/**
 * Master Availability Calendar Styles
 * Only loaded on the /availability/ page (page ID 662)
 *
 * Sections:
 *   1. Calendar container & header
 *   2. Legend
 *   3. Controls (view toggle, filter toggle)
 *   4. Filter panel (collapsible)
 *   5. Category headers
 *   6. Scrollable table container (shared scroll)
 *   7. Table base styles
 *   8. Name column with inline icons
 *   9. Status cells
 *  10. Checkbox styles (hidden until filter mode)
 *  11. Column/row hiding
 *  12. By Week view
 *  13. Footer
 *  14. Responsive
 */

/* ── 1. Calendar container ─────────────────────────────────────────── */
.bhacr-master-cal {
    font-family: Arial, Helvetica, sans-serif;
    max-width: 100%;
    margin: 0 auto;
}

/* ── Season header ─────────────────────────────────────────────────── */
.bhacr-cal-header h2 {
    font-size: 22px;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.bhacr-cal-header p {
    font-size: 13px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 12px;
}

/* ── 2. Legend ──────────────────────────────────────────────────────── */
.bhacr-cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 12px;
    font-size: 13px;
}

.cal-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.cal-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 1px solid #bbb;
    border-radius: 2px;
}

.cal-swatch.cal-open     { background: #c6efce; }
.cal-swatch.cal-discount { background: #c6efce; border-color: #c0392b; }
.cal-swatch.cal-booked   { background: #f4cccc; }
.cal-swatch.cal-unavail  { background: #e2e3e5; }
.cal-swatch.cal-ask      { background: #cfe2f3; }
.cal-swatch.cal-partial  { background: #ffe0b2; }
.cal-swatch.cal-pending  { background: #fff2cc; }

/* ── 3. Controls (view toggle + filter toggle) ─────────────────────── */
.bhacr-cal-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.bhacr-view-toggle {
    display: inline-flex;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
}

.bhacr-view-btn {
    padding: 6px 14px;
    font-size: 13px;
    border: none;
    background: #f5f5f5;
    color: #333;
    cursor: pointer;
    transition: background 0.15s;
}

.bhacr-view-btn:not(:last-child) {
    border-right: 1px solid #ccc;
}

.bhacr-view-btn.active {
    background: var(--bhacr-purple, #3300CC);
    color: #fff;
}

.bhacr-view-btn:hover:not(.active) {
    background: #e0e0e0;
}

.bhacr-filter-toggle {
    padding: 6px 14px;
    font-size: 13px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f5f5f5;
    color: #333;
    cursor: pointer;
    transition: background 0.15s;
}

.bhacr-filter-toggle:hover {
    background: #e0e0e0;
}

/* ── 4. Filter panel (collapsible) ─────────────────────────────────── */
.bhacr-filter-panel {
    background: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px 14px;
    margin-bottom: 10px;
}

.bhacr-quick-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 8px;
}

.bhacr-toggle {
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.bhacr-filter-label {
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.bhacr-filter-label select {
    font-size: 12px;
    padding: 2px 4px;
    border: 1px solid #ccc;
    border-radius: 3px;
}

.bhacr-cat-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.bhacr-cat-label {
    font-size: 13px;
    color: #555;
    margin-right: 4px;
}

.bhacr-cat-pill {
    padding: 3px 10px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 12px;
    background: #e8e8e8;
    color: #666;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.bhacr-cat-pill.active {
    background: #00ccff;
    color: #000;
    border-color: #00b8e6;
}

.bhacr-cat-pill:hover {
    opacity: 0.85;
}

.bhacr-filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.bhacr-btn-filter {
    padding: 5px 14px;
    font-size: 13px;
    border: none;
    border-radius: 4px;
    background: var(--bhacr-purple, #3300CC);
    color: #fff;
    cursor: pointer;
}

.bhacr-btn-filter:hover {
    opacity: 0.9;
}

.bhacr-btn-reset {
    padding: 5px 14px;
    font-size: 13px;
    border: 1px solid #999;
    border-radius: 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
}

.bhacr-btn-reset:hover {
    background: #f0f0f0;
}

#cal-filter-count {
    font-size: 12px;
    color: #666;
}

.bhacr-filter-hint {
    font-size: 12px;
    color: #888;
    margin: 0;
}

/* ── 4b. Active filter summary bar ──────────────────────────────────── */
.bhacr-filter-summary {
    background: #eef;
    border: 1px solid #ccd;
    border-radius: 4px;
    padding: 6px 12px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #333;
    line-height: 1.6;
}

.bhacr-filter-summary strong {
    color: var(--bhacr-purple, #3300CC);
}

.filter-summary-section {
    display: inline;
}

.filter-summary-section + .filter-summary-section::before {
    content: "  |  ";
    color: #999;
}

/* ── 5. Category headers — outside scroll container, always visible ─── */
.bhacr-cal-cat-header {
    background: #00ccff;
    color: #000;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    padding: 6px 10px;
    margin: 20px 0 0 0;
    border-radius: 3px 3px 0 0;
    box-sizing: border-box;
}

.bhacr-cal-category:first-of-type .bhacr-cal-cat-header {
    margin-top: 0;
}

/* ── 6. Scrollable table container (shared) ────────────────────────── */
.bhacr-cal-scroll-wrap {
    position: relative;
}

.bhacr-cal-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #ccc;
    margin-bottom: 5px;
}

.bhacr-scroll-hint {
    text-align: center;
    font-size: 12px;
    color: #888;
    margin: 4px 0 10px;
}

/* Scroll indicator arrows — centred vertically on the visible table area */
.bhacr-scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    width: 44px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #fff;
    background: rgba(51, 0, 204, 0.88);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    user-select: none;
    box-shadow: 0 3px 12px rgba(0,0,0,0.35);
}

.bhacr-scroll-arrow:hover {
    background: rgba(51, 0, 204, 1);
    transform: translateY(-50%) scale(1.08);
}

.bhacr-scroll-left {
    left: 230px; /* start after the sticky name column so it doesn't overlap */
}

.bhacr-scroll-right {
    right: 0;
}

/* Pulse animation on first load to draw attention */
@keyframes arrow-pulse {
    0%, 100% { box-shadow: 0 3px 12px rgba(0,0,0,0.35); }
    50%       { box-shadow: 0 0 0 6px rgba(51,0,204,0.25), 0 3px 12px rgba(0,0,0,0.35); }
}

.bhacr-scroll-arrow.pulse {
    animation: arrow-pulse 1.2s ease-in-out 4;
}

/* Fit-to-screen mode: scale tables to viewport width */
.bhacr-cal-scroll.fit-to-screen {
    overflow-x: hidden;
}

.bhacr-cal-scroll.fit-to-screen .bhacr-cal-table {
    min-width: 0;
    width: 100%;
    font-size: 8px;
}

.bhacr-cal-scroll.fit-to-screen .cal-name-cell,
.bhacr-cal-scroll.fit-to-screen .cal-name-col {
    min-width: 0;
    max-width: none;
    font-size: 9px;
    padding: 2px 3px !important;
    position: static; /* disable sticky in fit mode */
}

.bhacr-cal-scroll.fit-to-screen .cal-status-cell {
    min-width: 0;
    padding: 1px 2px;
    font-size: 7px;
}

.bhacr-cal-scroll.fit-to-screen .cal-week-col {
    font-size: 8px;
    padding: 2px;
}

.bhacr-cal-scroll.fit-to-screen .cal-icons {
    display: none; /* hide icons in fit mode to save space */
}

.bhacr-cal-scroll.fit-to-screen .bhacr-cal-cat-header {
    font-size: 12px;
    position: static; /* no sticky needed when everything fits */
}

/* ── 7. Table ──────────────────────────────────────────────────────── */
.bhacr-cal-table {
    border-collapse: collapse;
    min-width: 1500px;
    width: 100%;
    font-size: 11px;
}

.bhacr-cal-table th,
.bhacr-cal-table td {
    border: 1px solid #ccc;
    padding: 1px 4px;
    text-align: center;
    vertical-align: middle;
    line-height: 1.2;
}

/* Column header row (week dates) */
.bhacr-cal-table thead th {
    background: #ffff99;
    font-size: 11px;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
}

/* ── 8. Name column with inline icons ──────────────────────────────── */
.cal-name-col,
.cal-name-cell {
    text-align: left !important;
    white-space: nowrap;
    font-size: 13px;
    padding: 1px 8px !important;
    min-width: 230px;
    max-width: 280px;
    background: #fff;
    position: sticky;
    left: 0;
    z-index: 10;
    border-right: 2px solid #999 !important;
    /* Shadow on right edge makes frozen column obvious */
    box-shadow: 3px 0 6px -2px rgba(0,0,0,0.18);
}

.cal-name-cell {
    /* No display:flex — it breaks position:sticky on <td> in table layout */
    white-space: nowrap;
    overflow: hidden;
}

/* Even rows: sticky cell must explicitly carry the stripe colour */
.bhacr-cal-table tbody tr:nth-child(even) .cal-name-cell {
    background: #f2f2ff; /* faint lavender stripe, distinct from week cells */
}

/* Odd rows stay white */
.bhacr-cal-table tbody tr:nth-child(odd) .cal-name-cell {
    background: #fff;
}

.cal-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline;
}

.cal-name-col {
    z-index: 15; /* above both sticky col and sticky header */
    background: #ffff99;
    font-weight: bold;
}

.cal-name-cell a {
    color: var(--bhacr-purple, #3300CC);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cal-name-cell a:hover {
    color: var(--bhacr-magenta, #FF33FF);
    text-decoration: underline;
}

/* Sunday-to-Sunday label shown below cottage name */
.cal-sun-label {
    display: block;
    font-size: 10px;
    font-style: italic;
    color: #666;
    font-weight: normal;
    line-height: 1.2;
    margin-top: 1px;
}

/* Inline icons (bed + capacity, paw) — right-justified after name */
.cal-icons {
    font-size: 12px;
    white-space: nowrap;
    float: right;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 6px;
}

.cal-icon-bed {
    font-size: 15px;
    color: #333;
    font-weight: bold;
}

.cal-icon-paw {
    font-size: 14px;
}

/* Alternate row striping for status cells (name cell handled above) */

/* ── 9. Status cells ───────────────────────────────────────────────── */
.cal-status-cell {
    min-width: 42px;
    font-size: 11px;
}

.cal-open {
    background: #c6efce;
    color: #155724;
    font-weight: bold;
}

/* Discounted: open at a reduced rate — green-ish bg, red label (#187) */
.cal-discount {
    background: #c6efce;
    color: #c0392b;
    font-weight: bold;
    font-size: 0.82em;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cal-booked {
    background: #f4cccc;
    color: #721c24;
}

.cal-unavail {
    background: #e2e3e5;
    color: #999;
}

.cal-ask {
    background: #cfe2f3;
    color: #004085;
}

/* Partial: some nights booked within the week — ask for open dates (#269) */
.cal-partial {
    background: #ffe0b2;
    color: #b35900;
    font-weight: bold;
    font-size: 0.82em;
}

.cal-pending {
    background: #fff2cc;
    color: #856404;
}

/* ── 10. Checkbox styles (hidden until filter panel open) ──────────── */
.cal-week-check {
    width: 13px;
    height: 13px;
    display: block;
    margin: 0 auto 1px;
    cursor: pointer;
}

.cal-cottage-check {
    width: 14px;
    height: 14px;
    margin-right: 4px;
    vertical-align: middle;
    cursor: pointer;
}

/* ── 11. Column/Row hiding ─────────────────────────────────────────── */
.cal-col-hidden {
    display: none !important;
}

/* Filtered-to-selected-weeks state (#252): collapse the grid to fit the
   visible columns (drop the 1500px min-width + 100% width that otherwise
   strand the lone week column at the far right) and hide the scroll arrows. */
#bhacr-grid-view.weeks-filtered .bhacr-cal-table {
    min-width: 0;
    width: auto;
}
#bhacr-grid-view.weeks-filtered .bhacr-scroll-arrow {
    display: none !important;
}

.cal-row-hidden {
    display: none !important;
}

/* ── 12. By Week view ──────────────────────────────────────────────── */
#bhacr-byweek-view {
    /* container */
}

.byweek-week-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-bottom: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.byweek-week-pill {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 14px;
    background: #f5f5f5;
    color: #333;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.byweek-week-pill.active {
    background: var(--bhacr-purple, #3300CC);
    color: #fff;
    border-color: var(--bhacr-purple, #3300CC);
}

.byweek-week-pill:hover:not(.active) {
    background: #e0e0e0;
}

.byweek-category {
    margin-bottom: 15px;
}

.byweek-cat-header {
    background: #00ccff;
    color: #000;
    font-size: 15px;
    font-weight: bold;
    text-align: center;
    padding: 5px 10px;
    border-radius: 3px 3px 0 0;
    margin: 0;
}

/* Available-only toggle button */
.byweek-avail-toggle {
    margin: 6px 0 4px;
}

.byweek-toggle-btn {
    font-size: 11px;
    padding: 3px 12px;
    border-radius: 10px;
    border: 1px solid #aaa;
    background: #f5f5f5;
    color: #555;
    cursor: pointer;
}

.byweek-toggle-btn.avail-only {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
    font-weight: bold;
}

.byweek-toggle-btn:hover {
    background: #e0e0e0;
}

.byweek-card {
    border: 1px solid #ddd;
    border-top: none;
    padding: 4px 10px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: nowrap;
}

.byweek-card:last-child {
    border-radius: 0 0 3px 3px;
}

.byweek-card:nth-child(even) {
    background: #f9f9f9;
}

.byweek-card-name {
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    width: 260px;       /* fixed width — aligns all status badges in a column */
    min-width: 260px;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.byweek-card-name a {
    color: var(--bhacr-purple, #3300CC);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.byweek-card-name a:hover {
    color: var(--bhacr-magenta, #FF33FF);
    text-decoration: underline;
}

.byweek-card-info {
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    margin-left: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Sat = dark blue, white text */
.byweek-card-info.day-sat {
    background: #1a237e;
    color: #fff;
}

/* Sun = light blue, dark text */
.byweek-card-info.day-sun {
    background: #b3e5fc;
    color: #0d47a1;
}

.byweek-card-weeks {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
}

.byweek-status-badge {
    display: inline-block;
    padding: 2px 0;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    width: 120px;           /* fixed width so all week badges align in columns */
    text-align: center;
    box-sizing: border-box;
}

/* Each week badge + its optional "Submit inquiry" link stay grouped together (#254) */
.byweek-week-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.byweek-inquire-link {
    font-size: 11px;
    font-weight: bold;
    color: var(--bhacr-purple, #3300CC);
    text-decoration: none;
    white-space: nowrap;
}

.byweek-inquire-link:hover {
    color: var(--bhacr-magenta, #FF33FF);
    text-decoration: underline;
}

.badge-open {
    background: #c6efce;
    color: #155724;
}

.badge-discount {
    background: #c6efce;
    color: #c0392b;
    text-transform: uppercase;
    font-weight: bold;
}

.badge-booked {
    background: #f4cccc;
    color: #721c24;
}

.badge-unavail {
    background: #e2e3e5;
    color: #999;
}

.badge-ask {
    background: #cfe2f3;
    color: #004085;
}

.badge-partial {
    background: #ffe0b2;
    color: #b35900;
}

.badge-pending {
    background: #fff2cc;
    color: #856404;
}

.byweek-empty {
    font-size: 14px;
    color: #666;
    text-align: center;
    padding: 20px;
}

/* ── 13. Footer ────────────────────────────────────────────────────── */
.bhacr-cal-footer {
    margin-top: 20px;
    font-size: 14px;
}

.bhacr-cal-footer a {
    color: var(--bhacr-purple, #3300CC);
    font-weight: bold;
}

.bhacr-cal-footer a:hover {
    color: var(--bhacr-magenta, #FF33FF);
}

.bhacr-cal-updated {
    font-size: 12px;
    color: #888;
    margin-top: 5px;
}

/* ── 14. Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .bhacr-cal-header h2 {
        font-size: 18px;
    }

    .bhacr-cal-header p {
        font-size: 12px;
    }

    .bhacr-cal-legend {
        gap: 10px;
        font-size: 12px;
    }

    .bhacr-cal-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .bhacr-quick-filters {
        flex-wrap: wrap;
    }

    .bhacr-cal-cat-header {
        font-size: 14px;
        padding: 5px 8px;
    }

    .cal-name-cell {
        font-size: 12px;
        min-width: 160px;
        max-width: 200px;
    }

    .byweek-card {
        flex-wrap: wrap;
    }

    .byweek-card-name {
        min-width: 140px;
    }

    .byweek-week-picker {
        gap: 3px;
    }

    .byweek-week-pill {
        padding: 3px 7px;
        font-size: 11px;
    }
}
