/* --- Serious Modern Modals --- */

:root {
    --modal-bg: #ffffff;
    --modal-border: var(--elite-slate-200);
    --modal-shadow: 0 20px 50px -12px rgba(15, 23, 42, 0.15);
    --modal-overlay: rgba(15, 23, 42, 0.6);
}

.map-modal-overlay,
.date-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay);
    z-index: 2000000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.map-modal-overlay.active,
.date-modal-overlay.active { 
    display: flex; 
}

/* Container */
.map-modal-container,
.date-modal-container {
    background: var(--modal-bg);
    width: 100%;
    border-radius: 12px;
    box-shadow: var(--modal-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--modal-border);
    animation: modalScaleUp 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes modalScaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Header */
.map-modal-header,
.date-modal-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--elite-slate-100);
    background: #fff;
    flex-shrink: 0;
}

.map-modal-header h3,
.date-modal-header h3 { 
    font-size: 17px; 
    font-weight: 900; 
    color: var(--elite-slate-900); 
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--elite-slate-400);
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: var(--elite-slate-900);
}

/* Map Modal Specific */
.map-modal-container { max-width: 800px; }

.map-container {
    height: 400px;
    width: 100%;
    background: var(--elite-slate-50);
}

.map-modal-search {
    padding: 15px 24px;
    background: var(--elite-slate-50);
    border-bottom: 1px solid var(--elite-slate-100);
}

.map-search-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.map-search-wrapper input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--elite-slate-200);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    transition: all 0.2s ease;
}

.map-search-wrapper input:focus { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 4px rgba(0, 69, 165, 0.08); 
}

.btn-locate-me {
    background: #fff;
    border: 1px solid var(--elite-slate-200);
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--elite-slate-600);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-locate-me:hover {
    background: var(--elite-slate-100);
    color: var(--primary);
    border-color: var(--primary);
}

/* ============================================
   DATE MODAL - FULLY RESPONSIVE
   ============================================ */
.date-modal-container {
    max-width: min(520px, 92vw);
    max-height: min(600px, 85vh);
    width: 100%;
}

/* Scrollable middle section */
.date-modal-body {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.date-manual-inputs {
    padding: 10px 14px;
    display: flex;
    gap: 10px;
    background: var(--elite-slate-50);
    border-bottom: 1px solid var(--elite-slate-100);
    flex-shrink: 0;
}

.manual-field {
    flex: 1;
    min-width: 0;
}

.manual-field label {
    font-size: 10px;
    font-weight: 800;
    color: var(--elite-slate-500);
    text-transform: uppercase;
    margin-bottom: 4px;
    display: block;
}

.manual-field input {
    border: 1px solid var(--elite-slate-200);
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    width: 100%;
    box-sizing: border-box;
}

.date-shortcuts {
    padding: 6px 14px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    border-bottom: 1px solid var(--elite-slate-100);
    background: #fff;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.btn-shortcut {
    white-space: nowrap;
    background: var(--elite-slate-50);
    border: 1px solid var(--elite-slate-200);
    padding: 4px 11px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--elite-slate-700);
}

.btn-shortcut:hover { 
    border-color: var(--primary); 
    color: var(--primary); 
    background: #fff;
}

/* Calendar Grid */
.calendar-nav-header {
    background: #fff;
    padding: 8px 14px 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-arrow {
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--elite-slate-400);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.nav-arrow:hover {
    background: var(--elite-slate-50);
    color: var(--elite-slate-900);
}

.nav-selectors {
    display: flex;
    gap: 6px;
}

.nav-selectors select {
    background: var(--elite-slate-50);
    border: 1px solid var(--elite-slate-100);
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 13px;
}

.custom-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    padding: 4px 10px 8px;
    background: #fff;
}

.calendar-day-header {
    font-size: 10px;
    font-weight: 800;
    color: var(--elite-slate-400);
    text-transform: uppercase;
    text-align: center;
    padding: 3px 0;
}

/* KEY FIX: Use fixed height instead of aspect-ratio to prevent 
   calendar from being too tall on square/small screens */
.calendar-day {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--elite-slate-700);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.calendar-day:hover:not(.disabled):not(.selected) {
    background: var(--elite-slate-50);
    color: var(--primary);
}

.calendar-day.disabled {
    color: var(--elite-slate-200);
    cursor: default;
    text-decoration: line-through;
    opacity: 0.6;
}

.calendar-day.selected { 
    background: var(--om-blue, #0045A5) !important; 
    color: #fff !important;
    font-weight: 700;
}

.calendar-day.in-range { 
    background: #d1d5db;
    color: #000; 
    font-weight: 600;
}

/* Footer */
.map-modal-footer,
.date-modal-footer {
    padding: 12px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #fff;
    border-top: 1px solid var(--elite-slate-100);
    flex-shrink: 0;
}

.date-modal-footer {
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

.selected-range-preview {
    flex: 1 1 auto;
    white-space: nowrap;
}

.selected-range-preview strong {
    color: var(--elite-slate-900);
    font-size: 14px;
    display: block;
}

/* Buttons */
.btn-cancel {
    background: var(--elite-slate-50);
    color: var(--elite-slate-700);
}

.btn-confirm {
    background: #0045A5 !important;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 69, 165, 0.2);
}

.btn-cancel, .btn-confirm {
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-cancel:hover { background: var(--elite-slate-100); }
.btn-confirm:hover { background: var(--primary-dark); }

/* ===== TABLETS & SQUARE SCREENS (max 1024px) ===== */
@media (max-width: 1024px) {
    .date-modal-overlay {
        padding: 10px;
        align-items: flex-end;
    }

    .date-modal-container {
        max-width: 100%;
        max-height: 80vh;
        border-radius: 14px 14px 0 0;
    }

    .date-modal-header {
        padding: 12px 14px;
        position: sticky;
        top: 0;
        z-index: 10;
        background: #fff;
    }
    
    .date-modal-header h3 {
        font-size: 15px;
    }

    .calendar-day {
        height: 32px;
        font-size: 12px;
    }
}

/* ===== SMALL TABLETS (max 768px) ===== */
@media (max-width: 768px) {
    .date-modal-container {
        max-height: 85vh;
    }

    .calendar-day {
        height: 30px;
        font-size: 12px;
    }

    .manual-field input {
        padding: 6px 8px;
        font-size: 12px;
    }

    .btn-shortcut {
        padding: 3px 9px;
        font-size: 10px;
    }
}

/* ===== PHONES (max 480px) ===== */
@media (max-width: 480px) {
    .date-modal-overlay {
        padding: 0;
    }

    .date-modal-container {
        max-height: 100vh;
        max-height: 100dvh;
        height: 100%;
        border-radius: 0;
    }

    .calendar-day {
        height: 38px;
        font-size: 13px;
    }

    .date-modal-footer {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        position: sticky;
        bottom: 0;
        z-index: 10;
    }
    
    .selected-range-preview {
        margin-bottom: 6px;
        white-space: normal;
    }
    
    .date-footer-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }
    
    .btn-cancel, .btn-confirm {
        width: 100%;
        padding: 14px;
    }
}
