/**
 * 🎨 K12 SEARCH OVERLAYS - LoveForm-Style Modal CSS
 * Styling for calendar and kids selector overlays
 */

/* ============================================
   🎯 OVERLAY CONTAINER
   ============================================ */

.k12-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    animation: fadeIn 300ms ease-out;
}

.k12-search-overlay.d-none {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   📦 MODAL STRUCTURE
   ============================================ */

.overlay-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #222;
    margin: 0;
}

.btn-close-overlay {
    background: none;
    border: none;
    font-size: 24px;
    color: #222;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 200ms;
}

.btn-close-overlay:hover {
    background-color: #f0f0f0;
}

.modal-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-modal-action {
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 200ms ease;
}

.btn-modal-action.btn-primary {
    background: #2AC8C8;
    color: white;
}

.btn-modal-action.btn-primary:hover:not(:disabled) {
    background: #289A96;
    transform: translateY(-1px);
}

.btn-modal-action.btn-secondary {
    background: white;
    color: #222;
    border: 1px solid #ddd;
}

.btn-modal-action.btn-secondary:hover {
    background: #f9f9f9;
}

.btn-modal-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   📅 CALENDAR OVERLAY STYLING
   ============================================ */

.k12-calendar-overlay {
    /* Specific calendar styling */
}

.calendar-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 20px;
}

.calendar-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.nav-month-btn {
    background: none;
    border: none;
    color: #222;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 200ms;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-month-btn:hover {
    background-color: #f0f0f0;
}

.calendar-month {
    font-size: 15px;
    font-weight: 600;
    color: #222;
    margin: 0;
    flex: 1;
    text-align: center;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: #717171;
}

.calendar-weekdays div {
    width: 32px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.calendar-day {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 200ms ease;
    margin: 0 auto;
    user-select: none;
}

.calendar-day:not(.disabled):hover {
    background-color: #f0f0f0;
}

.calendar-day.today {
    border: 2px solid #2AC8C8;
    font-weight: 600;
    color: #2AC8C8;
}

.calendar-day.selected {
    background-color: #2AC8C8;
    color: white;
    font-weight: 600;
}

.calendar-day.in-range {
    background-color: #E5F8FF;
    color: #222;
}

.calendar-day.prev-month,
.calendar-day.next-month {
    color: #ccc;
    cursor: default;
}

.calendar-day.disabled {
    color: #ccc;
    cursor: not-allowed;
}

/* ============================================
   👨‍👩‍👧 KIDS SELECTOR OVERLAY STYLING
   ============================================ */

.k12-kids-overlay .modal-body {
    padding: 24px;
}

.kids-summary {
    background: #f9f9f9;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 24px;
    text-align: center;
}

.summary-text {
    font-size: 16px;
    font-weight: 600;
    color: #222;
    margin: 0 0 4px 0;
}

.summary-details {
    font-size: 13px;
    color: #717171;
    margin: 0;
}

.kids-categories {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.grade-category {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.grade-category:last-child {
    border-bottom: none;
}

.category-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-name {
    font-size: 15px;
    font-weight: 600;
    color: #222;
}

.category-grades {
    font-size: 13px;
    color: #717171;
}

.category-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f9f9f9;
    padding: 8px 12px;
    border-radius: 8px;
}

.btn-count {
    background: white;
    border: 1px solid #ddd;
    color: #222;
    font-size: 18px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 200ms ease;
    padding: 0;
}

.btn-count:hover:not(:disabled) {
    border-color: #2AC8C8;
    color: #2AC8C8;
    background: #E5F8FF;
}

.btn-count:disabled,
.btn-count.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.count-display {
    font-size: 16px;
    font-weight: 600;
    color: #222;
    min-width: 24px;
    text-align: center;
}

.kids-total {
    background: #f9f9f9;
    padding: 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 15px;
    color: #717171;
}

.total-label {
    font-weight: 600;
    color: #222;
}

.total-count {
    font-weight: 700;
    color: #222;
    font-size: 18px;
}

.total-limit {
    color: #ccc;
    font-size: 14px;
}

/* ============================================
   📱 RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .overlay-modal {
        max-width: 95%;
        max-height: 80vh;
        border-radius: 12px;
    }

    .calendar-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .modal-footer {
        flex-direction: column-reverse;
    }

    .btn-modal-action {
        width: 100%;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .overlay-modal {
        width: 100%;
        max-height: 100%;
        border-radius: 12px 12px 0 0;
        position: absolute;
        bottom: 0;
    }

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

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

    .calendar-weekdays div {
        width: 28px;
        height: 24px;
        font-size: 11px;
    }

    .category-controls {
        gap: 8px;
        padding: 6px 8px;
    }

    .btn-count {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
}

/* ============================================
   ✨ ACCESSIBILITY
   ============================================ */

.overlay-modal:focus-within {
    outline: 2px solid #2AC8C8;
    outline-offset: -2px;
}

.btn-close-overlay:focus,
.nav-month-btn:focus,
.btn-count:focus,
.btn-modal-action:focus {
    outline: 2px solid #2AC8C8;
    outline-offset: 2px;
}

/* ============================================
   🎨 BUGGY BRAND COLORS
   ============================================ */

:root {
    --primary-coral: #2AC8C8;
    --primary-coral-hover: #289A96;
    --neutral-dark: #222;
    --neutral-medium: #717171;
    --neutral-light: #ccc;
    --neutral-light-bg: #f0f0f0;
    --neutral-light-bg-alt: #f9f9f9;
}

/* ============================================
   ✨ AIRBNB-STYLE WEEKDAY PILLS (BUG-134)
   Inline weekday selector below calendar
   ============================================ */

/* ✨ BUG-086: Calendar controls row (weekday pills + trip type pill) */
.calendar-controls-row {
    margin-top: -6px;
}

.weekday-selector-inline {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 0 1rem;
}

/* ✨ BUG-086: Black circle design (matching LoveForm/Airbnb style) */
.weekday-pill-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    position: relative;
    top: -12px;
    border: none;
    border-radius: 50%;
    background: #222;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.weekday-pill-inline:hover {
    background: #289a96;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(40, 154, 150, 0.3);
}

.weekday-pill-inline.active,
.weekday-pill-inline.selected {
    background: #289a96;
    color: #fff;
    box-shadow: 0 4px 16px rgba(40, 154, 150, 0.4);
}

.weekday-pill-inline .day-letter {
    font-weight: 600;
}

/* ✨ BUG-086: Trip Type Pill (One Way / Round Trip toggle) */
/* Outline style with black border - fills with teal when active */
.trip-type-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 1rem;
    border-radius: 22px;
    border: 2px solid #222;
    background: transparent;
    color: #222;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    white-space: nowrap;
}

/* Hover: moves towards user with scale, keeps border */
.trip-type-pill:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(34, 34, 34, 0.2);
}

/* Active/selected state: teal background without border */
.trip-type-pill.active {
    background: #289a96;
    color: #fff;
    border: 2px solid #289a96;
    box-shadow: 0 4px 16px rgba(40, 154, 150, 0.4);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .weekday-selector-inline {
        gap: 0.375rem;
    }

    .weekday-pill-inline {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }
}

/* ============================================
   🖥️ LAPTOP-FRIENDLY MODAL HEIGHT (BUG-134/135)
   BUG-100: Match search bar width: 834px (Airbnb pattern)
   ============================================ */

#transportationCalendarModal .modal-container {
    max-height: 620px; /* BUG-135: Increased from 544px to show preset pills */
    max-width: 834px;  /* BUG-100: Match search bar width (was 850px) */
}

#transportationCalendarModal .modal-content-scrollable {
    max-height: none !important; /* BUG-100: Remove height constraint */
    overflow-y: visible !important; /* BUG-100: Remove scroll, allow full calendar display */
    overflow: visible !important; /* BUG-100: Remove all overflow */
    width: 100%; /* BUG-100: Fill modal-container width */
}

/* BUG-100: Override Bootstrap container width constraint */
#transportationCalendarModal .modal-content-scrollable .container,
#transportationCalendarModal .modal-content-scrollable > .container {
    max-width: 100% !important; /* Override Bootstrap max-width to fill modal */
    width: 832px !important; /* Force exact width (modal-content-scrollable is 832px) */
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* BUG-100: Override tab-pane padding/margin */
#transportationCalendarModal .tab-pane {
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Compact calendar to fit LoveForm height */
#transportationCalendarModal .calendar-section {
    padding: 0; /* BUG-100: Remove padding, apply to dual-calendar instead */
    width: 100% !important; /* BUG-100: Fill modal-container width */
    box-sizing: border-box !important; /* Include padding in width calculation */
}

#transportationCalendarModal .dual-calendar-container {
    max-width: 834px !important; /* BUG-100: Match search bar width (Airbnb pattern) */
    width: 834px !important; /* BUG-100: Force exact search bar width */
    margin: 0 auto !important; /* Center within parent */
    padding: 0; /* BUG-100: No padding on container */
    box-sizing: border-box !important;
    gap: 1rem; /* Reduce gap between calendars */
}

#transportationCalendarModal .calendar-panel {
    padding: 0.5rem;
    min-width: 397px; /* BUG-100: Force panels to expand (834px - 24px padding - 16px gap) / 2 = 397px */
    flex: 1 1 397px; /* Allow panels to grow from 397px base */
}

#transportationCalendarModal .apple-calendar-grid {
    gap: 2px;
}

#transportationCalendarModal .calendar-day-cell {
    padding: 4px;
    min-height: 28px;
    font-size: 13px;
}

/* Compact tab content margin */
#transportationCalendarModal .tab-pane.mt-5 {
    margin-top: 1rem !important;
}

/* ============================================
   🎯 TAB PILL BUTTONS - BUG-135 Fix
   Custom styles for .cal-tabs and .cal-tab-pill
   ============================================ */

/* Tab container - pill group styling */
#transportationCalendarModal .cal-tabs {
    display: flex;
    gap: 4px;
    background: #f1f1f1;
    padding: 4px;
    border-radius: 10px;
    margin-left: 1rem; /* BUG-135: Add left spacing so Dates tab isn't cut off */
}

/* Tab pill buttons */
#transportationCalendarModal .cal-tab-pill {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

/* Active tab pill */
#transportationCalendarModal .cal-tab-pill.active {
    background: white;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Hover state for inactive pills */
#transportationCalendarModal .cal-tab-pill:not(.active):hover {
    background: rgba(255,255,255,0.5);
    color: #333;
}

/* Tab count badge */
#transportationCalendarModal .cal-tab-pill .tab-count {
    display: inline-block;
    background: #2AC8C8;
    color: white;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
    min-width: 18px;
    text-align: center;
}

/* Hide count when zero */
#transportationCalendarModal .cal-tab-pill .tab-count:empty,
#transportationCalendarModal .cal-tab-pill .tab-count[data-count="0"] {
    display: none;
}

/* ============================================
   🌴 RECHARGE TAB - Rest Day Toggle Styles (BUG-135)
   ============================================ */

.rest-day-toggle .toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.rest-day-checkbox:checked + .toggle-slider {
    background-color: #2AC8C8 !important;
}

.rest-day-checkbox:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.rest-day-checkbox:not(:checked) + .toggle-slider {
    background-color: #ccc !important;
}

/* Hover effect on toggle */
.rest-day-toggle:hover .toggle-slider {
    opacity: 0.9;
}

/* For smaller laptop screens */
@media (max-height: 800px) {
    #transportationCalendarModal .modal-container {
        max-height: 590px; /* BUG-135: Increased from 520px */
    }

    #transportationCalendarModal .modal-content-scrollable {
        max-height: 480px; /* BUG-135: Increased from 400px */
    }
}

/* ============================================
   🎨 AIRBNB-STYLE SIDEBAR CALENDAR OVERLAY
   Positions modal to overlay booking card inputs
   ============================================ */

/* Sidebar context positioning - overlay the booking card */
#transportationCalendarModal[data-context="sidebar"][data-inline="true"] {
    position: absolute;
    top: var(--sidebar-calendar-top, 50%) !important;
    left: var(--sidebar-calendar-left, 50%) !important;
    transform: none !important;
    margin: 0 !important;
    z-index: 9999;
}

#transportationCalendarModal[data-context="sidebar"] .modal-container {
    max-width: 660px;
    width: 660px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.28);
    border-radius: 12px;
    overflow: hidden;
}

/* Sidebar Header - Two column layout: Title on left, inputs on right */
.sidebar-calendar-header {
    display: grid;
    grid-template-columns: 1fr 322px;  /* Fixed width for inputs column */
    gap: 24px;
    padding: 24px;
    background: white;
    border-radius: 12px 12px 0 0;
    align-items: center;
    overflow: hidden;
}

.sidebar-header-top {
    position: relative;
    padding-right: 40px;
}

.sidebar-header-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 999px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #222222;
    padding: 0;
    cursor: pointer;
}

.sidebar-header-close:hover {
    background: #F7F7F7;
}

.sidebar-header-close svg {
    width: 18px;
    height: 18px;
}

.sidebar-header-title {
    font-size: 22px;
    font-weight: 600;
    color: #222;
    margin-bottom: 4px;
}

.sidebar-header-subtitle {
    font-size: 14px;
    color: #717171;
}

.sidebar-header-inputs {
    /* Right column - CHECK-IN/CHECKOUT grid */
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 1px solid #B0B0B0;
    border-radius: 8px;
    overflow: hidden;
    width: 322px;  /* Match sidebar width */
}

.sidebar-input-box {
    padding: 12px;
    background: white;
    cursor: pointer;
    transition: background 0.2s;
}

.sidebar-input-box:first-child {
    border-right: 1px solid #B0B0B0;
}

.sidebar-input-box:hover {
    background: #F7F7F7;
}

.sidebar-input-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #222;
    margin-bottom: 4px;
}

.sidebar-input-value {
    font-size: 14px;
    color: #717171;
}

.sidebar-input-value:not(:empty) {
    color: #222;
    font-weight: 500;
}

/* Single-letter day headers for sidebar context */
#transportationCalendarModal[data-context="sidebar"] .calendar-day.header {
    font-size: 12px;
    font-weight: 500;
    color: #717171;
}

/* Sidebar Footer Layout - Keyboard icon + Clear + Close */
#transportationCalendarModal[data-context="sidebar"] .modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid #EBEBEB;
}

.footer-left-controls,
.footer-right-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.keyboard-icon-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #222;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.keyboard-icon-btn:hover {
    background: #F7F7F7;
}

.keyboard-icon-btn svg {
    width: 20px;
    height: 20px;
}

#transportationCalendarModal[data-context="sidebar"] .clear-btn {
    background: none;
    border: none;
    color: #222;
    font-size: 14px;
    font-weight: 500;
    text-decoration: underline;
    padding: 8px 12px;
    cursor: pointer;
}

#transportationCalendarModal[data-context="sidebar"] .clear-btn:hover {
    background: #F7F7F7;
    border-radius: 4px;
}

#transportationCalendarModal[data-context="sidebar"] .apply-btn {
    background: #222;
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#transportationCalendarModal[data-context="sidebar"] .apply-btn:hover {
    background: #000;
}

/* Hide default modal header when in sidebar context */
#transportationCalendarModal[data-context="sidebar"] .modal-header {
    display: none;
}

/* Adjust content area to account for sidebar header */
#transportationCalendarModal[data-context="sidebar"] .transportation-calendar-content {
    padding-top: 0;
}
