/**
 * Project Filter Widget Styles
 * CSS styles for the Elementor Project Filter widget
 */

/* Placeholder Image Styles */
.aldesa-placeholder {
    background-color: #f5f5f5 !important;
    background-image: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    filter: grayscale(100%) opacity(0.6);
    object-fit: contain;
    object-position: center;
    padding: 20px;
    box-sizing: border-box;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

/* Ensure placeholder images maintain aspect ratio */
.elementor-post__thumbnail .aldesa-placeholder {
    width: 100%;
    height: 100%;
    display: block;
}

/* Project card placeholder styling for non-Elementor containers */
.project-image .aldesa-placeholder {
    width: 100%;
    height: auto;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main Container */
.project-filter-container {
    max-width: 100%;
    margin: 0 auto;
}

.project-filter-title {
    margin: 0 0 20px 0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

/* Form Styles - Matching Elementor Contact Form */
.project-filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: end;
    margin-bottom: 20px;
}

.project-filter-item {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
}

/* Label styling to match Elementor */
.project-filter-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #6daa3b;
    font-size: 12px;
    line-height: 10px;
    letter-spacing: 4.1px!important;
    padding-bottom:0px!important;
    text-transform: uppercase;
}

/* Select wrapper to match Elementor structure */
.project-filter-select-wrapper {
    position: relative;
    width: 100%;
}

.project-filter-select-wrapper.remove-before {
    /* Matches Elementor's remove-before class styling */
    position: relative;
}

/* Caret down wrapper */
.select-caret-down-wrapper {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 2;
}
.elementor-select-wrapper .select-caret-down-wrapper svg {
    aspect-ratio: unset;
    display: unset;
    width: 1em;
    fill: currentColor;
    overflow: visible;
}

.select-caret-down-wrapper svg {
    width: 1em;
}

/* Select styling to match Elementor */
.project-filter-select {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 1px solid #F3F3F3;
    border-width:0px 0px 0px 0px;
    border-radius: 4px;
    background-color: #F3F3F3;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}


.project-filter-select:focus {
    outline: none;
    border-color: #6daa3b;
    box-shadow: 0 0 0 2px rgba(109, 170, 59, 0.1);
}

.project-filter-select:focus + .select-caret-down-wrapper svg {
    fill: #6daa3b;
}

.project-filter-select option {
    padding: 8px;
    color: #333;
    background-color: #fff;
}

/* Button Styles */
.project-filter-button {
    background-color: #6daa3b!important;
    border: 1px solid #6daa3b!important;
    font-family: "Helvetica", Sans-serif;
    color: #FFFFFF!important;
    fill:#FFFFFF;
    border: none;
    padding: 10px 20px;
    border-radius: 39px!important;
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    white-space: nowrap;
    width: auto;
    min-width: 120px;
}

.project-filter-button:hover:not(:disabled),
.project-filter-button:focus:not(:disabled),
.project-filter-button:visited:not(:disabled) {
    color: #FFFFFF;
    background-color: #0e6634;
    border: 1px solid #0e6634;
}

.project-filter-button:active:not(:disabled) {
    transform: translateY(0);
    color: #FFFFFF;
}

.project-filter-button:disabled,
.project-filter-button-disabled {
    border: 1px solid #ccc !important;
    background-color: #ccc !important;
    cursor: not-allowed;
    opacity: 0.7;
    transform: none !important;
    color: #FFFFFF;
}

.project-filter-button:disabled:hover,
.project-filter-button-disabled:hover {
    background-color: #ccc !important;
    transform: none !important;
    color: #FFFFFF;
}

/* Results Container */
.project-filter-results {
    clear: both;
    width: 100%;
}

.project-filter-results:empty {
    display: none;
}

.project-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.project-result-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    background: #fff;
    transition: box-shadow 0.3s ease;
}

.project-result-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.project-result-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
}

.project-result-content {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
}

.project-result-meta {
    font-size: 12px;
    color: #888;
    border-top: 1px solid #f0f0f0;
    padding-top: 15px;
    margin-top: 15px;
}

.project-result-meta-item {
    display: inline-block;
    margin-right: 15px;
    margin-bottom: 5px;
}

.project-result-meta-label {
    font-weight: 600;
    color: #555;
}

.project-results-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

.project-results-count {
    margin-bottom: 20px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
}

/* Loading and Error States */
.project-filter-loading,
.project-filter-error {
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
    text-align: center;
    font-family: "Helvetica", Sans-serif;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.project-filter-loading {
    background: linear-gradient(135deg, #6daa3b 0%, #5a9632 100%);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.project-filter-error {
    background: linear-gradient(135deg, #dc3232 0%, #c73232 100%);
    color: #ffffff;
    border: none;
    font-size: 16px;
    font-weight: 500;
}
.project-result-attachment {
    height: auto;
    top: calc(50% + 30px);
    left: calc(50% + 1px);
    position: absolute;
    transform: scale(1.20) translate(-50%,-50%);
}


/* Loading Spinner */
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced loading state with pulse effect */
.project-filter-loading {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0% { 
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(109, 170, 59, 0.3);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 0 6px 20px rgba(109, 170, 59, 0.4);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(109, 170, 59, 0.3);
    }
}

/* Project Results Styles */
.filtered-projects {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.project-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.project-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.project-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background-color: #f5f5f5;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.project-card:hover .project-image img {
    transform: scale(1.05);
}

.project-content {
    padding: 20px;
}

.project-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.project-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.project-title a:hover {
    color: #007cba;
}

.project-excerpt {
    margin-bottom: 15px;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.project-excerpt p {
    margin: 0 0 10px 0;
}

.project-excerpt p:last-child {
    margin-bottom: 0;
}

.project-meta {
    margin-bottom: 20px;
    font-size: 13px;
}

.project-meta > div {
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.project-meta > div:last-child {
    margin-bottom: 0;
}

.meta-label {
    font-weight: 600;
    color: #333;
    min-width: fit-content;
}

.meta-value {
    color: #666;
    flex: 1;
}

.project-actions {
    display: flex;
    justify-content: flex-start;
}

.project-link {
    color: #007cba;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: color 0.2s ease;
}

.project-link:hover {
    color: #005177;
    text-decoration: underline;
}

/* Empty State */
.filtered-projects-empty {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 20px;
    opacity: 0.7;
}

.filtered-projects-empty h3 {
    margin: 0 0 10px 0;
    font-size: 20px;
    color: #333;
}

.filtered-projects-empty p {
    margin: 0;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .project-filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .project-filter-item {
        min-width: auto;
        flex: none;
        align-items: flex-start!important;
    }
    
    .project-filter-button {
        min-width: auto;
        width: 100%;
    }
    
    .filtered-projects {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .project-content {
        padding: 15px;
    }
    
    .project-title {
        font-size: 16px;
    }
    
    /* Loading state mobile adjustments */
    .project-filter-loading {
        padding: 16px;
        font-size: 14px;
        flex-direction: column;
        gap: 8px;
    }
    
    .loading-spinner {
        width: 20px;
        height: 20px;
        border-width: 2px;
    }
}

@media (max-width: 480px) {
    .project-filter-container {
        padding: 0 10px;
    }
    
    .project-filter-title {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .project-filter-form {
        gap: 12px;
    }
    
    .project-filter-select,
    .project-filter-button {
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .project-image {
        height: 160px;
    }
}

/* High contrast support */
@media (prefers-contrast: high) {
    .project-filter-select {
        border-width: 2px;
    }
    
    .project-card {
        border-width: 2px;
    }
    
    .project-filter-button {
        border: 2px solid transparent;
    }
    
    .project-filter-button:focus {
        border-color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .project-card,
    .project-image img,
    .project-filter-button,
    .project-filter-select,
    .project-title a,
    .project-link {
        transition: none;
    }
    
    .project-card:hover {
        transform: none;
    }
    
    .project-card:hover .project-image img {
        transform: none;
    }
    
    /* Disable loading animations for reduced motion */
    .loading-spinner {
        animation: none;
        border: 3px solid rgba(255, 255, 255, 0.3);
        border-top: 3px solid #ffffff;
    }
    
    .project-filter-loading {
        animation: none;
        transform: none !important;
    }
}

/* Print styles */
@media print {
    .project-filter-form,
    .project-filter-loading,
    .project-filter-error {
        display: none;
    }
    
    .project-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .project-title a,
    .project-link {
        color: #000;
        text-decoration: underline;
    }
}
