/* 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; }
}

/* ===== Time clock ===== */
.login-form { max-width: 400px; margin: 2rem auto; }
.login-form label { display: block; margin-top: 0.75rem; }

.clock-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 1.5rem 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}
.clock-status { font-size: 1.4rem; font-weight: bold; color: #7f8c8d; }
.clock-status.clock-on { color: #1e6b3a; }
.clock-detail { color: #555; margin: 0.25rem 0 0.5rem; }
.clock-elapsed { font-size: 2.6rem; font-weight: bold; color: #2c3e50; margin-bottom: 0.75rem; font-variant-numeric: tabular-nums; }
.clock-buttons { display: flex; flex-direction: column; gap: 0.75rem; max-width: 420px; margin: 0.75rem auto 0; }
.clock-btn {
    display: block;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 1.1rem 1rem;
    font-size: 1.25rem;
    font-weight: bold;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.clock-btn-in { background-color: #2e9e5b; }
.clock-btn-in:hover { background-color: #25834b; }
.clock-btn-out { background-color: #d9534f; }
.clock-btn-out:hover { background-color: #c0403c; }

.week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0.5rem 0 1rem;
    text-align: center;
}
.week-label { flex: 1; line-height: 1.3; }
.week-link {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background: #eaf3fb;
    color: #2c7fb8;
    text-decoration: none;
    font-weight: bold;
    white-space: nowrap;
}
.week-link-off { background: #f0f0f0; color: #bbb; }

.hours-table td, .hours-table th { white-space: nowrap; }
.hours-table tfoot td { border-top: 2px solid #dfe6e9; background: #fafbfb; }
.dec { color: #7f8c8d; font-size: 0.85em; font-weight: normal; }
.row-warn { background-color: #fff4d6; }
.warn-tag { background: #e0a800; color: #fff; border-radius: 4px; padding: 0 0.4rem; font-size: 0.8em; }
.row-actions { display: flex; gap: 0.75rem; align-items: center; }
.row-actions form { display: inline; margin: 0; }
.small-btn { padding: 0.3rem 0.6rem; font-size: 0.85rem; width: auto; }
.nowrap { white-space: nowrap; }
.activity-table td { vertical-align: top; }

.stack-form { max-width: 420px; }
.stack-form label { display: block; margin-top: 0.75rem; font-weight: bold; }
.stack-form input[type="text"],
.stack-form input[type="datetime-local"],
.stack-form select { width: 100%; padding: 0.6rem; font-size: 1rem; border: 1px solid #ccc; border-radius: 6px; }
.stack-form .update-button { display: block; margin: 1rem 0 0; width: 100%; max-width: none; }
.danger-btn { display: block; width: 100%; margin-top: 1rem; background-color: #d9534f; color: #fff; }
.danger-btn:hover { background-color: #c0403c; }

.add-shift { margin-top: 1rem; background: #fff; border-radius: 8px; padding: 0.75rem 1rem; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.add-shift summary { cursor: pointer; font-weight: bold; color: #2c7fb8; }

@media (max-width: 480px) {
    .clock-elapsed { font-size: 2.2rem; }
    .week-link { padding: 0.4rem 0.5rem; font-size: 0.9rem; }
}

.clock-card form { background: none; box-shadow: none; padding: 0; margin: 0 auto; }

@media (max-width: 480px) {
    .hours-table th, .hours-table td { padding: 0.5rem 0.4rem; font-size: 0.9rem; white-space: normal; }
    .hours-table .hide-sm { display: none; }
    .hours-table .dec { display: block; }
    .week-label { font-size: 0.9rem; }
}

/* The inventory spreadsheet table forces 800px and a sticky first column; the time tables are small */
.hours-table, .activity-table { min-width: 0; }
.hours-table td:first-child, .hours-table th:first-child,
.activity-table td:first-child, .activity-table th:first-child { position: static; }
.activity-table td { white-space: normal; }
.activity-table td.nowrap { white-space: nowrap; }
.hours-table .row-actions { display: table-cell; }

.who-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.who-list li { background: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); padding: 0.85rem 1rem; }
.who-list li.row-warn { background: #fff4d6; }
.who-main { font-size: 1.1rem; }
.who-where { background: #eaf3fb; color: #2c7fb8; border-radius: 4px; padding: 0 0.5rem; font-size: 0.85rem; font-weight: bold; }
.who-sub { color: #555; margin: 0.15rem 0 0.5rem; }
.row-actions form { background: none; box-shadow: none; padding: 0; }
