/**
 * ==============================================
 * CALENDAR COMPONENT - Reusable across site
 * ==============================================
 * 
 * Usage: Include this file in pages that need calendar functionality
 * Dependencies: Requires CSS variables from styles.css
 * 
 * Components:
 * - Calendar Modal (full-screen overlay)
 * - Month Calendars (grid of monthly views)
 * - Day States (available, booked, selected, etc.)
 * - Booking Summary Panel
 * - Guest Form
 * - Dark Mode Support
 */

/* ==============================================
   CALENDAR MODAL
   ============================================== */

.calendar-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    overflow: hidden;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.calendar-modal.active,
.calendar-modal.visible {
    display: flex;
}

.calendar-modal-content {
    background: var(--bg-elevated);
    border-radius: 16px;
    width: 95%;
    max-width: 1400px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.calendar-modal-header {
    background: var(--bg-elevated);
    border-bottom: 2px solid var(--border-color);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calendar-modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-dark);
    margin: 0;
}

.calendar-modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-light);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.calendar-modal-close:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

.calendar-modal-body {
    padding: 30px;
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 380px);
    gap: 28px;
    height: 100%;
    overflow: hidden;
}

.calendar-date-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    padding: 40px 20px;
}

.calendar-instructions {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-xs);
}

.calendar-instructions-title {
    margin: 0 0 12px;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.calendar-instructions-title i {
    color: #dd7447;
}

.calendar-instructions-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.calendar-instructions-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.calendar-instructions-list i {
    color: #0f509b;
    font-size: 0.9rem;
}

.calendar-date-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.calendar-date-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.calendar-date-box i {
    font-size: 1.1rem;
    color: #dd7447;
}

.calendar-date-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.calendar-date-label {
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-light);
    font-weight: 600;
}

.calendar-date-box:hover,
.calendar-date-box:focus-visible {
    border-color: #dd7447;
    box-shadow: 0 10px 25px rgba(221, 116, 71, 0.15);
    transform: translateY(-1px);
}

.calendar-date-box:focus-visible {
    outline: 3px solid rgba(221, 116, 71, 0.35);
    outline-offset: 2px;
}

.calendar-date-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    text-align: left;
}

.calendar-date-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    font-weight: 600;
}

.calendar-date-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.calendar-date-value .placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.calendar-date-value .placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.calendar-date-help {
    font-size: 0.9rem;
    color: var(--text-light);
    margin: 0;
}

.booking-summary-placeholder {
    color: var(--text-light);
    text-align: center;
    padding: 40px 20px;
}

.calendar-months-container {
    overflow-y: auto;
    padding-right: 10px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}

#booking-summary-container {
    overflow: visible;
    max-height: none;
}

#booking-summary {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ==============================================
   MONTH CALENDAR
   ============================================== */

.month-calendar {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
}

.month-header {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 16px 12px 12px;
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    background: none;
    padding: 4px;
}

.day-header {
    background: none;
    padding: 10px 4px;
    text-align: center;
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==============================================
   CALENDAR DAY STATES
   ============================================== */

.calendar-day {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 8px 4px;
    text-align: center;
    font-size: 0.9rem;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: none;
    border-radius: 8px;
    margin: 2px;
    transition: all 0.2s ease;
}

.calendar-day.other-month {
    color: var(--text-tertiary);
    opacity: 0.5;
}

.calendar-day.today {
    background: #dbeafe;
    font-weight: 700;
    color: #0f509b;
}

.calendar-day.booked {
    background: #fee2e2;
    color: #991b1b;
    font-weight: 600;
}

.calendar-day.available {
    background: #d1fae5;
    color: #065f46;
    cursor: pointer;
}

.calendar-day.available:hover {
    background: #a7f3d0;
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

.calendar-day.selected-checkin,
.calendar-day.selected-checkout {
    background: #dd7447;
    color: white;
    font-weight: 700;
    position: relative;
}

/* Rounded capsule effect */
.calendar-day.selected-checkin {
    border-radius: 8px 0 0 8px !important;
}

.calendar-day.selected-checkout {
    border-radius: 0 8px 8px 0 !important;
}

.calendar-day.in-range {
    background: #fed7aa;
    color: #9a3412;
    border-radius: 0 !important;
}

/* Hover preview range */
.calendar-day.preview-range {
    background: #ffedd5 !important;
    color: #c2410c;
    border-radius: 0 !important;
}

.calendar-day.preview-checkout {
    background: #fb923c !important;
    color: white;
    border-radius: 0 8px 8px 0 !important;
}

.calendar-day.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.calendar-day.past {
    background: #f3f4f6;
    color: #9ca3af;
}

/* ==============================================
   CALENDAR LEGEND
   ============================================== */

.calendar-legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    padding: 20px;
    background: var(--bg-light);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* ==============================================
   BOOKING SUMMARY PANEL
   ============================================== */

 .booking-summary-panel {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

.booking-summary-panel::-webkit-scrollbar {
    width: 8px;
}

.booking-summary-panel::-webkit-scrollbar-thumb {
    background: rgba(203, 213, 225, 0.75);
    border-radius: 999px;
}

.booking-summary-panel::-webkit-scrollbar-track {
    background: transparent;
}

.summary-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.summary-card h4 {
    margin: 0 0 12px;
    font-size: 1.05rem;
    color: var(--text-dark);
}

.summary-dates {
    background: rgba(226, 232, 240, 0.4);
    padding: 14px;
    border-radius: 10px;
    font-size: 0.95rem;
    margin: 0;
    display: grid;
    gap: 6px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.summary-row.summary-row-discount {
    background: rgba(16, 185, 129, 0.08);
    border-left: 3px solid #10b981;
    border-radius: 10px;
    padding: 10px 12px;
    margin-left: 2px;
}

.summary-row.summary-row-discount span:last-child {
    color: #047857;
    font-weight: 600;
}

.summary-discount-meta {
    font-size: 0.8rem;
    color: #047857;
    margin-top: 4px;
    display: block;
}

.summary-price-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.summary-price-original {
    text-decoration: line-through;
    color: var(--text-light);
    font-size: 0.8rem;
}

.summary-price-current {
    font-weight: 600;
    color: var(--text-primary);
}

.summary-price-discount {
    font-weight: 700;
    color: #047857;
}

.summary-price-total {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.05rem;
}

.summary-row-total {
    border-top: 2px solid var(--border-color);
    margin-top: 12px;
    padding-top: 12px;
}

.summary-row-discount span:last-child {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.summary-row-muted {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.summary-row-muted span:last-child {
    color: var(--text-secondary);
    font-weight: 500;
}

.summary-scroll-button {
    align-self: flex-start;
    background: #dd7447;
    color: white;
    border: none;
    border-radius: 999px;
    padding: 9px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(221, 116, 71, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.summary-scroll-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(221, 116, 71, 0.32);
}

.summary-breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.summary-pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.summary-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(226, 232, 240, 0.7);
    border-radius: 999px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.summary-savings-card {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%);
    color: white;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 20px 40px rgba(16, 185, 129, 0.3);
}

.summary-savings-card h4 {
    color: inherit;
    font-size: 1.1rem;
    margin-bottom: 6px;
}

.summary-savings-meta {
    font-size: 0.85rem;
    opacity: 0.9;
}

.calendar-form-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 30px;
    align-self: flex-start;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 40px 10px;
}

.calendar-form-panel::-webkit-scrollbar {
    width: 6px;
}

.calendar-form-panel::-webkit-scrollbar-thumb {
    background: rgba(203, 213, 225, 0.7);
    border-radius: 999px;
}

.summary-reset-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.summary-reset-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.summary-reset-inline {
    margin-top: 12px;
    align-self: flex-start;
}

.summary-form-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.summary-form-card label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.summary-form-card input,
.summary-form-card textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.summary-form-card input:focus,
.summary-form-card textarea:focus {
    border-color: #dd7447;
    box-shadow: 0 0 0 3px rgba(221, 116, 71, 0.2);
    outline: none;
}

.summary-form-card .btn-submit-request {
    background: linear-gradient(135deg, #dd7447 0%, #c85a2f 100%);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 20px 36px rgba(221, 116, 71, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.summary-form-card .btn-submit-request:hover {
    transform: translateY(-1px);
    box-shadow: 0 24px 42px rgba(221, 116, 71, 0.35);
}

.summary-form-note {
    font-size: 0.78rem;
    color: var(--text-light);
    text-align: center;
    margin-top: 6px;
}

.summary-form-highlights {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.summary-form-highlights span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.summary-form-highlights i {
    color: #10b981;
}

.utility-notice {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 12px 15px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid #f59e0b;
}

.utility-notice-content {
    display: flex;
    align-items: start;
    gap: 10px;
}

.utility-notice-icon {
    color: #d97706;
    font-size: 1.1rem;
    margin-top: 2px;
}

.utility-notice-title {
    font-weight: 600;
    color: #92400e;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.utility-notice-text {
    color: #78350f;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* ==============================================
   NOTE: Dark mode styles moved to /css/dark-mode.css
   ============================================== */

/* ==============================================
   RESPONSIVE - MOBILE
   ============================================== */

@media (max-width: 968px) {
    .calendar-grid {
        grid-template-columns: 1fr;
    }

    .calendar-modal {
        align-items: flex-start;
        padding: 24px 0;
        overflow-y: auto;
    }

    .calendar-modal-content {
        width: 94%;
        max-width: 900px;
        margin: 0 auto;
        max-height: none;
    }

    .calendar-modal-body {
        grid-template-columns: 1fr !important;
        overflow-y: visible;
        padding: 24px;
        gap: 20px;
    }

    .calendar-date-panel {
        overflow: visible;
        padding-right: 0;
    }

    .calendar-months-container {
        overflow-y: visible;
        padding-right: 0;
    }

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

    .calendar-form-panel {
        position: static;
        max-height: none;
        padding-right: 0;
        order: 2;
    }

    #booking-summary-container {
        order: 1;
    }

    .booking-summary-panel {
        padding: 20px;
        box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
    }
}

@media (max-width: 600px) {
    .calendar-modal {
        padding: 16px 0;
    }
    
    .calendar-modal-content {
        width: 96%;
        border-radius: 12px;
    }
    
    .calendar-modal-header {
        padding: 16px 18px;
    }
    
    .calendar-modal-body {
        padding: 16px;
        gap: 20px;
    }

    .calendar-date-box {
        padding: 14px 16px;
    }

    .calendar-date-help {
        font-size: 0.85rem;
    }
}

