/**
 * CM Hotel Booking - Availability Calendar Styles
 *
 * Frontend Gantt-style availability view (2 months side by side).
 * Depends on frontend.css for base variables (--cmhb-*).
 *
 * @package CM_Hotel_Booking
 * @version 1.3.0
 */

/* ==========================================================================
   Container & Variables
   ========================================================================== */

.cmhb-availability-calendar {
    --cmhb-avail-free: #e8f5e9;
    --cmhb-avail-free-border: #a5d6a7;
    --cmhb-avail-booked: #fce4ec;
    --cmhb-avail-booked-border: #ef9a9a;
    --cmhb-avail-today: #e3f2fd;
    --cmhb-avail-today-border: #90caf9;
    --cmhb-avail-past: #f5f5f5;
    --cmhb-avail-past-border: #e0e0e0;
    --cmhb-avail-selected: #fff9c4;
    --cmhb-avail-selected-border: #ffd54f;
    --cmhb-avail-weekend: #fafafa;

    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #333;
    line-height: 1.4;
    margin: 0 auto 30px;
}

.cmhb-availability-calendar *,
.cmhb-availability-calendar *::before,
.cmhb-availability-calendar *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.cmhb-avail-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.cmhb-avail-prev,
.cmhb-avail-next {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 16px;
    cursor: pointer;
    color: #333;
    transition: background-color 0.15s, border-color 0.15s;
    line-height: 1;
}

.cmhb-avail-prev:hover,
.cmhb-avail-next:hover {
    background: #f5f5f5;
    border-color: #bbb;
}

.cmhb-avail-prev:disabled,
.cmhb-avail-next:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.cmhb-avail-label {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    min-width: 280px;
    text-align: center;
}

/* ==========================================================================
   Hint Text
   ========================================================================== */

.cmhb-avail-hint {
    text-align: center;
    font-size: 13px;
    color: #888;
    margin: 0 0 12px;
    font-style: italic;
}

/* ==========================================================================
   Grid Wrapper (horizontal scroll on small screens)
   ========================================================================== */

.cmhb-avail-grid-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cmhb-avail-months {
    display: flex;
    gap: 20px;
    min-width: 700px;
}

/* ==========================================================================
   Single Month Grid
   ========================================================================== */

.cmhb-avail-month {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.cmhb-avail-month-title {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    padding: 8px 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    color: #2c3e50;
}

/* Scroll wrapper for the table inside each month */
.cmhb-avail-table-wrap {
    overflow-x: auto;
}

/* ==========================================================================
   Gantt Table
   ========================================================================== */

.cmhb-avail-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 11px;
}

/* Day Header Row */
.cmhb-avail-table thead th {
    padding: 3px 0;
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    border-bottom: 2px solid #ddd;
    border-right: 1px solid #eee;
    background: #f8f9fa;
    color: #333;
    vertical-align: middle;
    line-height: 1.2;
}

.cmhb-avail-table thead th:first-child {
    text-align: left;
    padding-left: 8px;
    font-size: 10px;
    color: #999;
    border-right: 1px solid #ddd;
}

/* Single-room mode: no room column, reset first-child to normal day style */
.cmhb-avail-single thead th:first-child {
    text-align: center;
    padding-left: 0;
    font-size: 11px;
    color: #333;
    border-right: 1px solid #eee;
}

.cmhb-avail-table thead th:last-child {
    border-right: none;
}

.cmhb-avail-day-num {
    display: block;
    font-size: 12px;
}

.cmhb-avail-day-name {
    display: block;
    font-size: 9px;
    color: #999;
    font-weight: 400;
    text-transform: uppercase;
}

.cmhb-avail-th-weekend {
    background: #f5f2ed;
}

.cmhb-avail-th-today {
    background: var(--cmhb-avail-today);
}

.cmhb-avail-th-today .cmhb-avail-day-num {
    color: #1565c0;
}

/* Room Label Cell */
.cmhb-avail-table tbody th {
    text-align: left;
    padding: 6px 8px;
    font-weight: 600;
    font-size: 12px;
    color: #333;
    background: #fafafa;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

/* Day Cells */
.cmhb-avail-table tbody td {
    padding: 0;
    border-right: 1px solid #f0f0f0;
    border-bottom: 1px solid #eee;
    height: 28px;
    text-align: center;
    vertical-align: middle;
    cursor: default;
    transition: background-color 0.1s;
}

.cmhb-avail-table tbody td:last-child {
    border-right: none;
}

/* ==========================================================================
   Cell States
   ========================================================================== */

.cmhb-avail-free {
    background: var(--cmhb-avail-free);
    cursor: pointer;
}

.cmhb-avail-free:hover {
    background: #c8e6c9;
}

.cmhb-avail-booked {
    background: var(--cmhb-avail-booked);
}

.cmhb-avail-today {
    background: var(--cmhb-avail-today);
}

.cmhb-avail-today.cmhb-avail-free:hover {
    background: #bbdefb;
}

.cmhb-avail-past {
    background: var(--cmhb-avail-past);
    cursor: default;
    color: #bbb;
}

/* Weekend: subtle overlay — must NOT override free/booked status colors */
.cmhb-avail-free.cmhb-avail-weekend {
    background: #d7ecd9;
}
.cmhb-avail-booked.cmhb-avail-weekend {
    background: #f8d7df;
}
.cmhb-avail-past.cmhb-avail-weekend {
    background: #efefef;
}

/* Selection highlight (click-to-book) */
.cmhb-avail-selected {
    background: var(--cmhb-avail-selected) !important;
    outline: 2px solid var(--cmhb-avail-selected-border);
    outline-offset: -2px;
    z-index: 1;
    position: relative;
}

.cmhb-avail-range {
    background: #fff8e1 !important;
}

/* Availability count inside cell (only shown when quantity > 1) */
.cmhb-avail-count {
    font-size: 10px;
    font-weight: 600;
    line-height: 28px;
}

.cmhb-avail-free .cmhb-avail-count {
    color: #2e7d32;
}

.cmhb-avail-booked .cmhb-avail-count {
    color: #c62828;
}

/* ==========================================================================
   Classic Calendar Grid (single-room view)
   ========================================================================== */

.cmhb-avail-cal {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.cmhb-avail-cal thead th {
    padding: 8px 4px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    border-bottom: 2px solid #ddd;
    background: #f8f9fa;
}

.cmhb-avail-cal thead th.cmhb-avail-th-weekend {
    background: #f5f2ed;
}

.cmhb-avail-cal tbody td {
    padding: 0;
    text-align: center;
    vertical-align: middle;
    height: 44px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    border: 1px solid #eee;
    cursor: default;
    transition: background-color 0.15s;
}

.cmhb-avail-cal .cmhb-avail-empty {
    background: transparent;
    border-color: transparent;
}

.cmhb-avail-cal .cmhb-avail-past {
    color: #bbb;
}

.cmhb-avail-cal .cmhb-avail-free {
    cursor: pointer;
    font-weight: 600;
}

.cmhb-avail-cal .cmhb-avail-booked {
    color: #999;
    text-decoration: line-through;
}

/* ==========================================================================
   Legend
   ========================================================================== */

.cmhb-avail-legend {
    display: flex;
    gap: 18px;
    margin-top: 12px;
    font-size: 12px;
    color: #666;
    flex-wrap: wrap;
}

.cmhb-avail-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.cmhb-avail-legend-color {
    display: inline-block;
    width: 16px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid #ccc;
}

.cmhb-avail-legend-free {
    background: var(--cmhb-avail-free);
    border-color: var(--cmhb-avail-free-border);
}

.cmhb-avail-legend-booked {
    background: var(--cmhb-avail-booked);
    border-color: var(--cmhb-avail-booked-border);
}

.cmhb-avail-legend-today {
    background: var(--cmhb-avail-today);
    border-color: var(--cmhb-avail-today-border);
}

.cmhb-avail-legend-past {
    background: var(--cmhb-avail-past);
    border-color: var(--cmhb-avail-past-border);
}

/* ==========================================================================
   Booking Bar (shown after date selection)
   ========================================================================== */

.cmhb-avail-booking-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    padding: 12px 20px;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    border-radius: 6px;
    flex-wrap: wrap;
}

.cmhb-avail-booking-info {
    font-size: 14px;
    font-weight: 600;
    color: #2e7d32;
}

.cmhb-avail-booking-btn {
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s;
    line-height: 1.3;
}

.cmhb-avail-booking-btn:hover {
    background: #1b5e20;
}

/* ==========================================================================
   Validation Message (booked days in range)
   ========================================================================== */

.cmhb-avail-message {
    margin-top: 12px;
    padding: 10px 16px;
    background: #fff3e0;
    border: 1px solid #ffcc80;
    border-radius: 6px;
    color: #e65100;
    font-size: 13px;
    text-align: center;
}

/* ==========================================================================
   Loading Overlay
   ========================================================================== */

.cmhb-avail-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 6px;
    transition: opacity 0.2s;
}

.cmhb-avail-loading.cmhb-avail-hidden {
    opacity: 0;
    pointer-events: none;
}

/* ==========================================================================
   Empty / Error State
   ========================================================================== */

.cmhb-avail-empty {
    text-align: center;
    padding: 30px;
    color: #888;
    font-size: 14px;
}

.cmhb-avail-error {
    text-align: center;
    padding: 20px;
    color: #c62828;
    font-size: 14px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media screen and (max-width: 768px) {
    .cmhb-avail-months {
        flex-direction: column;
        gap: 15px;
        min-width: 0;
    }

    .cmhb-avail-month {
        width: 100%;
    }

    .cmhb-avail-label {
        font-size: 15px;
        min-width: auto;
    }

    .cmhb-avail-nav {
        gap: 8px;
    }

    .cmhb-avail-table tbody th {
        max-width: 80px;
        font-size: 11px;
        padding: 4px 5px;
    }

    .cmhb-avail-day-name {
        display: none;
    }

    .cmhb-avail-table thead th {
        font-size: 10px;
    }

    .cmhb-avail-day-num {
        font-size: 10px;
    }

    .cmhb-avail-table tbody td {
        height: 24px;
    }

    .cmhb-avail-count {
        font-size: 9px;
        line-height: 24px;
    }

    .cmhb-avail-legend {
        gap: 10px;
        font-size: 11px;
    }
}

@media screen and (max-width: 768px) {
    .cmhb-avail-cal tbody td {
        height: 36px;
        font-size: 13px;
    }

    .cmhb-avail-cal thead th {
        font-size: 11px;
        padding: 6px 2px;
    }
}

@media screen and (max-width: 480px) {
    .cmhb-avail-cal tbody td {
        height: 32px;
        font-size: 12px;
    }

    .cmhb-avail-prev,
    .cmhb-avail-next {
        padding: 5px 10px;
        font-size: 14px;
    }

    .cmhb-avail-label {
        font-size: 13px;
    }
}
