/* ==========================================================================
   style.css — Base stylesheet
   Maroon, cream and gold theme. Every color, font and shadow comes from the
   :root variables below, so the whole system can be re-themed there.
   Every module page loads inside the Admin shell's iframe, so pages are
   fluid, never cause horizontal scroll, and keep their own scroll area.
   ========================================================================== */

/* 1. Design tokens
   ========================================================================== */
:root {
    /* Page and surfaces: warm cream */
    --color-bg:            #f8f1e5;
    --color-surface:       #ffffff;
    --color-surface-alt:   #fdf8f0;
    --color-border:        #eadfcd;
    --color-border-strong: #d8c5a8;
    --color-text:          #2e2022;
    --color-text-muted:    #6f5b58;
    --color-heading:       #4a0f19;

    /* Brand: maroon and gold */
    --color-maroon:        #7b1e2b;
    --color-maroon-dark:   #4a0f19;
    --color-maroon-light:  #a3364a;
    --color-gold:          #d4a017;
    --color-gold-dark:     #8a6508;
    --color-gold-soft:     #fbefc8;
    --color-cream:         #fbf3e4;

    /* Action colors */
    --color-primary:        #7b1e2b;
    --color-primary-hover:  #5e1520;
    --color-primary-text:   #ffffff;
    --color-secondary:      #ffffff;
    --color-secondary-hover:#fbf1e1;
    --color-secondary-text: #7b1e2b;
    --color-search:         #d4a017;   /* Search / Update / Add Item: gold */
    --color-search-hover:   #b8870c;
    --color-search-text:    #3a1206;
    --color-danger:         #c0392b;
    --color-danger-hover:   #9e2b20;
    --color-danger-text:    #ffffff;

    /* Feedback */
    --color-success-bg:   #eaf6ee;
    --color-success-text: #1e6b3a;
    --color-error-bg:     #fdeeee;
    --color-error-text:   #b3261e;
    --color-focus:        rgba(212, 160, 23, 0.40);   /* gold focus ring */

    /* Book theme: a faint outlined book pattern for page backgrounds (tiny inline SVG),
       and the bookshelf drawing (assets/img/bookshelf.svg) for the login and home banners */
    --pattern-books: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%237b1e2b' stroke-opacity='.07' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 16h24a3 3 0 0 1 3 3v32H23a3 3 0 0 0-3 3z'/%3E%3Cpath d='M20 54a3 3 0 0 0 3 3h24'/%3E%3Cpath d='M27 26h12'/%3E%3Crect x='96' y='22' width='34' height='8' rx='2'/%3E%3Crect x='92' y='30' width='40' height='8' rx='2'/%3E%3Crect x='98' y='38' width='36' height='8' rx='2'/%3E%3Cpath d='M30 104c7-4 16-4 23 1v26c-7-5-16-5-23-1z'/%3E%3Cpath d='M53 105c7-5 16-5 23-1v26c-7-4-16-4-23 1z'/%3E%3Cg transform='rotate%2812 120 118%29'%3E%3Crect x='110' y='96' width='18' height='44' rx='2'/%3E%3Cpath d='M122 96v12l3-3 3 3V96'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    --bookshelf: url("../img/bookshelf.svg");

    /* Gradients */
    --gradient-maroon: linear-gradient(135deg, #5a1320 0%, #7b1e2b 55%, #9c2f42 100%);
    --gradient-gold:   linear-gradient(135deg, #e2b33a 0%, #d4a017 60%, #b8870c 100%);

    /* Admin shell */
    --header-bg:          var(--gradient-maroon);
    --sidebar-bg:         #3f0d16;
    --sidebar-text:       #f3e4d3;
    --sidebar-muted:      #c79d95;
    --sidebar-hover:      rgba(255, 255, 255, 0.08);
    --sidebar-active-bg:  rgba(212, 160, 23, 0.16);

    /* Tables */
    --table-head-bg:     #f6ead6;   /* light cream tint (also used for chips and icons) */
    --table-header-bg:   #7b1e2b;   /* maroon column headers */
    --table-header-text: #ffffff;
    --table-stripe-bg:   #fdf6ea;
    --table-hover-bg:    #fbefc8;   /* gold highlight */

    /* Typography (Google Fonts, with safe fallbacks when offline) */
    --font-sans:    "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-heading: "Poppins", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono:    "Consolas", "SFMono-Regular", Menlo, monospace;
    --fs-xs:   0.75rem;
    --fs-sm:   0.875rem;
    --fs-base: 0.9375rem;
    --fs-md:   1.0625rem;
    --fs-lg:   1.25rem;
    --fs-xl:   1.5rem;
    --lh-tight: 1.25;
    --lh-base:  1.55;

    /* Spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    /* Shape and depth (warm, soft shadows) */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(74, 15, 25, 0.08);
    --shadow-md: 0 2px 6px rgba(74, 15, 25, 0.06), 0 8px 20px rgba(74, 15, 25, 0.07);
    --shadow-lg: 0 16px 40px rgba(74, 15, 25, 0.22);
    --shadow-hover: 0 6px 14px rgba(74, 15, 25, 0.10), 0 14px 32px rgba(74, 15, 25, 0.10);

    /* Controls */
    --control-height: 38px;
    --transition: 0.18s ease;
}

/* 2. Reset and base
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    color: var(--color-text);
    background: var(--color-bg);
    overflow-x: hidden;          /* never scroll sideways inside the iframe */
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    margin: 0 0 var(--space-3);
    font-family: var(--font-heading);
    color: var(--color-heading);
    line-height: var(--lh-tight);
    font-weight: 600;
}
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }

p {
    margin: 0 0 var(--space-3);
}

a {
    color: var(--color-primary);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    display: block;
}

.text-muted  { color: var(--color-text-muted); }
.text-small  { font-size: var(--fs-sm); }
.text-center { text-align: center; }
.text-right  { text-align: right; }

/* 3. Page layout (for pages rendered inside the iframe)
   ========================================================================== */
.page {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-6);
}

/* Report pages with wide tables use the full iframe width */
.page.page-wide {
    max-width: none;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}
.page-header h1 {
    margin: 0;
    overflow-wrap: anywhere;     /* long titles wrap in a very narrow iframe */
}
.page-header .subtitle {
    margin: var(--space-1) 0 0;
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
}

/* 4. Cards
   ========================================================================== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-6);
    overflow: hidden;
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-alt);
}
.card-header h2,
.card-header h3 {
    margin: 0;
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-alt);
}

/* 5. Forms
   ========================================================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4) var(--space-6);
}
.form-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}
.form-group.span-2    { grid-column: span 2; }
.form-group.span-full { grid-column: 1 / -1; }

/* Label beside the input, for row-style layouts */
.form-row {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--color-text);
}
.required {
    color: var(--color-danger);
    margin-left: 2px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="search"],
select,
textarea {
    width: 100%;
    height: var(--control-height);
    padding: 0 var(--space-3);
    font-family: inherit;
    font-size: var(--fs-base);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

textarea {
    height: auto;
    min-height: 96px;
    padding: var(--space-2) var(--space-3);
    resize: vertical;
}

select {
    cursor: pointer;
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-muted);
    opacity: 0.8;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-focus);
}

input[readonly],
input:disabled,
select:disabled,
textarea:disabled {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.form-hint {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}

/* Field that failed validation */
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: var(--color-danger);
}
input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.15);
}
.form-error {
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--color-error-text);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-6);
    padding-top: var(--space-5);
    border-top: 1px solid var(--color-border);
}

/* Search bar above report tables */
.search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}
.search-bar input[type="text"],
.search-bar input[type="search"] {
    flex: 1 1 260px;
}
.search-bar select {
    flex: 0 1 200px;
}

/* Labeled filter row for report pages: Search By | Keyword | buttons */
.filter-row {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) auto;
    align-items: end;
    gap: var(--space-4);
}
.filter-row .filter-buttons {
    display: flex;
    gap: var(--space-3);
}
.filter-row .btn {
    height: var(--control-height);   /* line up with the inputs */
}

/* Two grids stacked inside one section */
.form-grid + .form-grid {
    margin-top: var(--space-4);
}

/* Input with a button attached on its right (e.g. Employee Code + Search) */
.input-group {
    display: flex;
    gap: var(--space-2);
}
.input-group input {
    flex: 1 1 auto;
    min-width: 0;
}
.input-group .btn {
    flex: 0 0 auto;
}

/* Read-only computed results (e.g. Gross Pay, Net Pay) */
input.output-field {
    height: 48px;
    font-size: var(--fs-md);
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--color-heading);
}
input.output-field.output-total {
    color: var(--color-primary-text);
    background: var(--color-primary);
    border-color: var(--color-primary);
}
input.output-field.output-total::placeholder {
    color: var(--color-primary-text);
}

/* Groups of fields inside one form card */
.form-section + .form-section {
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px dashed var(--color-border);
}
.form-section-title {
    margin: 0 0 var(--space-4);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

/* 6. Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: var(--control-height);
    padding: 0 var(--space-5);
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition), border-color var(--transition),
                box-shadow var(--transition), transform var(--transition);
}
.btn:hover {
    text-decoration: none;
}
.btn:active {
    transform: translateY(1px);
}
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-focus);
}
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* Primary: Save / Add (largest, most prominent) */
.btn-primary {
    min-width: 120px;
    height: 42px;
    padding: 0 var(--space-6);
    font-size: var(--fs-base);
    color: var(--color-primary-text);
    background: var(--color-primary);
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

/* Secondary: Cancel (same height as primary, outlined) */
.btn-secondary {
    min-width: 110px;
    height: 42px;
    padding: 0 var(--space-6);
    font-size: var(--fs-base);
    color: var(--color-secondary-text);
    background: var(--color-secondary);
    border-color: var(--color-border-strong);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--color-secondary-hover);
}

/* Search: matches input height so it sits flush beside the search field */
.btn-search {
    min-width: 96px;
    height: var(--control-height);
    padding: 0 var(--space-4);
    color: var(--color-search-text);
    background: var(--color-search);
}
.btn-search:hover:not(:disabled) {
    background: var(--color-search-hover);
}

/* Delete: compact, used on the User Account page and inside table rows */
.btn-delete {
    min-width: 84px;
    height: 34px;
    padding: 0 var(--space-4);
    font-size: var(--fs-sm);
    color: var(--color-danger-text);
    background: var(--color-danger);
}
.btn-delete:hover:not(:disabled) {
    background: var(--color-danger-hover);
}
/* In a form's bottom button row, Delete matches Save / Cancel */
.form-actions .btn-delete,
.modal-actions .btn-delete {
    min-width: 110px;
    height: 42px;
    padding: 0 var(--space-6);
    font-size: var(--fs-base);
}
/* Pushes the Delete button to the left, away from Save */
.form-actions .push-left {
    margin-right: auto;
}
table .btn-delete {
    min-width: 0;
    height: 28px;
    padding: 0 var(--space-3);
    font-size: var(--fs-xs);
}

/* Compute: outlined dark button, same size as Save / Cancel */
.btn-compute {
    min-width: 110px;
    height: 42px;
    padding: 0 var(--space-6);
    font-size: var(--fs-base);
    color: var(--color-primary);
    background: var(--color-surface);
    border-color: var(--color-primary);
}
.btn-compute:hover:not(:disabled) {
    background: var(--color-secondary-hover);
}

.btn-block {
    width: 100%;
}

/* 7. Data tables
   ========================================================================== */
.table-container {
    width: 100%;
    max-height: 65vh;            /* table scrolls inside itself, header stays put */
    overflow: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.card-body > .table-container:only-child {
    margin: 0;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-sm);
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: var(--space-3);
    text-align: left;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--table-header-text);
    white-space: nowrap;
    background: var(--table-header-bg);
    border-bottom: 3px solid var(--color-gold);
}

.data-table tbody td {
    padding: var(--space-3);
    vertical-align: middle;
    white-space: nowrap;              /* short values stay on one line */
    border-bottom: 1px solid var(--color-border);
}
.data-table td.wrap {
    white-space: normal;              /* long text (e.g. address) wraps instead */
    min-width: 180px;
    max-width: 260px;
}

.table-meta {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
}

.data-table tbody tr:nth-child(even) td {
    background: var(--table-stripe-bg);
}
.data-table tbody tr:hover td {
    background: var(--table-hover-bg);
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table td.num,
.data-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table tfoot td {
    position: sticky;
    bottom: 0;
    padding: var(--space-3) var(--space-4);
    font-weight: 700;
    background: var(--table-head-bg);
    border-top: 1px solid var(--color-border-strong);
}

.table-empty {
    padding: var(--space-10) var(--space-4);
    text-align: center;
    color: var(--color-text-muted);
}

/* 8. Modal pop-up (confirmation dialogs)
   Show with: element.classList.add('is-open')
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(43, 10, 16, 0.55);
}
.modal-overlay.is-open {
    display: flex;
    animation: modal-fade 0.15s ease-out;
}

.modal {
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 2 * var(--space-4));
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modal-pop 0.18s ease-out;
}

.modal-header {
    padding: var(--space-5) var(--space-6) 0;
}
.modal-header h3 {
    margin: 0;
}

.modal-body {
    padding: var(--space-4) var(--space-6);
    color: var(--color-text-muted);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6) var(--space-5);
}

@keyframes modal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes modal-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

/* 9. Alerts / status messages
   ========================================================================== */
.alert {
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-5);
    font-size: var(--fs-sm);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
}
.alert-success {
    color: var(--color-success-text);
    background: var(--color-success-bg);
    border-color: currentColor;
}
.alert-error {
    color: var(--color-error-text);
    background: var(--color-error-bg);
    border-color: currentColor;
}

/* 10. Login page
   ========================================================================== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    background: var(--color-bg);
}

.login-card {
    width: 100%;
    max-width: 420px;
    margin: 0;
    box-shadow: var(--shadow-lg);
}

.login-card .card-header {
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-8) var(--space-6) var(--space-6);
    text-align: center;
    color: var(--color-primary-text);
    background: var(--color-primary);
    border-bottom: none;
}
.login-card .card-header h1 {
    margin: 0;
    font-size: var(--fs-lg);
    color: inherit;
}
.login-card .card-header p {
    margin: 0;
    font-size: var(--fs-sm);
    opacity: 0.8;
}

.login-card .card-body {
    padding: var(--space-8) var(--space-8) var(--space-6);
}
.login-card .form-group {
    margin-bottom: var(--space-5);
}
.login-card .btn-primary {
    margin-top: var(--space-2);
}

.login-footer {
    padding: var(--space-4) var(--space-6);
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-alt);
}

/* Password box with the show/hide button inside it */
.password-field {
    position: relative;
}
.password-field input {
    padding-right: 72px;
}
.password-toggle {
    position: absolute;
    top: 50%;
    right: var(--space-2);
    transform: translateY(-50%);
    height: 28px;
    padding: 0 var(--space-3);
    font-family: inherit;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.password-toggle:hover {
    color: var(--color-text);
    background: var(--color-secondary-hover);
}
.password-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-focus);
}

.alert[hidden] {
    display: none;
}

/* 11. Admin shell (admin/admin.php)
   Header bar on top, sidebar on the left, iframe fills the rest.
   The page itself never scrolls; only the sidebar and the iframe do.
   ========================================================================== */
.admin-body {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header bar */
.admin-header {
    flex: 0 0 60px;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: 0 var(--space-5);
    color: var(--color-primary-text);
    background: var(--header-bg);
    border-bottom: 3px solid var(--color-gold);
    box-shadow: 0 4px 14px rgba(74, 15, 25, 0.25);
    z-index: 10;
}

.hamburger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 0 10px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition);
}
.hamburger span {
    display: block;
    height: 2px;
    background: var(--color-primary-text);
    border-radius: 2px;
}
.hamburger:hover {
    background: rgba(255, 255, 255, 0.12);
}
.hamburger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.portal-title {
    margin: 0;
    font-size: var(--fs-md);
    letter-spacing: 0.01em;
    font-weight: 600;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-user {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-left: auto;
    font-size: var(--fs-sm);
    white-space: nowrap;
}
.header-user .user-name {
    font-weight: 600;
}
.logout-link {
    padding: var(--space-2) var(--space-4);
    font-weight: 600;
    color: var(--color-primary-text);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition);
}
.logout-link:hover {
    text-decoration: none;
    background: rgba(255, 255, 255, 0.12);
}

/* Sidebar + iframe area */
.admin-main {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;          /* lets the children scroll instead of the page */
}

.sidebar {
    flex: 0 0 250px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: var(--space-4) var(--space-3);
    white-space: nowrap;    /* labels don't wrap while the sidebar animates */
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(0, 0, 0, 0.25);
    transition: flex-basis 0.25s ease, padding 0.25s ease,
                opacity 0.2s ease, visibility 0.25s;
}

/* Collapsed by the hamburger button: the iframe takes the freed space */
.admin-body.sidebar-collapsed .sidebar {
    flex-basis: 0;
    padding-left: 0;
    padding-right: 0;
    border-right-width: 0;
    opacity: 0;
    visibility: hidden;     /* links can't be tabbed to while hidden */
}

.nav-section {
    margin: var(--space-4) var(--space-3) var(--space-2);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
}
.nav-section:first-child {
    margin-top: 0;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-link {
    display: block;
    padding: var(--space-2) var(--space-3);
    margin-bottom: 2px;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition), color var(--transition),
                padding-left var(--transition);
}
.nav-link:hover {
    text-decoration: none;
    color: #ffffff;
    background: var(--sidebar-hover);
    padding-left: var(--space-4);
}
.nav-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-focus);
}
/* Active tab: soft gold glow with a gold line on the left */
.nav-link.active {
    font-weight: 600;
    color: #ffffff;
    background: var(--sidebar-active-bg);
    box-shadow: inset 4px 0 0 var(--color-gold);
}

.content-area {
    flex: 1 1 auto;
    min-width: 0;           /* stops the iframe from pushing the page sideways */
    display: flex;
    background: var(--color-bg);
}
.content-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

/* 12. Home dashboard (admin/home.php)
   ========================================================================== */
.home {
    max-width: 1000px;
    margin: 0 auto;
    padding: var(--space-10) var(--space-6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-8);
}

/* Top: badge, title, subtitle */
.home-hero {
    text-align: center;
}
.home-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: var(--space-4);
    color: var(--color-primary-text);
    background: var(--color-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}
.home-badge svg {
    width: 32px;
    height: 32px;
}
.home-title {
    margin: 0 0 var(--space-2);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.home-subtitle {
    margin: 0;
    font-size: var(--fs-base);
    color: var(--color-text-muted);
}

/* Middle: greeting + clock */
.greeting-card {
    width: 100%;
    max-width: 520px;
    margin: 0;
    text-align: center;
}
.greeting-card .card-body {
    padding: var(--space-8) var(--space-6);
}
.greeting-label {
    margin: 0 0 var(--space-3);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--color-text-muted);
}
.digital-clock {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 3.25rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;   /* digits don't jump as they change */
    color: var(--color-heading);
}
.digital-clock .clock-period {
    margin-left: var(--space-2);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text-muted);
}
.today-date {
    margin: var(--space-3) 0 0;
    font-size: var(--fs-md);
    color: var(--color-text-muted);
}

/* Bottom: summary cards */
.summary-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-5);
}
.summary-card {
    margin: 0;
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.summary-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--color-primary);
    background: var(--table-head-bg);
    border-radius: var(--radius-md);
}
.summary-icon svg {
    width: 20px;
    height: 20px;
}
.summary-label {
    margin: 0;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--color-text-muted);
}
.summary-value {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--color-heading);
}

@media (max-width: 900px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 480px) {
    .summary-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .digital-clock {
        font-size: 2.25rem;
    }
}
/* Very narrow iframe (sidebar open on a phone) */
@media (max-width: 360px) {
    .home {
        padding: var(--space-6) var(--space-3);
    }
    .home-title {
        font-size: 1.25rem;
        overflow-wrap: anywhere;
    }
    .greeting-card .card-body {
        padding: var(--space-6) var(--space-3);
    }
    .digital-clock {
        font-size: 1.45rem;
    }
    .digital-clock .clock-period {
        display: block;             /* AM/PM goes under the time */
        margin: var(--space-1) 0 0;
        font-size: 1rem;
    }
}

/* 13. Point of Sale (pos/pos.php)
   ========================================================================== */
/* Cashier and date shown on the right of the page header */
.pos-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}
.pos-meta-item {
    padding: var(--space-2) var(--space-4);
    font-size: var(--fs-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.pos-meta-item span {
    display: block;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.pos-meta-item strong {
    color: var(--color-heading);
}

/* Two columns: item entry + cart on the left, checkout on the right */
.pos-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr);
    gap: var(--space-6);
    align-items: start;
}
.pos-layout > .card {
    margin-bottom: 0;
}

/* A form-group that only holds a button, lined up with the inputs beside it */
.form-group.align-end {
    justify-content: flex-end;
}

.cart-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: var(--space-6) 0 var(--space-3);
}
.cart-title h3 {
    margin: 0;
}
.cart-table {
    max-height: 320px;
}
/* Narrower cells so the 6-column cart fits the left column */
.cart-table .data-table th,
.cart-table .data-table td {
    padding-left: var(--space-2);
    padding-right: var(--space-2);
}
.cart-table .data-table td.wrap {
    min-width: 96px;
}

/* Checkout column */
.checkout-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* Discount type radio buttons shown as selectable tiles */
.radio-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    border: 0;
}
.radio-group legend {
    margin-bottom: var(--space-1);
    padding: 0;
    font-size: var(--fs-sm);
    font-weight: 600;
}
.radio-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--fs-sm);
    font-weight: 500;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition), background-color var(--transition);
}
.radio-option:hover {
    background: var(--color-secondary-hover);
}
.radio-option input {
    margin: 0;
    accent-color: var(--color-primary);
}
.radio-option:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--table-head-bg);
}
.radio-option .rate {
    margin-left: auto;
    color: var(--color-text-muted);
}

@media (max-width: 1000px) {
    .pos-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* 14. Point of Sale: product picture grid (pos/pos.php)
   ========================================================================== */
/* Left column of the POS: Products card stacked above Item Entry */
.pos-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    min-width: 0;
}
.pos-stack > .card {
    margin-bottom: 0;
}

/* Search box + category filter */
.product-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

/* The grid scrolls inside its own box, so the page never grows sideways */
.product-grid-box {
    max-height: 460px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: var(--space-3);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: var(--space-3);
}

/* One book card (a real <button>, so it works with the keyboard too) */
.product-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
    padding: var(--space-2);
    font-family: inherit;
    text-align: left;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    user-select: none;          /* double-click adds to the cart, not selects text */
    transition: transform var(--transition), box-shadow var(--transition),
                border-color var(--transition);
}
.product-card[hidden] {
    display: none;
}
.product-card:hover {
    transform: translateY(-3px);
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-md);
}
.product-card:active {
    transform: translateY(-1px);
}
.product-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-focus);
}
.product-card.is-selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary);
}
.product-card.is-selected:focus-visible {
    box-shadow: 0 0 0 2px var(--color-primary), 0 0 0 5px var(--color-focus);
}

/* Cover: book shape (2:3). The letter sits underneath and shows when there is no image */
.product-cover {
    position: relative;
    display: block;
    aspect-ratio: 2 / 3;
    margin-bottom: var(--space-1);
    overflow: hidden;
    background: var(--table-head-bg);
    border-radius: var(--radius-sm);
}
.product-cover img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.product-letter {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text-muted);
}

.product-category {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.product-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;      /* long titles stop at two lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: var(--fs-sm);
    font-weight: 700;
    line-height: var(--lh-tight);
    color: var(--color-heading);
    overflow-wrap: anywhere;
}
.product-price {
    margin-top: auto;
    font-size: var(--fs-sm);
    font-weight: 600;
}

.product-empty {
    margin: 0;
    padding: var(--space-8) var(--space-4);
    text-align: center;
    color: var(--color-text-muted);
}

@media (max-width: 640px) {
    .product-filters {
        grid-template-columns: minmax(0, 1fr);
    }
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
}

/* 15. Employee photo (employee_registration.php, employee_report.php)
   ========================================================================== */
/* Photo column on the left, personal details on the right */
.photo-layout {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: var(--space-6);
    align-items: start;
}
.photo-upload {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
}

/* Square box: the chosen picture, or a grey person icon */
.photo-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--color-surface-alt);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
}
.photo-box.is-invalid {
    border: 1px solid var(--color-danger);
}
.photo-box img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.photo-box img[hidden] {
    display: none;
}
.photo-icon {
    width: 62%;
    height: 62%;
    fill: var(--color-border-strong);
}
.photo-input {
    display: none;               /* opened by the "Choose Photo" button */
}
.photo-buttons {
    display: flex;
    gap: var(--space-2);
}
.photo-buttons .btn {
    flex: 1;
    min-width: 0;
    padding: 0 var(--space-2);
}
.photo-buttons .btn[hidden] {
    display: none;
}

/* Small photo in the Employee Report table */
.data-table td.photo-cell {
    padding-top: var(--space-1);
    padding-bottom: var(--space-1);
}
.avatar {
    display: block;
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}
.avatar-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-alt);
}
.avatar-empty svg {
    width: 26px;
    height: 26px;
    fill: var(--color-border-strong);
}

@media (max-width: 640px) {
    .photo-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .photo-upload {
        width: 100%;
        max-width: 170px;
        margin: 0 auto;
    }
}

/* 16. Payroll (payroll/payroll.php)
   ========================================================================== */
/* Smaller read-only photo beside the employee information */
.photo-layout.photo-layout-sm {
    grid-template-columns: 130px minmax(0, 1fr);
}

/* Income rows: name | rate per hour | hours | income per cut-off */
.income-rows {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
.income-row {
    display: grid;
    grid-template-columns: 170px repeat(3, minmax(0, 1fr));
    gap: var(--space-4) var(--space-6);
    align-items: end;
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}
.income-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}
.income-label {
    margin: 0;
    padding-bottom: 10px;            /* lines up with the text inside the inputs */
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--color-heading);
}
.income-label .text-muted {
    font-weight: 500;
}
.income-total .form-group {
    grid-column: 4;                  /* Gross Income sits under the income column */
}
.income-total input.output-field {
    font-weight: 700;
}
.deduction-note {
    margin: var(--space-3) 0 0;
}
/* Income boxes are as tall as the inputs beside them, so the row lines up */
.income-row input.output-field {
    height: var(--control-height);
    font-size: var(--fs-base);
}
/* Update matches the height of Save and the compute buttons */
.form-actions .btn-update {
    height: 42px;
    padding: 0 var(--space-6);
    font-size: var(--fs-base);
}

@media (max-width: 900px) {
    .income-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .income-label {
        grid-column: 1 / -1;
        padding-bottom: 0;
    }
    .income-total .form-group {
        grid-column: 3;
    }
}
@media (max-width: 640px) {
    .photo-layout.photo-layout-sm,
    .income-row {
        grid-template-columns: minmax(0, 1fr);
    }
    .income-total .form-group {
        grid-column: auto;
    }
}

/* 17. User accounts (users/user_account_report.php)
   ========================================================================== */
/* Active / Inactive label in the report */
.status-pill {
    display: inline-block;
    padding: 2px var(--space-2);
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--color-success-text);
    background: var(--color-success-bg);
    border-radius: 999px;
}
.status-pill.is-inactive {
    color: var(--color-text-muted);
    background: var(--table-head-bg);
}

/* 18. Point of Sale: cart editing, order details and keypad (pos/pos.php)
   ========================================================================== */
/* Text only for screen readers (e.g. the empty Remove column header) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Quantity box and Remove button inside the cart */
/* Headers and Category may wrap to two lines so the 7 columns fit */
.cart-table .data-table th {
    white-space: normal;
}
.cart-table .data-table td.cart-category {
    min-width: 72px;
}
.cart-table .cart-qty {
    width: 56px;
    height: 32px;
    padding: 0 var(--space-2);
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.cart-table td.cart-remove {
    width: 1%;
    white-space: nowrap;
}
table .btn-delete.btn-remove {
    width: 28px;
    padding: 0;
    font-size: var(--fs-sm);
}
.cart-error {
    margin: var(--space-2) 0 0;
}

/* Receipt-style summary under the payment fields */
.receipt {
    padding: var(--space-4);
    font-size: var(--fs-sm);
    font-variant-numeric: tabular-nums;
    background: var(--color-surface-alt);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
}
.receipt-title {
    margin-bottom: var(--space-2);
    padding-bottom: var(--space-2);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
    color: var(--color-text-muted);
    border-bottom: 1px dashed var(--color-border-strong);
}
.receipt-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 3px 0;
}
.receipt-row span {
    color: var(--color-text-muted);
}
.receipt-row strong {
    text-align: right;
    color: var(--color-heading);
    overflow-wrap: anywhere;
}
.receipt-total {
    margin: var(--space-2) calc(var(--space-2) * -1);
    padding: var(--space-2) var(--space-3);
    font-size: var(--fs-md);
    background: var(--color-primary);
    border-radius: var(--radius-sm);
}
.receipt-total span,
.receipt-total strong {
    font-weight: 700;
    color: var(--color-primary-text);
}
.receipt-change {
    margin-top: var(--space-1);
    padding-top: var(--space-2);
    font-size: var(--fs-md);
    border-top: 1px dashed var(--color-border-strong);
}
.receipt-change span {
    font-weight: 700;
    color: var(--color-heading);
}

/* New | Calculate Change on top, Update | Save below */
.pos-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-6);
    padding-top: var(--space-5);
    border-top: 1px solid var(--color-border);
}
.pos-actions .btn {
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0 var(--space-3);
    font-size: var(--fs-base);
}

/* On-screen keypad */
.keypad-target {
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.keypad {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-2);
}
.key {
    height: 52px;
    font-family: inherit;
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--color-heading);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition), transform var(--transition);
}
.key:hover {
    background: var(--color-secondary-hover);
}
.key:active {
    transform: translateY(1px);
}
.key:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-focus);
}
.key-op {
    background: var(--table-head-bg);
}
.key-clear {
    color: var(--color-danger);
}
.key-enter {
    grid-column: 1 / -1;
    height: 60px;
    font-size: var(--fs-md);
    letter-spacing: 0.08em;
    color: var(--color-primary-text);
    background: var(--color-primary);
    border-color: var(--color-primary);
}
.key-enter:hover {
    background: var(--color-primary-hover);
}
.keypad-help {
    margin: var(--space-3) 0 0;
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}
/* The box the keypad is typing into */
input.is-keypad-target:not(:focus):not(.is-invalid) {
    border-color: var(--color-primary);
}

/* 19. Theme accents: headings, hover lift, buttons, tables, badges, report summaries
   ========================================================================== */
::selection {
    color: var(--color-maroon-dark);
    background: var(--color-gold-soft);
}
html {
    scrollbar-color: var(--color-border-strong) transparent;
}
.sidebar {
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

/* Page title with a short gold underline */
.page-header h1 {
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--color-maroon);
}
.page-header h1::after {
    content: "";
    display: block;
    width: 56px;
    height: 4px;
    margin-top: var(--space-2);
    background: var(--gradient-gold);
    border-radius: 999px;
}

/* Cards: maroon top edge, cream header, soft shadow, small lift on hover */
.card {
    border-top: 3px solid var(--color-maroon);
    transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}
.card-header {
    background: linear-gradient(180deg, #fffaf3 0%, var(--color-cream) 100%);
}
.card-header h2 {
    color: var(--color-maroon);
}
.form-section-title {
    color: var(--color-maroon-light);
}
.modal {
    border-top: 4px solid var(--color-maroon);
}
.modal-header h3 {
    color: var(--color-maroon);
}

/* Buttons: maroon gradient Save, gold Search / Update, small lift on hover */
.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}
.btn-primary {
    background: var(--gradient-maroon);
}
.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
}
.btn-search {
    font-weight: 700;
}
.btn-secondary,
.btn-compute {
    border-color: var(--color-maroon);
}

/* Maroon highlights on computed totals */
input.output-field.output-total,
.receipt-total,
.key-enter,
.home-badge {
    background: var(--gradient-maroon);
}
.home-badge {
    box-shadow: 0 0 0 5px var(--color-gold-soft), var(--shadow-md);
}
.summary-icon {
    color: var(--color-maroon);
    background: var(--color-gold-soft);
}
.digital-clock {
    color: var(--color-maroon);
}

/* Login: cream page with soft maroon and gold glows, maroon card header */
.login-wrapper {
    background:
        radial-gradient(circle at 12% 12%, rgba(123, 30, 43, 0.16), transparent 42%),
        radial-gradient(circle at 88% 88%, rgba(212, 160, 23, 0.22), transparent 45%),
        var(--color-bg);
}
.login-card .card-header {
    background: var(--gradient-maroon);
    border-bottom: 3px solid var(--color-gold);
}

/* Tables: cream stripes, gold highlight with a gold edge on the hovered row */
.table-container {
    box-shadow: var(--shadow-sm);
}
.data-table tbody tr:hover td:first-child {
    box-shadow: inset 4px 0 0 var(--color-gold);
}
.data-table tbody tr.cart-empty:hover td,
.data-table tbody tr:hover td.table-empty {
    background: var(--color-surface);
    box-shadow: none;
}
.data-table td.num strong {
    color: var(--color-maroon);
}

/* Small colored labels (employee status, user type, discount type, ...) */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: 999px;
}
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.badge-maroon { color: #ffffff; background: var(--color-maroon); }
.badge-rose   { color: #8c2236; background: #fbe4e8; border-color: #f1c1cb; }
.badge-gold   { color: #6f4e05; background: #fbefc8; border-color: #edd58a; }
.badge-green  { color: #1e6b3a; background: #e3f4e8; border-color: #bde2c8; }
.badge-blue   { color: #1d4f91; background: #e4eefb; border-color: #c2d5f1; }
.badge-plum   { color: #5b2a86; background: #f0e6fa; border-color: #dac6ef; }
.badge-teal   { color: #0f6466; background: #e0f4f3; border-color: #b4e0dc; }
.badge-grey   { color: #5f5552; background: #f1ece7; border-color: #ddd2c8; }

/* Summary cards above each report */
.report-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}
.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin: 0;
    padding: var(--space-5);
}
.stat-card.is-gold  { border-top-color: var(--color-gold); }
.stat-card.is-green { border-top-color: #2f8a4c; }
.stat-card.is-plum  { border-top-color: #6f3a9c; }
.stat-icon {
    flex: 0 0 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    color: #ffffff;
    background: var(--gradient-maroon);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.stat-card.is-gold .stat-icon  { color: var(--color-maroon-dark); background: var(--gradient-gold); }
.stat-card.is-green .stat-icon { background: linear-gradient(135deg, #43a065 0%, #1e6b3a 100%); }
.stat-card.is-plum .stat-icon  { background: linear-gradient(135deg, #8d55bb 0%, #5b2a86 100%); }
.stat-icon svg {
    width: 24px;
    height: 24px;
}
.stat-text {
    min-width: 0;
}
.stat-label {
    margin: 0;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.stat-value {
    margin: 2px 0 0;
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    color: var(--color-heading);
    overflow-wrap: anywhere;
}
.stat-note {
    margin: 2px 0 0;
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}
@media (max-width: 1000px) {
    .report-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 520px) {
    .report-summary {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-3);
    }
    .stat-card {
        padding: var(--space-4);
    }
}

/* Very narrow iframe: icon above the numbers */
@media (max-width: 360px) {
    .stat-card {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }
    .stat-icon {
        flex-basis: auto;
        width: 40px;
        height: 40px;
    }
    .stat-icon svg {
        width: 20px;
        height: 20px;
    }
    .stat-value {
        font-size: 1.2rem;
    }
}

/* Phones: the hamburger and title keep their room in the header bar */
.hamburger {
    flex: 0 0 auto;
}
@media (max-width: 600px) {
    .admin-header {
        gap: var(--space-3);
        padding: 0 var(--space-3);
    }
    .header-user .welcome-text {
        display: none;
    }
    .portal-title {
        font-size: var(--fs-sm);
    }
}

/* People who prefer less motion get no lifts */
@media (prefers-reduced-motion: reduce) {
    .card:hover,
    .btn:hover:not(:disabled),
    .product-card:hover {
        transform: none;
    }
}

/* 20. Book theme backgrounds
   ========================================================================== */
/* Forms and reports: very faint outlined books behind the solid cards */
body {
    background-color: var(--color-bg);
    background-image: var(--pattern-books);
    background-size: 160px 160px;
}

/* Login: bookshelf behind the card, under a soft dark overlay */
.login-wrapper {
    background:
        radial-gradient(circle at 50% 50%, rgba(212, 160, 23, 0.16), transparent 55%),
        linear-gradient(180deg, rgba(30, 6, 10, 0.62) 0%, rgba(30, 6, 10, 0.78) 100%),
        var(--bookshelf) center / 960px 320px repeat,
        #2e0b12;
}
.login-card {
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

/* Home: bookshelf banner behind the title and the clock */
.home-banner {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-10) var(--space-6);
    background:
        linear-gradient(180deg, rgba(46, 11, 18, 0.78) 0%, rgba(74, 15, 25, 0.90) 100%),
        var(--bookshelf) center / 720px 240px repeat,
        #2e0b12;
    border-bottom: 4px solid var(--color-gold);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.home-banner .home-title {
    color: #ffffff;
}
.home-banner .home-subtitle {
    color: var(--color-cream);
    opacity: 0.9;
}
.home-banner .greeting-card {
    border-top-color: var(--color-gold);
}
@media (max-width: 480px) {
    .home-banner {
        padding: var(--space-6) var(--space-4);
    }
}
@media (max-width: 360px) {
    .home-banner {
        padding: var(--space-5) var(--space-2);
        border-radius: var(--radius-md);
    }
}

/* 21. Responsive (narrow iframe or small screens)
   ========================================================================== */
@media (max-width: 900px) {
    .filter-row {
        grid-template-columns: 180px minmax(0, 1fr);
    }
    .filter-row .filter-buttons {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
    .form-grid.cols-3,
    .form-grid.cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .page {
        padding: var(--space-4);
    }
    .card-header,
    .card-body,
    .card-footer {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }
    .form-grid,
    .form-grid.cols-3,
    .form-grid.cols-4 {
        grid-template-columns: minmax(0, 1fr);
    }
    .form-group.span-2 {
        grid-column: auto;
    }
    .filter-row {
        grid-template-columns: minmax(0, 1fr);
    }
    .filter-row .filter-buttons .btn {
        flex: 1;
    }
    .form-row {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-1);
    }
    .form-actions,
    .modal-actions {
        flex-direction: column-reverse;
    }
    .form-actions .btn,
    .modal-actions .btn {
        width: 100%;
    }
}
