/* Allow vertical scroll on mobile for home page */
@media (max-width: 575.98px) {
    html, body {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}
/* Hide calendar and show only listings sidebar on mobile */
@media (max-width: 575.98px) {
    .col-md-3.border-end {
        width: 100vw !important;
        min-width: 100vw !important;
        max-width: 100vw !important;
        flex: 0 0 100vw !important;
        margin: 0 !important;
        left: 0 !important;
        right: 0 !important;
    }
    .col-md-9 {
        display: none !important;
    }
}
/* Make stat cards more compact on mobile */
@media (max-width: 575.98px) {
    .stats-mobile-row > .card {
        font-size: 13px !important;
    }
    .stats-mobile-row > .card .card-body {
        padding: 8px 6px !important;
    }
    .stats-mobile-row > .card h6 {
        font-size: 14px !important;
        margin-bottom: 2px !important;
    }
    .stats-mobile-row > .card h4 {
        font-size: 1rem !important;
    }
}
/* On mobile, show stats boxes in a single row */
@media (max-width: 575.98px) {
    .stats-mobile-row {
        flex-wrap: nowrap !important;
        gap: 8px !important;
        width: 100% !important;
        margin: 0 !important;
    }
    .stats-mobile-row > .card {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        margin: 0 !important;
    }
}
/* Center Dashboard button only on mobile navbar */
@media (max-width: 991.98px) {
    .dashboard-mobile-center {
        text-align: center !important;
        width: 100%;
        display: block;
        margin-left: auto;
        margin-right: auto;
    }
}
.booking-block.dim {
    opacity: 0.35;
}
.booking-block.pulse {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.35);
    transition: box-shadow 0.3s ease;
}
/* Sticky bar measurements */
:root {
    --sticky-hscroll-height: 22px; /* height of the fixed bottom scrollbar */
    --sticky-hscroll-gap: 12px;    /* extra breathing space above it */
}
/* Airbnb Multi-Calendar Styles */

/* General Layout */
.airbnb-booking {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
}

.manual-booking {
    background-color: #007bff !important;
    border-color: #007bff !important;
}

.fc-event-title {
    color: white !important;
}

.listing-card {
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
}

/* Sidebar Styles */
.listings-sidebar {
    /* Fill the sidebar column height (acts like 100% height) */
    flex: 1 1 auto;
    min-height: 0; /* allow flex child to shrink within column */
    height: auto;
    /* Vertical scroll inside sidebar to sync with calendar */
    overflow-y: auto;
    /* Allow dropdown menus to overflow horizontally into the calendar area */
    overflow-x: visible;
    background: white;
    position: relative;
    z-index: 100;
    /* Top padding will be set dynamically to match sticky header height */
    padding-top: 0;
}

.col-md-3.border-end {
    background-color: #fafafa;
    /* Let column grow with page content; page handles vertical scroll */
    height: auto;
    padding: 0;
    min-width: 280px;
    max-width: 320px;
    position: relative;
    z-index: 1000; /* keep above calendar area so menus aren't clipped */
    /* Make the sidebar column a flex container so the list can fill remaining height */
    display: flex;
    flex-direction: column;
}

.col-md-9 {
    background-color: white;
    /* Let the right column grow with content; page handles vertical scroll */
    height: auto;
    padding: 0 !important;
    flex: 1 !important;
    max-width: none !important;
    width: calc(100% - 320px) !important;
    /* Flex column so header sits on top and calendar fills remaining height */
    display: flex;
    flex-direction: column;
}

.listing-item {
    background: white;
    height: 50px; /* content height; +1px border = 51px total to match calendar */
    padding: 0 12px; /* no vertical padding to keep height stable */
    border-bottom: 1px solid #e9e9e9;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    /* Ensure dropdown menus are not clipped by each row container */
    overflow: visible;
    min-width: 250px;
}

.listing-item .flex-grow-1 {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.listing-item h6 {
    margin-bottom: 2px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    color: #333;
}

.listing-item .dropdown {
    flex-shrink: 0;
    margin-left: auto;
    position: relative; /* keep positioning for absolute menu */
    /* no z-index here to avoid stacking conflicts across rows */
}

.listing-item .dropdown-menu {
    position: absolute !important;
    right: 0 !important;
    left: auto !important;
    top: 100% !important;
    transform: none !important;
    z-index: 200000 !important; /* above sidebar content */
    background-color: white !important;
    border: 1px solid #ddd !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4) !important;
    border-radius: 6px !important;
    min-width: 160px !important;
    margin-top: 2px !important;
    padding: 8px 0 !important;
    list-style: none !important;
}

/* Flip menu upward when there isn't enough space below */
.listing-item .dropdown-menu.dropup {
    top: auto !important;
    bottom: 100% !important;
    margin-top: 0 !important;
    margin-bottom: 2px !important;
}

.listing-item .dropdown-menu[style*="display: block"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.listing-item .dropdown-menu .dropdown-item {
    display: block !important;
    width: 100% !important;
    padding: 8px 16px !important;
    color: #333 !important;
    text-decoration: none !important;
    background: transparent !important;
    border: none !important;
    text-align: left !important;
    cursor: pointer !important;
    line-height: 1.4 !important;
}

.listing-item .dropdown-menu .dropdown-item:hover {
    background-color: #f8f9fa !important;
    color: #495057 !important;
}

.listing-item .dropdown .btn {
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    border-radius: 4px;
    color: #666;
    transition: all 0.2s;
}

.listing-item .dropdown .btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #495057;
}

.listing-item:hover {
    background-color: #f8f9fa;
    border-left: 3px solid #007bff;
    padding-left: 9px;
}

.listing-item:last-child {
    border-bottom: none;
}

.listing-image {
    position: relative;
    margin-right: 10px;
    flex-shrink: 0;
}

.listing-image .listing-thumb {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    object-fit: cover;
    display: block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.placeholder-img {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 1; /* Ensure the custom thumb bar is on top */
    font-size: 13px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.status-indicator.online {
    background-color: #28a745;
}

.status-indicator.offline {
    background-color: #ffc107;
}

/* Calendar Container Styles */
.calendar-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    margin-top: 10px;
}

/* Excel-like calendar table structure - Single container scroll */
/* Remove all margins and padding from body and html */
html, body {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
}

@media (max-width: 575.98px) {
    html, body {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

* {
    box-sizing: border-box !important;
}

/* Calendar header with month navigation */
.col-md-9 .p-3 {
    /* Add a small top gap for the header while keeping sides/bottom tight */
    padding: 8px 0 0 0 !important;
    margin: 0 !important;
    width: 100%;
    box-sizing: border-box;
    /* Fill the column and host header + calendar as a vertical flex stack */
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
}

.calendar-table-body {
    flex: 1 1 auto;
    overflow-x: auto;
    /* Vertical scroll inside the calendar; header sticks within */
    overflow-y: auto;
    position: relative;
    z-index: 1;
    min-height: 0;
}

.calendar-table {
    display: block;
    height: 100%;
}

/* Scrollable body - single horizontal scroll for all content */
.calendar-table-body {
    flex: 1 1 auto;
    overflow-x: auto;
    overflow-y: auto;
    min-height: 0;
}

/* Custom scrollbar styles */
.calendar-table-body::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.calendar-table-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.calendar-table-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.calendar-table-body::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Inner table replaces old .calendar-content */
table.calendar-table-inner {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    width: max-content; /* expand to fit columns */
}
table.calendar-table-inner thead th,
table.calendar-table-inner tbody td {
    min-width: 45px;
    width: 45px;
}
/* Sticky header inside the scroll container */
table.calendar-table-inner thead th.date-cell {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 5;
    height: 50px; /* ensure header height matches sidebar padding-top */
}
/* Reapply visual styles to th/td cells */
table.calendar-table-inner thead th.date-cell {
    height: 50px;
    padding: 6px 3px 4px 3px;
    text-align: center;
    border-right: 1px solid #888;
    border-bottom: 1px solid #d0d0d0;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    background-color: #f8f9fa;
    box-sizing: border-box;
}
table.calendar-table-inner tbody td.booking-cell {
    height: 50px;
    border-right: 1px solid #888;
    border-bottom: 1px solid #d0d0d0;
    position: relative;
    background-color: #fff;
    box-sizing: border-box;
}
/* Center booking-block inside cell */
table.calendar-table-inner tbody td.booking-cell .booking-block {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}
/* Left/right borders */
table.calendar-table-inner thead th.date-cell:first-child,
table.calendar-table-inner tbody td.booking-cell:first-child {
    border-left: 1px solid #888;
}
table.calendar-table-inner thead th.date-cell:last-child,
table.calendar-table-inner tbody td.booking-cell:last-child {
    border-right: 1px solid #888;
}

/* Old flex header styles removed in favor of table header */

/* Sunday header styling: black background with white text */
table.calendar-table-inner thead th.date-cell.sunday {
    background-color: #000 !important;
}
table.calendar-table-inner thead th.date-cell.sunday * {
    color: #fff !important;
}

/* Today column highlight */
table.calendar-table-inner thead th.date-cell.today,
table.calendar-table-inner tbody td.booking-cell.today {
    background-color: #fff8e1; /* subtle amber tint */
}
table.calendar-table-inner thead th.date-cell.today::before,
table.calendar-table-inner tbody td.booking-cell.today::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #dc3545; /* red guide line */
    z-index: 3;
}

.listing-row {
    display: flex;
    border-bottom: 1px solid #d0d0d0;
    min-height: 50px;
}

.listing-row:last-child {
    border-bottom: 1px solid #d0d0d0;
}

.calendar-row {
    display: flex;
    min-height: 50px;
    align-items: center;
    width: 100%;
}

.booking-cell {
    min-width: 45px;
    width: 45px;
    height: 50px;
    border-right: 1px solid #888;
    border-bottom: 1px solid #d0d0d0;
    position: relative;
    /* no flex on table cell to avoid layout quirks */
    background-color: #fff;
    box-sizing: border-box;
}

/* Disabled date cells: gray background with a centered cross */
.booking-cell.disabled {
    background-color: #f3f3f3;
    cursor: not-allowed;
}
.booking-cell.disabled::after {
    content: '\2715'; /* heavy multiplication X */
    position: absolute;
    color: #c0392b;
    font-size: 18px;
    line-height: 1;
    opacity: 0.7;
    z-index: 5; /* above booking blocks */
    pointer-events: none;
    /* center the X */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.booking-cell.disabled .booking-block {
    opacity: 0.2;
    filter: grayscale(80%);
    pointer-events: none;
    z-index: 1; /* keep below the cross */
}

/* Read-only (past) cells: allow interaction for editing */
.booking-cell.readonly {
    background-color: #fafafa;
    cursor: pointer;
}
.booking-cell.readonly .booking-block {
    opacity: 0.5;
    filter: grayscale(40%);
    /* keep pointer events so hover tooltips still work */
}

/* Optional: tint header on disabled dates */
table.calendar-table-inner thead th.date-cell.disabled {
    background-color: #eee !important;
    color: #999 !important;
}

/* Header style for read-only days */
table.calendar-table-inner thead th.date-cell.readonly {
    background-color: #f6f6f6 !important;
    color: #aaa !important;
}

/* handled by table cell rules */

.booking-block {
    background-color: #007bff;
    color: white;
    font-size: 10px;
    text-align: center;
    line-height: 1.2;
    width: calc(100% + 2px);
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    cursor: pointer;
    font-weight: 500;
    margin: 0 -1px;
    border: none;
    position: relative;
    z-index: 2;
}
.booking-block .bb-label-left,
.booking-block .bb-label-right {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    padding: 0 6px;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.booking-block .bb-label-left { left: 6px; }
.booking-block .bb-label-right { right: 6px; }

.booking-block.airbnb {
    background-color: #28a745;
}

.booking-block.manual {
    background-color: #007bff;
}

/* Half-day indicator on checkout date: shows left-half of the cell, non-interactive */
.booking-half {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: -1%;
    width: 52%;
    height: 28px;
    border-radius: 0 20px 20px 0; /* rounded to match booking block radius */
    opacity: 1.0;
    pointer-events: none; /* don't block interactions for new check-in */
    z-index: 1; /* below full booking blocks (which use z-index:2) */
}
.booking-half.airbnb { background-color: #28a745; }
.booking-half.manual { background-color: #007bff; }

/* Booking bar styles for continuous appearance */
.booking-block.booking-start {
    /* Show only the right half on check-in day, rounded on the LEFT side */
    left: 50% !important;
    right: auto !important;
    width: 50% !important;
    margin: 0 !important;
    border-radius: 20px 0 0 20px !important;
}

.booking-block.booking-end {
    margin-right: 0;
}

.booking-block.booking-single {
    /* Single-night stay: extend slightly beyond 50% to overlap with checkout half-bar and eliminate line */
    left: 49% !important;
    right: auto !important;
    width: 52% !important;
    margin: 0 !important;
    border-radius: 20px 0 0 20px !important;
}

.booking-block.booking-middle {
    border-radius: 0;
    margin: 0 -1px;
}

/* Past booking (fully ended): keep clickable for editing */
.booking-block.past {
    cursor: pointer;
}

/* Drag selection highlight */
.booking-cell.range-selected {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
    background-color: #e7f1ff;
}

/* Manual Booking modal: make mode switch buttons equal width (50/50) */
#manualBookingModal .btn-group[aria-label="Mode switch"] {
    display: flex;
    width: 100%;
}
#manualBookingModal .btn-group[aria-label="Mode switch"] .btn {
    flex: 1 1 50%;
}

/* Hide native scrollbar visuals inside the calendar scroller (scroll still works) */
.calendar-table-body {
    -ms-overflow-style: none; /* IE/Edge Legacy */
    scrollbar-width: none;    /* Firefox */
}
.calendar-table-body::-webkit-scrollbar {
    width: 0 !important;      /* hide vertical bar in WebKit */
    height: 0 !important;     /* hide horizontal bar in WebKit */
}

/* Sidebar listings alignment with booking rows */
.listings-sidebar::-webkit-scrollbar {
    width: 8px;
}

.listings-sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.listings-sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.listings-sidebar::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Excel Grid - Single line borders between columns */
#main-calendar-header .date-cell,
[id^="timeline-"] .booking-cell {
    border-right: 1px solid #c0c0c0 !important;
}

#main-calendar-header .date-cell:first-child,
[id^="timeline-"] .booking-cell:first-child {
    border-left: 1px solid #c0c0c0 !important;
}

/* Pretty hover popover for booking details */
.booking-popover {
    background: #111;
    color: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.35);
    min-width: 220px;
    max-width: 360px;
    pointer-events: none;
}
.booking-popover .bp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.booking-popover .bp-title {
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 75%;
}
.booking-popover .bp-price {
    font-weight: 700;
    color: #5ee3a4;
    font-size: 13px;
}
.booking-popover .bp-sub {
    font-size: 12px;
    color: #cfcfcf;
    margin-bottom: 8px;
}
.booking-popover .bp-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.booking-popover .bp-badge {
    background: #1b1b1b;
    border: 1px solid #2a2a2a;
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 999px;
}
.booking-popover .bp-badge.bp-airbnb { color: #a7f3d0; border-color: #134e4a; background: #0f2f2a; }
.booking-popover .bp-badge.bp-manual { color: #93c5fd; border-color: #1e3a8a; background: #0b1f46; }

.sticky-box {
  position: sticky;
  top: 16px;          /* distance from top of viewport when it becomes sticky */
  /* optional styling */
  background: white;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  z-index: 10;
}

/* Sticky horizontal scrollbar fixed at viewport bottom */
.sticky-hscroll {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--sticky-hscroll-height); /* match custom track height */
    z-index: 5000; /* above page chrome */
    background: #ffffff; /* visible bar background */
    border-top: 1px solid #e6e6e6;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.05);
    pointer-events: auto; /* allow interaction with the bar */
}
.sticky-hscroll > :not(.sticky-hscroll-viewport):not(.sticky-hscroll-bar) {
    display: none !important;
}
.sticky-hscroll-viewport {
    width: 100%;
    height: 0; /* hide native bar area */
    overflow: hidden; /* no native bar */
    pointer-events: auto; /* enable interaction */
    display: block;
    background: transparent;
    margin-top: 0;
}
.sticky-hscroll-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--sticky-hscroll-height); /* custom track height */
    pointer-events: auto;
    z-index: 2; /* Adjust z-index layering for interactivity */
}
.sticky-hscroll-bar .sticky-thumb {
    position: absolute;
    top: 4px;
    left: 0;
    height: 14px; /* thicker thumb */
    width: 60px; /* will be resized by JS */
    background: #c1c1c1;
    border-radius: 7px;
    cursor: grab;
}
.sticky-hscroll-bar .sticky-thumb:active {
    cursor: grabbing;
    background: #a1a1a1;
}
.sticky-hscroll-content {
    height: 1px; /* minimal height to show only scrollbar */
}
/* Optional: nicer track appearance (WebKit only) */
.sticky-hscroll-viewport::-webkit-scrollbar {
    height: 16px; /* thicker native scrollbar if visible */
}
.sticky-hscroll-viewport::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 6px;
}
.sticky-hscroll-viewport::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}
/* We size inner scrollers in JS to avoid overlap with the sticky bar, so no extra page padding needed */

/* WebKit override kept above to hide both axes */
/* Recent Bookings indicator dots */
.rb-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 2px;
    border: 1px solid rgba(0,0,0,.15);
}
.rb-gray { background: #adb5bd; }
.rb-green { background: #198754; } /* match .text-success */
.rb-yellow { background: #ffc107; } /* match .text-warning */
/* Navbar Open Calendar button styles - match navbar-dark link colors */
.navbar-dark .btn-open-calendar {
    color: rgba(255, 255, 255, .55) !important;
    background-color: transparent !important;
    border: 1px solid rgba(255, 255, 255, .55) !important;
}
.navbar-dark .btn-open-calendar:hover,
.navbar-dark .btn-open-calendar:focus {
    color: rgba(255, 255, 255, .75) !important;
    border-color: rgba(255, 255, 255, .75) !important;
    background-color: transparent !important;
    text-decoration: none !important;
}
.navbar-dark .btn-open-calendar:active,
.navbar-dark .btn-open-calendar.active,
.navbar-dark .btn-open-calendar.show {
    color: #fff !important;
    border-color: #fff !important;
    background-color: transparent !important;
}