/* General Reset & Body */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f7f6;
    color: #333;
}

.container {
    width: 100%;
    padding: 1rem;
    margin: 0 auto;
}

@media (min-width: 992px) { .container { max-width: 960px; } }
@media (min-width: 1200px) { .container { max-width: 1140px; } }

/* Header & Page Titles */
header {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    text-align: center;
}

.header-logo {
    height: 80px;
    width: auto;
    margin-bottom: 1rem;
}

header h1 {
    color: #2c3e50;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

header p {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* --- New Professional Navbar --- */
.navbar {
    background-color: #3498db;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.nav-brand a {
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 1.4rem;
}

.nav-links-container {
    display: none; /* Hidden on mobile by default */
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    text-decoration: none;
    color: #fff;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
    color: #f1c40f;
}

/* Hamburger Toggle Button */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10;
}

.nav-toggle .hamburger {
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 10px;
    transition: all 0.3s linear;
    position: relative;
    transform-origin: 1px;
}

.nav-toggle .hamburger::before,
.nav-toggle .hamburger::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 10px;
    transition: all 0.3s linear;
}

.nav-toggle .hamburger::before {
    transform: translateY(-8px);
}

.nav-toggle .hamburger::after {
    transform: translateY(8px);
}

.nav-toggle.active .hamburger {
    background: transparent;
}

.nav-toggle.active .hamburger::before {
    transform: rotate(45deg);
}

.nav-toggle.active .hamburger::after {
    transform: rotate(-45deg);
}


/* Mobile Navigation Styles */
@media (max-width: 767px) {
    .nav-toggle {
        display: flex;
    }

    .nav-links-container {
        display: none; /* Initially hidden */
        position: absolute;
        top: 80px; /* Position below the navbar */
        left: 0;
        width: 100%;
        padding: 0 1rem; /* Match container padding */
        z-index: 100;
    }
    
    .nav-links-container.active {
        display: block; /* Show when active */
    }

    .nav-links {
        flex-direction: column;
        gap: 0;
        width: 100%;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 8px 16px rgba(0,0,0,0.1);
        overflow: hidden;
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links a {
        display: block;
        padding: 1rem 1.5rem;
        text-align: left;
        border-top: 1px solid #f0f0f0;
        color: #555; /* Reset color for dropdown */
    }
}

/* Desktop Navigation Styles */
@media (min-width: 768px) {
    .nav-links-container {
        display: block;
    }
}

/* Main Content & Sections */
main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

h2, h3 {
    background-color: #eaf6ff; /* Light blue background */
    color: #2c3e50;
    padding: 0.75rem 1rem;
    border-left: 5px solid #3498db; /* Blue accent line */
    margin-bottom: 1.5rem;
    border-radius: 5px;
}

/* Forms & Filters */
form {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-container {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 1rem;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.filter-group > label {
    font-weight: bold;
    margin-right: 0.5rem;
}

.filter-options {
    display: flex;
    gap: 0.5rem;
}

.filter-options input[type="checkbox"] {
    display: none;
}

.filter-options label {
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: normal;
}

.filter-options input[type="checkbox"]:checked + label {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
}

button {
    background-color: #3498db;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background-color 0.3s, transform 0.2s;
    align-self: flex-start;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}

.update-button {
    align-self: stretch; 
}

/* Unified Table Styles */
.table-container {
    overflow-x: auto; /* ONLY allow horizontal scrolling */
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.spreadsheet-table {
    width: 100%;
    min-width: 800px;
    border-collapse: separate;
    border-spacing: 0;
}

.spreadsheet-table th, .spreadsheet-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    vertical-align: middle;
    white-space: nowrap;
}

.spreadsheet-table thead th {
    background-color: #f8f9fa;
    color: #333;
    font-weight: bold;
}

.spreadsheet-table tbody tr:hover {
    background-color: #f2f8fc;
}

.spreadsheet-table tbody tr:last-child td {
    border-bottom: none;
}

/* --- STICKY HEADER & COLUMN STYLES --- */
.sticky-header-clone {
    position: fixed;
    top: 0;
    left: 0;
    width: auto;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: none;
    overflow: hidden; /* This is the critical fix */
}

.sticky-header-clone .spreadsheet-table {
    margin-bottom: 0;
    border-radius: 0;
    border: none;
}


.spreadsheet-table td:first-child,
.spreadsheet-table th:first-child {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
    z-index: 1;
    border-right: 1px solid #ddd;
    background-color: #fff;
}

.spreadsheet-table tr:hover td:first-child {
    background-color: #f2f8fc;
}


.spreadsheet-table input {
    width: 100px;
}

/* Styles for forms inside table cells */
.spreadsheet-table td form {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.spreadsheet-table td form input[type="number"] {
    width: 80px;
}

.spreadsheet-table td form button {
    padding: 5px 15px;
    font-size: 0.9em;
}

/* Container for multiple forms in one cell */
.spreadsheet-table td .actions-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

/* --- STICKY UPDATE BUTTON --- */
.sticky-update-container {
    position: -webkit-sticky;
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding: 1rem 0;
    display: flex;
    justify-content: center;
}

.update-button {
    width: 50%;
    max-width: 400px;
    min-width: 200px;
    align-self: center; /* Center button in the flex container */
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Saved / error messages after a form is submitted */
.flash {
    padding: 0.85rem 1rem;
    border-radius: 6px;
    margin: 0 0 1rem;
    font-weight: bold;
}

.flash-ok {
    background-color: #e8f6ec;
    color: #1e6b3a;
    border: 1px solid #b7e1c5;
}

.flash-err {
    background-color: #fdecea;
    color: #a12a1f;
    border: 1px solid #f3c1bb;
}

.form-note {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

/* --- Staff counting page --- */
.filter-options input[type="radio"] {
    display: none;
}

.filter-options input[type="radio"]:checked + label {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

.filter-container .search-row {
    margin-top: 0.75rem;
}

.filter-container .search-row input[type="search"] {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
}

.legend {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    align-items: center;
}

.swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 0.3rem;
    border: 1px solid #bbb;
}

.swatch-low { background-color: #fff4d6; border-color: #e0a800; }
.swatch-out { background-color: #fde2df; border-color: #d9534f; }
.swatch-changed { background-color: #fff; border-left: 4px solid #3498db; }

.spreadsheet-table.staff-table {
    min-width: 0;
}

.staff-table td:first-child {
    white-space: normal;
    min-width: 110px;
}

.staff-table input[type="number"] {
    width: 90px;
    font-size: 1.1rem;
}

input.qty-low { background-color: #fff4d6; border-color: #e0a800; }
input.qty-out { background-color: #fde2df; border-color: #d9534f; }
input.qty-changed { box-shadow: inset 5px 0 0 #3498db; }

/* --- Shopping list (admin) --- */
.list-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.shop-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.shop-group {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 1rem 1.25rem;
}

.shop-group h3 {
    margin-top: 0;
}

.shop-count {
    color: #888;
    font-weight: normal;
    font-size: 0.9em;
}

.shop-group ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.shop-group li {
    padding: 0.35rem 0;
    border-bottom: 1px solid #eee;
}

.shop-group li:last-child {
    border-bottom: none;
}

.shop-group li label {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    cursor: pointer;
}

.shop-group li input:checked ~ .shop-item {
    text-decoration: line-through;
    color: #999;
}

.shop-unit {
    color: #666;
}

@media print {
    body * { visibility: hidden; }
    #shopping-list, #shopping-list * { visibility: visible; }
    #shopping-list { position: absolute; left: 0; top: 0; width: 100%; }
    .list-actions { display: none; }
    .shop-group { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}

@media (max-width: 480px) {
    .filter-options { flex-wrap: wrap; }
    .staff-table th, .staff-table td { padding: 10px 6px; }
    .staff-table td:first-child { min-width: 90px; }
    .staff-table input[type="number"] { width: 72px; padding: 0.5rem; }
}
