/* --- GENERAL STYLES --- */
* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    color: #333;
    margin: 0;
    padding-top: 60px; /* Space for fixed header */
}

/* --- HEADER (Universal Layout) --- */
.app-header {
    background-color: #0056b3;
    color: white;
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    border-bottom: 1px solid #004494;
}
.header-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.header-right {
    margin-left: auto;
    flex-shrink: 0;
}
.app-title {
    margin: 0;
    font-size: 24px;
    font-weight: 300;
    color: #d1eaff;
    letter-spacing: 1px;
}
.app-title .highlight {
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 0 7px rgba(255, 255, 255, 0.5);
}
#logout-link svg {
    stroke: white;
}
#logout-link:hover svg {
    stroke: #ffdddd;
}

/* --- SIDE NAVIGATION --- */
.sidenav {
    height: 100%;
    width: 220px;
    position: fixed;
    z-index: 900;
    top: 0;
    left: 0;
    background-color: #2c3e50;
    overflow-x: hidden;
    padding-top: 80px;
    transition: left 0.3s ease-in-out;
}
.sidenav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.sidenav a {
    padding: 10px 15px;
    text-decoration: none;
    font-size: 18px;
    color: #bdc3c7;
    display: block;
    transition: 0.2s;
}
.sidenav a:hover {
    color: #ffffff;
    background-color: #34495e;
}

/* --- NEW SIDENAV OVERLAY STYLES --- */
#sidenav-overlay {
    display: none; /* Hidden by default */
    position: fixed; /* Fixed to the viewport, will not scroll */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 899; /* Just below the sidenav, but above everything else */
}

/* --- MAIN CONTENT AREA --- */
.main-content {
    transition: margin-left 0.3s, filter 0.3s;
    padding: 20px;
    margin-left: 220px;
    position: relative;
    z-index: 800;
}


/* --- HAMBURGER MENU BUTTON --- */
#menu-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: none;
    padding: 10px;
    margin-right: 15px;
}
#menu-toggle-btn span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: white;
    margin: 5px 0;
}

/* --- MODAL STYLES --- */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}
.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
}
/* --- FINAL MODAL HEADER & CONTENT STYLES --- */

/* Keep the main modal content container with its original padding */
.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px; /* Restore original padding */
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    /* NEW APPROACH: Use padding and a negative margin TRICK */
    margin: -20px -20px 20px -20px; /* Go up and out to the edges of the parent padding */
    padding: 15px 20px;             /* Add our own internal padding back */

    background-color: #f8f9fa; /* A slightly softer grey */
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0; /* Match the parent's top corners */
}

.modal-header h1 {
    margin: 0;
    font-size: 18px;
    color: #495057; /* Darker grey for better contrast */
}

.close-btn {
    position: static;
    float: none;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    color: #6c757d;
    opacity: 0.7;
    background: none;
    border: none;
    width: auto;
    padding: 0;
}

.close-btn:hover {
    color: #212529;
    opacity: 1;
}
/* --- NEW CUSTOM QUANTITY INPUT STYLES --- */

/* Compact quantity controls: use a small, non-stretching input and tighter buttons.
   Use a grid layout on the item row to keep label flexible and prevent squishing. */
.quantity-input-wrapper {
    display: inline-flex;
    align-items: center;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.quantity-btn {
    background-color: #f1f3f5;
    color: #495057;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    width: 32px; /* compact click area */
    height: 32px;
    line-height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.12s;
}

.quantity-btn:hover { background-color: #e2e6ea; }

/* Compact number input that doesn't stretch to fill the row */
.quantity-input {
    width: 48px;
    min-width: 48px;
    max-width: 64px;
    text-align: center;
    border: none;
    padding: 6px 4px;
    font-size: 14px;
    font-weight: 600;
    background: transparent;
    appearance: textfield; /* standard property for broader compatibility */
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

/* Make the time control fill the modal width like the search input.
   Buttons remain fixed size; the numeric input flexes to take remaining space. */
.time-qty-wrapper {
    display: flex;
    gap: 8px;
    width: 100%; /* fill the available width in the form-group */
    align-items: center;
}

.time-qty-wrapper .quantity-input {
    flex: 1;           /* expand to fill space */
    width: auto;       /* allow flex to control size */
    min-width: 72px;   /* keep readable on very small widths */
    max-width: none;
}

.time-qty-wrapper .quantity-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 18px;
}
.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* --- FORM & GENERIC TABLE STYLES --- */
.message { text-align: center; padding: 10px; background-color: #e6f7ff; border: 1px solid #91d5ff; border-radius: 4px; margin-bottom: 20px; }
.message.error { background-color: #f8d7da; border-color: #f5c6cb; color: #721c24; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
button { display: block; width: 100%; padding: 10px; background-color: #0056b3; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; }
button:hover { background-color: #004494; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; background-color: #fff; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
th, td { padding: 12px; border: 1px solid #ddd; text-align: left; }
thead { background-color: #f2f2f2; }
tbody tr:nth-child(even) { background-color: #f9f9f9; }
table img { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; }
input[type="checkbox"] {
    width: 20px;
}
/* --- HEADER (Universal Layout - Final) --- */
.app-header {
    background-color: #0056b3;
    color: white;
    height: 60px;
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    border-bottom: 1px solid #004494;
}

.header-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    /* This width perfectly matches the sidenav for alignment */
    width: 220px; 
    padding: 0 20px;
}

/* This is the container for tabs and logout */
.header-main-area {
    flex-grow: 1; /* It takes up all remaining width */
    height: 100%;
    display: flex;
    align-items: center;
}

.header-right {
    margin-left: auto; /* Pushes logout to the far right of this container */
    flex-shrink: 0;
}

/* --- UPGRADED: HEADER ICON BADGES (High Visibility) --- */
.header-icon-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px; /* Increased size from 30px */
    height: 32px; /* Increased size from 30px */
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1); /* Adds a subtle border for definition */
    cursor: help; /* Changes the cursor to a '?' to indicate it's informative */
}
.header-icon-badge svg {
    stroke-width: 2.5; /* Makes the icon lines thicker */
}

/* Specific colors for different badges - MORE CONTRAST */

/* Work Order: Bright Red */
.header-icon-badge.wo-badge { background-color: #dc3545; border-color: #b02a37; }
.header-icon-badge.wo-badge svg { stroke: #ffffff; }

/* Owner Stay: Bright Yellow/Gold */
.header-icon-badge.os-badge { background-color: #ffc107; border-color: #c79805; }
.header-icon-badge.os-badge svg { stroke: #212529; fill: #212529; } /* Black icon for readability */

/* Romance Package: Bright Pink/Red */
.header-icon-badge.romance-badge { background-color: #e83e8c; border-color: #b9316e; }
.header-icon-badge.romance-badge svg { stroke: #ffffff; fill: #ffffff; }

/* Firewood: Bright Brown/Orange */
.header-icon-badge.firewood-badge { background-color: #fd7e14; border-color: #c4620e; }
.header-icon-badge.firewood-badge svg { stroke: #ffffff; }

/* App Title & Logout Icon (Unchanged) */
.app-title { margin: 0; font-size: 24px; font-weight: 300; color: #d1eaff; letter-spacing: 1px; }
.app-title .highlight { font-weight: 700; color: #ffffff; text-shadow: 0 0 7px rgba(255, 255, 255, 0.5); }
#logout-link svg { stroke: white; }
#logout-link:hover svg { stroke: #ffdddd; }

/* --- Default Tab Pane Visibility --- */
.tab-pane {
    display: none; /* Hide all tab content by default */
}
.tab-pane.active {
    display: block; /* ONLY show the tab that also has the "active" class */
}

/* --- TAB LAYOUT STYLES (File Folder Version) --- */
.tab-nav {
    display: flex;
    flex-grow: 1; /* Tell the NAV container to grow */
    height: 100%;
    align-items: flex-end; /* Pushes tabs to the bottom */
    margin-right: 30px; /* Adds space between last tab and logout button */
}

.tab-link {
    /* flex-grow is removed from here */
    text-align: center;
    padding: 10px 20px;
    cursor: pointer;
    background-color: #004a9e;
    border: 1px solid #004494;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    margin-right: 5px;
    margin-bottom: -1px;
    font-size: 16px;
    color: #a7d4ff;
    position: relative;
    transition: background-color 0.2s, color 0.2s;
}
.tab-link:last-child {
    margin-right: 0;
}
.tab-link:not(.active):hover {
    background-color: #005cb3;
    color: #ffffff;
}
.tab-link.active {
    background-color: #f4f4f4;
    color: #0056b3;
    font-weight: bold;
    border-color: #dee2e6;
    border-bottom: 1px solid #f4f4f4;
    z-index: 1001;
}

/* --- UI Button and Control Styles --- */
.table-header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.table-header-controls h2 {
    margin: 0;
}
.btn-primary {
    width: auto;
    background-color: #0056b3;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.btn-primary:hover {
    background-color: #004494;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}
.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* --- UNIVERSAL CARD STYLES (for Properties & Work Orders) --- */
.property-card-container,
.work-order-card-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.property-card,
.work-order-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
}
.property-card {
    border: 1px solid #dee2e6;
     border-left: 5px solid #6c757d; /* Standard grey border */
    overflow: visible;
}
.work-order-card {
    border-left: 5px solid #6c757d;
}
.work-order-card:has(.priority-high) {
    border-left-color: #dc3545;
}

.card-toggle-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f1f1f1;
}
.property-card:not(.expanded) .card-toggle-area:hover,
.work-order-card:not(.expanded) .card-toggle-area:hover {
    background-color: #f8f9fa;
}
.card-toggle-area h3 {
    margin: 0;
    font-size: 16px;
    color: #343a40;
    display: flex;
    align-items: center;
}
.card-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}
.door-code-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #e9ecef;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 15px;
    font-weight: 700;
    color: #0056b3;
    letter-spacing: 1px;
}
.door-code-display svg {
    stroke: #0056b3;
}
.card-chevron {
    font-size: 24px;
    font-weight: bold;
    color: #ced4da;
    transition: transform 0.3s ease-in-out;
}
.expanded .card-chevron {
    transform: rotate(90deg);
}

.card-collapsible-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-in-out;
}
.property-card.expanded .card-collapsible-content,
.work-order-card.expanded .card-collapsible-content {
    border-top: 1px solid #dee2e6;
}
.card-collapsible-content > div {
    overflow: hidden;
}
.expanded .card-collapsible-content {
    grid-template-rows: 1fr;
}
/* --- NEW & IMPROVED CARD BODY RULES --- */
.card-body {
    padding: 0 15px; /* Keep side padding, but remove vertical padding by default */
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* The transition is now part of the expanded state logic */
}

/* When the parent card is expanded, restore vertical padding */
.expanded .card-body {
    padding-top: 15px;
    padding-bottom: 15px;
    transition: padding 0.3s ease-in-out;
}
.collapsed .card-body {
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
}
.info-item {
    font-size: 13px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
}
.info-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.info-item strong {
    color: #495057;
    display: block;
    margin-bottom: 3px;
}
.info-item span {
    color: #212529;
    white-space: pre-wrap;
}
.wo-photo {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin-top: 5px;
}

.card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}
.action-icons {
    display: flex;
    gap: 12px;
}

/* --- PROPERTY CARD SPECIFIC ACTION BUTTONS --- */
.property-card .btn-action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #6c757d;
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}
.property-card .btn-action svg { stroke: white; }
.property-card .btn-action:hover { background-color: #5a6268; transform: scale(1.1); }
.property-card .btn-action:active { transform: scale(0.95); }
.property-card .btn-action.map-btn { background-color: #17a2b8; }
.property-card .btn-action.map-btn:hover { background-color: #138496; }

/* --- WORK ORDER SPECIFIC ACTION BUTTONS & TAGS --- */
.card-actions form { margin: 0; }
.btn-action-form {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #007bff;
    color: white;
    border: none;
    padding: 6px;
    width: auto; /* Allow text buttons to size naturally */
    min-width: 32px; /* Set a min-width for icon buttons */
    height: 32px;
    border-radius: 5px; /* Change to match text button style */
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    padding-left: 12px;
    padding-right: 12px;
}
.btn-action-form:hover { background-color: #0069d9; }
.btn-action-form.btn-complete { background-color: #28a745; }
.btn-action-form.btn-complete:hover { background-color: #218838; }
.btn-action-form.btn-part-request, .btn-action-form.btn-part-received { border-radius: 50%; width: 32px; padding: 6px; } /* Make icon buttons circular */
.btn-action-form.btn-part-request { background-color: #6f42c1; }
.btn-action-form.btn-part-request:hover { background-color: #5a32a3; }
.btn-action-form.btn-part-received { background-color: #28a745; }
.btn-action-form.btn-part-received:hover { background-color: #218838; }
.btn-action-form svg { stroke: white; }

.priority-tag { font-weight: bold; padding: 4px 10px; border-radius: 12px; font-size: 12px; }
.priority-standard { background-color: #e2e3e5; color: #383d41; }
.priority-high { background-color: #f8d7da; color: #721c24; }

/* --- OCCUPANCY STATUS TAGS (Used by both card types) --- */
.occupancy-status { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; padding: 4px 8px; border-radius: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.occupancy-status.status-default, .occupancy-status.status-arrival { color: #1e7e34; background-color: #d4edda; }
.occupancy-status.status-default .status-dot, .occupancy-status.status-arrival .status-dot { background-color: #1e7e34; }
.occupancy-status.status-checkout { color: #b85d0d; background-color: #fff3cd; }
.occupancy-status.status-checkout .status-dot { background-color: #b85d0d; }
.occupancy-status.status-occupied { color: #721c24; background-color: #f8d7da; }
.occupancy-status.status-occupied .status-dot { background-color: #721c24; }
.occupancy-status.status-blocked { color: #383d41; background-color: #e2e3e5; }
.occupancy-status.status-blocked .status-dot { background-color: #383d41; }
.occupancy-status.status-turn { color: #004085; background-color: #cce5ff; }
.occupancy-status.status-turn .status-dot { background-color: #004085; }
.occupancy-status.status-part-pending { color: #5a32a3; background-color: #e9dffc; }
.occupancy-status.status-part-pending .status-dot { background-color: #5a32a3; }

/* --- BOTTOM MOBILE NAVIGATION --- */
.mobile-bottom-nav { display: none; position: fixed; bottom: 0; left: 0; width: 100%; height: 60px; background-color: #0056b3; border-top: 1px solid #004494; box-shadow: 0 -2px 5px rgba(0,0,0,0.1); z-index: 1000; }
.mobile-nav-btn { flex-grow: 1; /* Allow buttons to share space equally */
    flex-basis: 0; /* Ensures grow works correctly */
    width: auto;   /* Remove the fixed width */ height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; background-color: transparent; border: none; border-top: 4px solid transparent; padding: 5px 0; cursor: pointer; color: #a7d4ff; transition: color 0.2s, border-color 0.2s; }
.mobile-nav-btn svg { stroke: #a7d4ff; transition: stroke 0.2s; }
.mobile-nav-btn span { font-size: 10px; font-weight: 600; }
.mobile-nav-btn.active { color: #ffffff; border-top-color: #ffffff; }
.mobile-nav-btn.active svg { stroke: #ffffff; }

.item-list-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px;
    margin-top: 5px;
}
.radio-item {
    display: block;
    margin-bottom: 5px;
}
/* Item row: grid keeps the label flexible, qty controls fixed to the right */
.checkbox-item {
    display: block;
    padding: 8px 10px;
    border-bottom: 1px solid #f6f6f6;
}

.checkbox-top {
    display: flex;
    gap: 8px;
    align-items: center;
}

.checkbox-top label {
    margin: 0;
    min-width: 0; /* allow truncation */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Full-width qty controls placed below the checkbox/label */
.stock-qty-wrapper {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: 6px;
    align-items: center;
}

.stock-qty-wrapper .quantity-input {
    flex: 1; /* expand to fill modal width */
    width: auto;
}

/* Keep legacy compact number inputs styled if present */
.checkbox-item input[type="number"] {
    width: 56px;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
}

/* Stock qty wrapper: ensure a single flex layout and make the numeric input expand to fill available width */
.stock-qty-wrapper {
    display: flex; /* keep as flex so child can grow */
    align-items: center;
    gap: 8px;
    width: 100%;
}
.stock-qty-wrapper .quantity-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 18px;
}
.stock-qty-wrapper .quantity-input {
    flex: 1;            /* expand to fill the wrapper */
    width: auto;        /* let flex control width */
    text-align: center;
    padding: 6px 8px;
    min-width: 56px;    /* keep readable on very small screens */
}

@media screen and (max-width: 480px) {
    .checkbox-item { gap: 8px; padding: 8px; }
    .stock-qty-wrapper .quantity-btn { width: 36px; height: 36px; font-size: 18px; }
    .stock-qty-wrapper .quantity-input { width: 56px; }
    /* On very small screens allow the label to wrap instead of shrinking too far */
    .checkbox-item label { white-space: normal; }
}
.radio-item label {
    display: block;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
}
.radio-item input[type="radio"] {
    display: none; /* Hide the default radio button */
}
.radio-item input[type="radio"]:checked + label {
    background-color: #0056b3;
    color: white;
    font-weight: bold;
}

/* --- RESPONSIVE DESIGN --- */
@media screen and (max-width: 768px) {
    .sidenav {
        left: -220px;
    }
    .sidenav.open {
        left: 0;
    }
    .main-content {
       margin-left: 0;
        padding-left: 10px;  /* Reduce side padding for mobile */
        padding-right: 10px; /* Reduce side padding for mobile */
        padding-bottom: 70px;
    }
    #menu-toggle-btn {
        display: block;
    }
    .app-title {
        font-size: 20px;
    }
    .header-left {
        width: auto;
        padding: 0 10px;
    }
    .header-main-area .tab-nav {
        display: none;
    }
    .mobile-bottom-nav {
        display: flex;
    }
    /* --- RESPONSIVE HEADER CONTROLS (Final) --- */
    .table-header-controls {
        flex-direction: column; /* Stack the h2 and the controls div vertically */
        align-items: center;    /* Center them horizontally */
        gap: 15px;
    }

    /* Target the container that holds the search bar and/or button */
    .table-header-controls > div {
        display: flex;
        flex-direction: column; /* Stack the search and button vertically */
        width: 100%;            /* Make this container full-width */
        gap: 15px;
    }

    /* Target BOTH the form group (for the search bar) AND the button */
    .table-header-controls > div > .form-group,
    .table-header-controls > div > .btn-primary {
        width: 100%; /* Make BOTH the search group and the button full-width */
        min-width: 0;  /* Allow shrinking */
    }

    .table-header-controls h2 {
        text-align: center;
    }

    .table-header-controls .form-group {
        min-width: 0; /* Allow the search bar to shrink properly */
    }

}
/* --- RECURRING TASK STYLES --- */
.property-card.task-due {
    border-left: 5px solid #ffc107; /* Warning yellow */
}
.btn-action.task-complete-btn {
    background-color: #283366; /* Match the border */
}
.btn-action.task-complete-btn:hover {
    background-color: #e0a800;
}
/* --- FULL HEIGHT CALENDAR STYLES (Version 2 - Scrolling Fixed) --- */

/* We no longer need to control the html/body height directly */

.page-schedule .main-content {
    /* Set a max-height to prevent the body from scrolling */
    max-height: calc(100vh - 60px); /* Full screen height minus the top header */
    overflow-y: auto; /* THIS IS THE KEY: Make the main content area scrollable */
    padding-bottom: 60px; /* Add padding to the bottom to avoid the mobile nav */
}

/* We don't need the flex-grow rules anymore. 
   FullCalendar will naturally expand to fit its content, 
   and our .main-content will handle the scrolling. */
/* .page-schedule #calendar rules were intentionally removed to avoid an empty ruleset; calendar sizing is handled by .main-content scrolling rules above. */

/* We can also remove the .fc-scroller override, as it's no longer needed */
/* Use Flexbox for the main toolbar for better alignment */
.fc .fc-header-toolbar {
    display: flex;
    flex-wrap: wrap; /* Allow items to wrap onto the next line on small screens */
    justify-content: space-between;
    align-items: center;
    gap: 10px; /* Add some space between wrapped items */
    padding: 10px 0;
}

/* Ensure the left, center, and right sections behave correctly */
.fc .fc-toolbar-chunk {
    display: flex;
    align-items: center;
    gap: 5px; /* Space between buttons within a chunk */
}

/* On smaller screens, make the chunks take up the full width */
@media screen and (max-width: 576px) {
    .fc .fc-header-toolbar {
        flex-direction: column; /* Stack the sections vertically */
        align-items: stretch;   /* Make them full-width */
    }

    .fc .fc-toolbar-chunk {
        justify-content: center; /* Center the buttons within each chunk */
        width: 100%;
    }

    .fc .fc-toolbar-title {
        font-size: 1.25em; /* Slightly smaller title on mobile */
    }
}



/* --- UNIFIED CALENDAR STYLING (Version 2) --- */

/* The main calendar container. Remove its top border since the header will provide it. */
.fc {
    border: 1px solid #ddd;
    border-top: none; 
    border-radius: 0 0 6px 6px; /* Only round the bottom corners */
    overflow: hidden; 
}

/* Style the top control bar to be the new top of the component */
.fc .fc-header-toolbar.fc-toolbar {
    background-color: #f8f9fa;
    padding: 10px;
    border: 1px solid #ddd;
    border-bottom: none; /* Join it to the calendar body */
    border-radius: 6px 6px 0 0; /* Rounded top corners */
    margin-bottom: 0 !important;
    display: flex; /* Ensure flex properties */
    justify-content: center; /* Center the chunk within the bar */
}

/* Force the control button group to take up the full width */
.fc .fc-header-toolbar .fc-toolbar-chunk {
    display: flex;
    justify-content: center; /* Center the buttons within the chunk */
    width: 100%; /* THIS IS THE KEY: Make the button group expand */
}

/* Remove any extra border from the view harness */
.fc-view-harness {
    border: none;
}

/* --- USER TABLE UI IMPROVEMENTS --- */
.user-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.color-cell {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.2s;
}
.color-cell:hover {
    transform: scale(1.1);
}

/* Make the SVG icons inside our new action buttons look right */
.btn-action-form svg {
    stroke: white;
}

/* --- ZONE PAGE STYLES --- */
.main-content .header-main-area {
    background-color: #0056b3;
    padding: 0 20px;
    margin: -20px -20px 20px -20px; /* Pull to edges */
    height: 60px;
    display: flex;
    align-items: flex-end;
}
.main-content .header-main-area .tab-nav {
    margin-bottom: 0;
}

/* --- CHECKBOX STYLES for Zone Settings --- */
.checkbox-label {
    display: block;
    margin-bottom: 10px;
    font-weight: normal;
    cursor: pointer;
}
.checkbox-label input {
    width: auto;
    margin-right: 10px;
    transform: scale(1.2); /* Makes checkbox slightly bigger */
}

/* --- NEW: CHECKBOX GRID STYLES --- */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 columns by default */
    gap: 10px; /* Space between items */
    margin-top: 10px;
}

/* On smaller screens, collapse to 2 columns */
@media screen and (max-width: 768px) {
    .checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* On very small screens, collapse to a single column */
@media screen and (max-width: 480px) {
    .checkbox-grid {
        grid-template-columns: 1fr;
    }
}
/* --- NOTIFICATION BADGE STYLES --- */
.task-hub-btn {
    position: relative; /* Needed for positioning the badge */
}
.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* --- Task Dropdown Styles --- */

/* The main container - needs relative positioning */
.task-dropdown-container {
    position: relative;
    display: inline-block;
}

/* The badge on the main button */
.task-due-btn {
    position: relative; /* Needed for positioning the badge */
}

.task-count-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #dc3545; /* Red color for attention */
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* The dropdown menu itself - hidden by default */
.task-dropdown-menu {
    /* Keep the menu off the layout with absolute positioning, centered over its inline container */
    position: absolute;
    left: 50%;                      /* Center horizontally relative to container */
    transform: translateX(-50%) translateY(6px); /* start slightly lower when hidden */
    bottom: 100%; /* Position it above the button */
    margin-bottom: 10px; /* Space between button and menu */
    background-color: #ffffff;
    min-width: 220px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 100; /* Ensure it appears above other content */
    border-radius: 6px;
    padding: 5px 0;
    border: 1px solid #ddd;

    /* Use visibility + opacity + transform for smooth transitions instead of display */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease;
}

/* Pointer (caret) pointing down at the trigger button (popup -> button).
   ::before creates a subtle shadow, ::after creates the visible white triangle. */
.task-dropdown-menu::before,
.task-dropdown-menu::after {
    content: '';
    position: absolute;
    /* Use a CSS variable set by JS to align the arrow to the trigger button. Fallback to 50% */
    left: var(--task-dropdown-arrow-left, 50%);
    transform: translateX(-50%);
    width: 0;
    height: 0;
    pointer-events: none;
}

.task-dropdown-menu::before {
    /* subtle shadow/border behind the pointer */
    bottom: -9px; /* place under the menu */
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 9px solid rgba(0,0,0,0.08);
}

.task-dropdown-menu::after {
    /* visible pointer pointing downward */
    bottom: -8px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #ffffff; /* same as menu background */
}

/* The class we'll add with JavaScript to show the menu */
.task-dropdown-menu.show {
    /* Make visible and animate into position */
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* Styling for the items inside the dropdown */
.task-dropdown-menu .dropdown-item {
    color: #333;
    padding: 10px 15px;
    text-decoration: none;
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
}

.task-dropdown-menu .dropdown-item:hover {
    background-color: #f1f1f1;
}

/* Ensure stock quantity controls behave exactly like the time quantity controls:
   the numeric input should expand to fill remaining width while buttons stay fixed. */
.quantity-input-wrapper.stock-qty-wrapper {
    display: flex;   /* force a flex container (overrides inline-flex) */
    gap: 8px;
    width: 100%;     /* fill the available width in the form/group */
    align-items: center;
}
.quantity-input-wrapper.stock-qty-wrapper .quantity-input {
    flex: 1;         /* expand to take remaining space */
    width: auto;     /* allow flex to control width */
    min-width: 72px; /* keep readability on very small viewports */
    max-width: none; /* remove any legacy max-width limits */
}

/* Invoice-style table for the Confirm Completion modal */
.invoice-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 14px;
    margin-top: 8px;
}
.invoice-table thead th {
    background-color: #f1f3f5;
    color: #333;
    font-weight: 700;
    padding: 8px 10px;
    border-bottom: 1px solid #e6e9ec;
}
.invoice-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #f4f6f8;
}
.invoice-table tbody tr:nth-child(odd) {
    background-color: #ffffff;
}
.invoice-table tbody tr:nth-child(even) {
    background-color: #fbfdff;
}
.invoice-table tfoot td {
    padding: 10px 10px;
    border-top: 2px solid #e6e9ec;
    background-color: #ffffff;
}
.invoice-total td { font-size: 15px; }

/* The invoice table uses the same layout across all screen sizes. Small-screen specific rules were removed so the Confirm Completion table displays consistently. */