/**
 * CSS per Template Archivio Case
 * Basato su screenshot design
 */

/* Layout principale */
.case-archive-container {
    display: flex;
    gap: 30px;
    max-width: 1920px;
    margin: 0 auto;
    padding: 20px;
    font-family: "Titillium Web", Sans-serif;
}

/* Sidebar Filtri */
.case-filters-sidebar {
    flex: 0 0 300px;
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    height: fit-content;
}

.filters-wrapper h3 {
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: bold;
}

.filter-group {
    margin-bottom: 25px;
}

.filter-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
}

/* Input Search */
.search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* Range Prezzi */
.price-range {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    display: none;
}

.price-range input {
    flex: 1;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

/* Slider container per prezzo */
.price-slider-container {
    margin: 10px 0;
}

.price-slider {
    width: 100%;
    height: 4px;
    background: #13223D;
    border-radius: 2px;
    position: relative;
    margin: 8px 0;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
}

/* Range Sliders */
.surface-range,
.rooms-range {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.range-value {
    background: #13223D;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    min-width: 30px;
    text-align: center;
    user-select: none;
}

.range-slider {
    flex: 1;
    height: 4px;
    background: #13223D;
    border-radius: 2px;
    position: relative;
    margin: 8px 0;
}

/* Slider Handles */
.slider-handle {
    position: absolute;
    top: -6px;
    width: 16px;
    height: 16px;
    background: #13223D;
    border: 2px solid white;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.1s ease;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.slider-handle:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.slider-handle:active,
.slider-handle.dragging {
    cursor: grabbing;
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.slider-handle-min {
    left: 0;
}

.slider-handle-max {
    right: 0;
    transform: translateX(50%);
}

/* Range Track */
.range-slider::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right, #13223D 0%, #13223D 100%);
    border-radius: 2px;
}

/* Radio Groups */
.radio-group label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    font-weight: normal;
    margin-bottom: 5px;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    margin-right: 8px;
}

.radio-group span.count {
    background: #e0e0e0;
    color: #666;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    min-width: 20px;
    text-align: center;
    transition: all 0.2s ease;
}

.radio-group span.count:not(:empty) {
    background: #13223D;
    color: white;
}

/* Disabled filter state */
.radio-group label.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.radio-group label.disabled span.count {
    background: #f0f0f0;
    color: #999;
}

.radio-group input[type="radio"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Backward compatibility - Checkbox Groups */
.checkbox-group label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    font-weight: normal;
    margin-bottom: 5px;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 8px;
}

.checkbox-group span.count {
    background: #e0e0e0;
    color: #666;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    min-width: 20px;
    text-align: center;
    transition: all 0.2s ease;
}

.checkbox-group span.count:not(:empty) {
    background: #13223D;
    color: white;
}

/* Disabled filter state */
.checkbox-group label.disabled,
.car-access-filters label.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.checkbox-group label.disabled span.count {
    background: #f0f0f0;
    color: #999;
}

.checkbox-group input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Search hint */
.search-hint {
    display: block;
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    font-style: italic;
}

/* Car accessibility filter */
.car-access-filters label {
    display: flex;
    align-items: center;
    padding: 5px 0;
    font-weight: normal;
    margin-bottom: 5px;
}

.car-access-filters input[type="checkbox"] {
    margin-right: 8px;
}

/* Position filters */
.position-filters label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    font-weight: normal;
    margin-bottom: 5px;
}

.position-filters input[type="checkbox"] {
    margin-right: 8px;
}

/* Rating filters */
.rating-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rating-option {
    display: flex;
    align-items: center;
}

.rating-option input[type="radio"] {
    margin-right: 8px;
}

.rating-option label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 0;
    font-weight: normal;
    margin: 0;
}

.rating-option .stars {
    color: #ffd700;
    font-size: 14px;
    line-height: 1;
    font-family: serif;
}

.rating-option .rating-text {
    font-size: 13px;
    color: #333;
}

/* Main Content */
.case-main-content {
    flex: 1;
}

/* Controlli ordinamento e contatori */
.case-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.results-count {
    color: #666;
    font-size: 16px;
    font-weight: 500;
}

.results-count strong {
    color: #333;
    font-size: 18px;
}

.control-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.sort-controls {
    display: flex;
    align-items: center;
}

.case-sort-select {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    min-width: 200px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><path fill="%23666" d="M6 9L2 5h8z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 32px;
    appearance: none;
}

.case-sort-select:focus {
    outline: none;
    border-color: #13223D;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

.case-sort-select:hover {
    border-color: #13223D;
}

.view-toggle {
    display: flex;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 36px;
    border: none;
    background: #13223D;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    border-right: 1px solid #ddd;
}

.view-toggle-btn:last-child {
    border-right: none;
}

.view-toggle-btn:hover {
    background-color: #FCA310 !important;
    color: #13223D;
}

.view-toggle button {
    border: none;
    color: #13223D;
}

.view-toggle button.active {
    background: #FCA310;
    color: #13223D;
}

.view-toggle button.active:hover {
    background: #13223D;
    color: white;
}

button.reset-filters {
    font-size: 12px;
    padding: 5px 10px;
    text-transform: uppercase;
    font-weight: 600;
    border-radius: 20px;
}

.view-toggle-btn svg {
    width: 16px;
    height: 16px;
}

/* Responsive controlli */
@media (max-width: 768px) {

    /* Force mobile results button to show when filters are open */
    .mobile-filters-checkbox:checked~.case-filters-sidebar .mobile-results-btn,
    body:has(.mobile-filters-checkbox:checked) .mobile-results-btn {
        display: block !important;
    }

    .case-controls {
        flex-direction: column;
        gap: 20px;
        align-items: stretch;
        text-align: center;
        padding: 15px;
        margin-bottom: 20px;
        background: #f8f9fa;
        border-radius: 12px;
        border: 1px solid #e9ecef;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .results-count {
        font-size: 18px;
        font-weight: 600;
        color: #13223D;
        margin-bottom: 5px;
        order: -1;
    }

    .results-count strong {
        font-size: 20px;
        color: #13223D;
    }

    .control-actions {
        flex-direction: row;
        gap: 15px;
        justify-content: space-between;
        align-items: center;
    }

    .sort-controls {
        flex: 1;
        display: flex;
        justify-content: flex-start;
    }

    .case-sort-select {
        min-width: auto;
        width: auto;
        min-width: 180px;
        max-width: none;
        padding: 12px 16px;
        font-size: 15px;
        font-weight: 500;
        border-radius: 8px;
        border: 2px solid #ddd;
        background: white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        transition: all 0.3s ease;
    }

    .case-sort-select:focus {
        border-color: #13223D;
        box-shadow: 0 0 0 3px rgba(19, 34, 61, 0.15);
        outline: none;
    }

    .view-toggle {
        flex-shrink: 0;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .view-toggle-btn {
        width: 48px;
        height: 48px;
        border: none;
        background: #13223D;
        color: white;
        transition: all 0.3s ease;
        touch-action: manipulation;
    }

    .view-toggle-btn:hover {
        background-color: #FCA310 !important;
        color: #13223D;
        transform: scale(1.05);
    }

    .view-toggle-btn.active {
        background: #FCA310;
        color: #13223D;
    }

    .view-toggle-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* Ulteriori ottimizzazioni per schermi molto piccoli */
@media (max-width: 480px) {
    .case-controls {
        padding: 12px;
        gap: 15px;
    }

    .control-actions {
        flex-direction: row;
        gap: 12px;
    }

    .sort-controls {
        justify-content: center;
    }

    .case-sort-select {
        width: 100%;
        min-width: auto;
        max-width: 100%;
    }

    .view-toggle {
        align-self: center;
    }

    .results-count {
        font-size: 16px;
        margin: 0 !important;
        border: none;
        border-left: none !important;
        padding: 0 !important;
    }

    .results-count strong {
        font-size: 18px;
    }
}

/* Grid Case */
.case-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

/* Vista Lista */
.case-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* No Results */
.no-cases-found {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

/* Loading States */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    text-align: center;
    color: #13223D;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #13223D;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.loading-spinner p {
    margin: 0;
    font-weight: 500;
}

/* Grid Loading State */
.case-grid.loading {
    position: relative;
    pointer-events: none;
}

.case-grid.loading .case-card {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

/* Results Counter */
.results-count {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-left: 4px solid #13223D;
    border-radius: 4px;
}

.results-count p {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.results-count strong {
    color: #13223D;
    font-weight: 600;
}

/* Filter Error */
.filter-error {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border: 2px dashed #ddd;
    border-radius: 8px;
    margin: 20px 0;
}

.filter-error h3 {
    color: #d32f2f;
    margin: 0 0 10px 0;
}

.filter-error p {
    color: #666;
    margin: 0 0 20px 0;
}

/* Disabled Filters During Loading */
.filter-group input:disabled,
.filter-group select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Smooth Transitions */
.case-grid {
    transition: opacity 0.3s ease;
}

.case-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
    box-shadow: 0 5px 10px #00000057;
    border: none;
}

/* Reset Button - Stile moderno magenta */
button.reset-filters {
    background: transparent;
    color: #13223D;
    border: 1px solid #13223D;
    border-radius: 6px;
    font-size: 14px !important;
    font-weight: 600 !important;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    text-transform: none;
    letter-spacing: 0.5px;
    display: inline-block !important;
    padding: 4px 10px;
}

button.reset-filters:hover {
    background: #13223D;
    border-color: #13223D;
    transform: translateY(-1px);
    font-weight: 600 !important;
}

button.reset-filters:active {
    transform: translateY(0);
}

/* Filter Active States */
.filter-group input:checked+label,
.checkbox-group input:checked,
.radio-group input:checked {
    accent-color: #13223D;
}

.checkbox-group label:has(input:checked),
.radio-group label:has(input:checked) {
    background: rgba(0, 124, 186, 0.1);
    border-radius: 4px;
    padding: 4px;
}

/* Search Input Focus */
.search-input:focus {
    outline: none;
    border-color: #13223D;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* Pagination Styles */
.case-pagination {
    margin: 30px 0;
    text-align: center;
}

.page-numbers-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.page-numbers {
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: #fff;
    color: #13223D;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 40px;
    text-align: center;
}

.page-numbers:hover {
    background: #13223D;
    color: #fff;
    border-color: #13223D;
    text-decoration: none;
}

.page-numbers.current {
    background: #13223D;
    color: #fff;
    border-color: #13223D;
    font-weight: 600;
}

.page-numbers.prev,
.page-numbers.next {
    padding: 8px 16px;
    font-weight: 600;
}

.page-numbers.prev:hover,
.page-numbers.next:hover {
    background: #005177;
}

.dots {
    color: #666;
    padding: 8px 4px;
    font-weight: bold;
}

.pagination-info {
    color: #666;
    font-size: 14px;
    margin-top: 10px;
}

/* Pagination Loading State */
.case-pagination.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Fast Filters Loading State */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    margin: 20px 0;
    font-size: 18px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 1;
    }
}

/* Performance Stats (debug mode) */
.performance-stats {
    position: fixed;
    top: 32px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 9999;
    font-family: monospace;
}

.performance-stats.hidden {
    display: none;
}

/* Mobile Filter Toggle */
.mobile-filter-toggle {
    display: none;
}

.mobile-filters-checkbox {
    display: none;
}

.mobile-filters-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #13223D;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    border: none;
    margin-bottom: 20px;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mobile-filters-btn:hover {
    background: #FCA310;
    color: #13223D;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.mobile-filters-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.mobile-filters-close {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    width: 30px;
    height: 30px;
    background: #666;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    line-height: 1;
    font-weight: bold;
    transition: all 0.2s ease;
    z-index: 1001;
}

.mobile-filters-close:hover {
    background: #FCA310;
    color: #13223D;
}

.mobile-filters-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

/* Mobile Results Button - Hidden by default */
.mobile-results-btn {
    display: none;
    /* Hidden on desktop by default */
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: #13223D;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
    touch-action: manipulation;
}

.mobile-results-btn p {
    margin: 0;
}

.mobile-results-btn:hover {
    background: #FCA310;
    color: #13223D;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.mobile-results-btn:active {
    transform: translateY(0);
}

.mobile-results-text {
    display: block;
    line-height: 1.2;
}

/* Responsive */
@media (max-width: 767px) {
    .case-archive-container {
        flex-direction: column;
        gap: 0;
    }

    /* Show mobile toggle button */
    .mobile-filter-toggle {
        display: block;
        padding: 20px;
        margin-bottom: 0;
    }

    /* Hide sidebar by default on mobile */
    .case-filters-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: #f5f5f5;
        z-index: 999;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
        opacity: 0;
        visibility: hidden;
    }

    /* Show mobile close button inside sidebar */
    .mobile-filters-close {
        display: flex;
    }

    /* Sidebar visibility is now handled by JavaScript */

    /* Adjust filters wrapper padding for close button */
    .case-filters-sidebar .filters-wrapper {
        position: relative;
        padding-top: 60px;
        padding-bottom: 140px;
        /* Space for mobile results button */
    }

    /* Show mobile results button only when filters are open */
    .mobile-filters-checkbox:checked~.case-filters-sidebar .mobile-results-btn {
        display: block;
    }

    /* Alternative selector in case the structure is different */
    .mobile-filters-checkbox:checked~* .mobile-results-btn {
        display: block;
    }

    .case-grid {
        grid-template-columns: 1fr;
    }

    /* Pagination Mobile */
    .page-numbers-wrapper {
        gap: 4px;
    }

    .page-numbers {
        padding: 6px 8px;
        font-size: 14px;
        min-width: 32px;
    }

    .page-numbers.prev,
    .page-numbers.next {
        padding: 6px 12px;
    }

    .pagination-info {
        font-size: 12px;
    }

    /* Slider handles più grandi su mobile */
    .slider-handle {
        width: 24px;
        height: 24px;
        top: -10px;
    }

    .slider-handle:hover {
        transform: scale(1.2);
    }

    .slider-handle:active,
    .slider-handle.dragging {
        transform: scale(1.3);
    }
}