/**
 * Advanced Travel Search - Calendar CSS v5.0.0-CLEAN-DUAL
 * Estilos para calendario dual limpio y elegante
 * 
 * 🎯 CARACTERÍSTICAS:
 * ✅ Modal limpio con fondo blanco elegante
 * ✅ Dos calendarios lado a lado (estilo preferido del usuario)
 * ✅ Navegación en extremos con flechas discretas
 * ✅ Estados de días: normal, hover, seleccionado, rango
 * ✅ Tres botones: Limpiar, Cancelar, Aplicar
 * ✅ Color azul #337ab7 para selecciones
 * ✅ Responsive completo
 * 
 * @package AdvancedTravelSearch
 * @version 5.0.0-CLEAN-DUAL
 */

/* ==================== VARIABLES CSS ==================== */

:root {
    /* Colores principales */
    --ats-calendar-primary: #337ab7;
    --ats-calendar-primary-light: #e6f3ff;
    --ats-calendar-primary-dark: #2c5aa0;
    
    /* Fondos */
    --ats-calendar-bg: #ffffff;
    --ats-calendar-overlay: rgba(0, 0, 0, 0.5);
    --ats-calendar-surface: #f8f9fa;
    
    /* Textos */
    --ats-calendar-text: #2d3748;
    --ats-calendar-text-light: #718096;
    --ats-calendar-text-muted: #a0aec0;
    
    /* Bordes */
    --ats-calendar-border: #e2e8f0;
    --ats-calendar-border-light: #f1f3f4;
    
    /* Estados */
    --ats-calendar-hover: #f8f9fa;
    --ats-calendar-disabled: #f5f5f5;
    --ats-calendar-disabled-text: #cbd5e0;
    
    /* Sombras */
    --ats-calendar-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    --ats-calendar-shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    
    /* Transiciones */
    --ats-calendar-transition: all 0.2s ease;
    --ats-calendar-transition-fast: all 0.15s ease;
}

/* ==================== MODAL BASE ==================== */

.ats-calendar-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--ats-calendar-overlay);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: var(--ats-calendar-transition);
}

.ats-calendar-modal.show {
    display: flex;
    opacity: 1;
}

.ats-calendar-modal.opening {
    animation: atsModalFadeIn 0.3s ease-out;
}

.ats-calendar-modal.closing {
    animation: atsModalFadeOut 0.2s ease-in;
}

/* ==================== CONTENEDOR PRINCIPAL ==================== */

.ats-calendar-container {
    background: var(--ats-calendar-bg);
    border-radius: 12px;
    box-shadow: var(--ats-calendar-shadow);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    position: relative;
    overflow: hidden;
    transform: scale(0.9);
    transition: var(--ats-calendar-transition);
}

.ats-calendar-modal.show .ats-calendar-container {
    transform: scale(1);
}

/* ==================== BOTÓN CERRAR ==================== */

.ats-calendar-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 24px;
    color: var(--ats-calendar-text-light);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ats-calendar-transition-fast);
    z-index: 10;
}

.ats-calendar-close:hover {
    background: var(--ats-calendar-hover);
    color: var(--ats-calendar-text);
}

.ats-calendar-close:focus {
    outline: 2px solid var(--ats-calendar-primary);
    outline-offset: 2px;
}

/* ==================== CONTENEDOR DE CALENDARIOS ==================== */

.ats-calendars-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 32px 24px 80px 24px;
    position: relative;
}

/* ==================== CALENDARIO INDIVIDUAL ==================== */

.ats-single-calendar {
    padding: 0 16px;
    position: relative;
}

.ats-single-calendar:first-child {
    border-right: 1px solid var(--ats-calendar-border-light);
}

/* ==================== HEADER DE MES ==================== */

.ats-calendar-month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    height: 40px;
}

.ats-month-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--ats-calendar-text);
    margin: 0;
    text-align: center;
    flex: 1;
}

/* ==================== NAVEGACIÓN ==================== */

.ats-nav-button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--ats-calendar-border);
    background: var(--ats-calendar-bg);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--ats-calendar-text-light);
    transition: var(--ats-calendar-transition-fast);
}

.ats-nav-button:hover {
    border-color: var(--ats-calendar-primary);
    color: var(--ats-calendar-primary);
    background: var(--ats-calendar-primary-light);
}

.ats-nav-button:focus {
    outline: 2px solid var(--ats-calendar-primary);
    outline-offset: 2px;
}

.ats-nav-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.ats-nav-left,
.ats-nav-right {
    width: 32px;
    display: flex;
    justify-content: center;
}

/* Solo mostrar navegación en extremos */
.ats-single-calendar:first-child .ats-nav-right,
.ats-single-calendar:last-child .ats-nav-left {
    opacity: 0;
    pointer-events: none;
}

/* ==================== DÍAS DE LA SEMANA ==================== */

.ats-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    margin-bottom: 8px;
}

.ats-weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--ats-calendar-text-light);
    padding: 8px 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==================== GRID DE DÍAS ==================== */

.ats-days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

.ats-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--ats-calendar-transition-fast);
    position: relative;
    min-height: 40px;
    color: var(--ats-calendar-text);
    background: var(--ats-calendar-bg);
}

/* ==================== ESTADOS DE DÍAS ==================== */

/* Día normal */
.ats-day:hover:not(.ats-day-disabled):not(.ats-day-selected) {
    background: var(--ats-calendar-hover);
    color: var(--ats-calendar-text);
}

/* Día seleccionado (check-in/check-out) */
.ats-day.ats-day-selected {
    background: var(--ats-calendar-primary) !important;
    color: white !important;
    font-weight: 600;
    z-index: 2;
}

/* Rango intermedio */
.ats-day.ats-day-in-range {
    background: var(--ats-calendar-primary-light) !important;
    color: var(--ats-calendar-primary-dark) !important;
    font-weight: 500;
}

/* Día actual */
.ats-day.ats-day-today {
    font-weight: 700;
    color: var(--ats-calendar-primary);
}

.ats-day.ats-day-today:not(.ats-day-selected):not(.ats-day-in-range)::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--ats-calendar-primary);
    border-radius: 50%;
}

/* Día deshabilitado */
.ats-day.ats-day-disabled {
    color: var(--ats-calendar-disabled-text);
    cursor: not-allowed;
    background: var(--ats-calendar-disabled);
}

/* Día de mes anterior/siguiente */
.ats-day.ats-day-other-month {
    color: var(--ats-calendar-text-muted);
    opacity: 0.4;
}

/* ==================== ÁREA DE FECHAS SELECCIONADAS ==================== */

.ats-selected-dates-display {
    position: absolute;
    bottom: 16px;
    left: 24px;
    background: var(--ats-calendar-surface);
    border: 1px solid var(--ats-calendar-border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ats-calendar-text);
    min-width: 200px;
    opacity: 0;
    transform: translateY(10px);
    transition: var(--ats-calendar-transition);
    z-index: 5;
}

.ats-selected-dates-display.visible {
    opacity: 1;
    transform: translateY(0);
}

.ats-selected-dates-display.empty {
    color: var(--ats-calendar-text-muted);
    font-style: italic;
}

.ats-date-range-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ats-date-arrow {
    color: var(--ats-calendar-primary);
    font-weight: 600;
    font-size: 14px;
}

.ats-date-count {
    color: var(--ats-calendar-text-light);
    font-size: 12px;
    margin-left: 4px;
}

.ats-single-date {
    color: var(--ats-calendar-primary);
    font-weight: 600;
}

/* ==================== BOTONES DE ACCIÓN ==================== */

.ats-calendar-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--ats-calendar-bg);
    border-top: 1px solid var(--ats-calendar-border-light);
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.ats-calendar-button {
    padding: 10px 20px;
    border: 1px solid var(--ats-calendar-border);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--ats-calendar-transition-fast);
    min-width: 80px;
    text-align: center;
}

/* Botón Limpiar */
.ats-btn-clear {
    background: var(--ats-calendar-bg);
    color: var(--ats-calendar-text-light);
    border-color: var(--ats-calendar-border);
}

.ats-btn-clear:hover:not(:disabled) {
    background: var(--ats-calendar-hover);
    color: var(--ats-calendar-text);
    border-color: var(--ats-calendar-text-light);
}

/* Botón Cancelar */
.ats-btn-cancel {
    background: var(--ats-calendar-bg);
    color: var(--ats-calendar-text);
    border-color: var(--ats-calendar-border);
}

.ats-btn-cancel:hover {
    background: var(--ats-calendar-hover);
    border-color: var(--ats-calendar-text-light);
}

/* Botón Aplicar */
.ats-btn-apply {
    background: var(--ats-calendar-primary);
    color: white;
    border-color: var(--ats-calendar-primary);
}

.ats-btn-apply:hover:not(:disabled) {
    background: var(--ats-calendar-primary-dark);
    border-color: var(--ats-calendar-primary-dark);
}

.ats-btn-apply:disabled {
    background: var(--ats-calendar-disabled);
    color: var(--ats-calendar-disabled-text);
    border-color: var(--ats-calendar-border);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Focus states para todos los botones */
.ats-calendar-button:focus {
    outline: 2px solid var(--ats-calendar-primary);
    outline-offset: 2px;
}

/* ==================== RESPONSIVE DESIGN ==================== */

@media (max-width: 768px) {
    .ats-calendar-modal {
        padding: 16px;
    }
    
    .ats-calendar-container {
        max-width: 100%;
        border-radius: 8px;
        max-height: 95vh;
        overflow-y: auto;
    }
    
    .ats-calendars-container {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 24px 16px 100px 16px;
    }
    
    .ats-single-calendar {
        padding: 0;
    }
    
    .ats-single-calendar:first-child {
        border-right: none;
        border-bottom: 1px solid var(--ats-calendar-border-light);
        padding-bottom: 24px;
    }
    
    /* Mostrar navegación en ambos calendarios en mobile */
    .ats-single-calendar:first-child .ats-nav-right,
    .ats-single-calendar:last-child .ats-nav-left {
        opacity: 1;
        pointer-events: auto;
    }
    
    .ats-calendar-actions {
        padding: 12px 16px;
        flex-direction: column;
        gap: 8px;
        height: 80px;
    }
    
    .ats-calendar-button {
        width: 100%;
    }
    
    /* Área de fechas seleccionadas en mobile */
    .ats-selected-dates-display {
        position: relative;
        bottom: auto;
        left: auto;
        margin: 0 16px 12px 16px;
        width: calc(100% - 32px);
        min-width: auto;
        text-align: center;
        background: var(--ats-calendar-primary-light);
        border-color: var(--ats-calendar-primary);
        border-width: 1px;
    }
}

@media (max-width: 480px) {
    .ats-calendar-container {
        border-radius: 0;
        max-height: 100vh;
        width: 100vw;
        margin: 0;
    }
    
    .ats-calendars-container {
        padding: 20px 12px 120px 12px;
    }
    
    .ats-month-title {
        font-size: 16px;
    }
    
    .ats-day {
        min-height: 36px;
        font-size: 13px;
    }
    
    /* Área de fechas seleccionadas en mobile pequeño */
    .ats-selected-dates-display {
        margin: 0 12px 8px 12px;
        width: calc(100% - 24px);
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .ats-calendar-actions {
        height: 100px;
        padding: 8px 12px;
    }
}

/* ==================== ESTADOS ESPECIALES PARA ÁREA DE FECHAS ==================== */

.ats-selected-dates-display.selecting {
    background: linear-gradient(135deg, var(--ats-calendar-primary-light), #f0f8ff);
    border-color: var(--ats-calendar-primary);
    animation: pulse 2s infinite;
}

.ats-selected-dates-display.complete {
    background: linear-gradient(135deg, var(--ats-calendar-primary-light), var(--ats-calendar-surface));
    border-color: var(--ats-calendar-primary);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(51, 122, 183, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(51, 122, 183, 0.1);
    }
}

/* ==================== MEJORAS VISUALES ADICIONALES ==================== */

.ats-date-separator {
    display: inline-flex;
    align-items: center;
    margin: 0 4px;
    color: var(--ats-calendar-primary);
}

.ats-date-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ats-date-range-main {
    font-weight: 600;
    color: var(--ats-calendar-text);
}

.ats-date-range-sub {
    font-size: 11px;
    color: var(--ats-calendar-text-light);
    font-weight: normal;
}

/* ==================== ANIMACIONES ==================== */

@keyframes atsModalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes atsModalFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

@keyframes atsDaySelect {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.ats-day-selected {
    animation: atsDaySelect 0.2s ease-out;
}

/* ==================== ACCESIBILIDAD ==================== */

.ats-calendar-modal[aria-hidden="true"] {
    display: none !important;
}

.ats-day[aria-selected="true"] {
    background: var(--ats-calendar-primary) !important;
    color: white !important;
}

.ats-day:focus {
    outline: 2px solid var(--ats-calendar-primary);
    outline-offset: 2px;
    z-index: 3;
}

/* Alto contraste */
@media (prefers-contrast: high) {
    :root {
        --ats-calendar-primary: #0052cc;
        --ats-calendar-border: #666666;
        --ats-calendar-text: #000000;
        --ats-calendar-disabled-text: #666666;
    }
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* ==================== UTILIDADES ==================== */

.ats-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Ocultar scrollbars en el modal */
.ats-calendar-container {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.ats-calendar-container::-webkit-scrollbar {
    display: none;
}

/* ==================== PRINT STYLES ==================== */

@media print {
    .ats-calendar-modal {
        display: none !important;
    }
}