/*
 * HCI Supply customer portal. Plain CSS, no build step, no JavaScript needed.
 * Colors, type and radii follow the HCI Supply design system (tokens noted beside each value).
 */

/* Roboto, served from this site (OFL, see fonts/Roboto-LICENSE.txt). Latin only to keep it small. */
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/roboto-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/roboto-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/roboto-latin-700-normal.woff2") format("woff2"); }

:root {
    --brand: #0f7e3e;          /* brand-green: buttons, links, header */
    --brand-dark: #0b5f2f;     /* brand-green-dark: hover / pressed / active */
    --brand-tint: #e3f1e8;     /* brand-green-tint: badges, callouts, selected */
    --text: #333333;           /* text-body */
    --ink: #000000;            /* ink: headings */
    --muted: #626262;          /* secondary text (derived; 5.4:1 on --bg) */
    --border: #d0d0d0;         /* border */
    --bg: #f5f6f5;             /* page background (derived neutral; cards use --surface) */
    --surface: #ffffff;        /* surface */
    --surface-nav: #2e2c36;    /* surface-nav: staff admin bar */
    --surface-footer: #0a0a0a; /* surface-footer */
    --text-on-dark: #aeaeae;   /* text-on-dark */
    --danger: #b42318;
    --danger-bg: #fdecea;
    --warning: #8a5a00;
    --warning-bg: #fff4d6;
    --success: var(--brand-dark);
    --success-bg: var(--brand-tint);
    --info-bg: var(--brand-tint);
    --focus: #7cc39a;          /* focus ring (derived from brand-green) */
    --radius: 8px;             /* radius-md: cards, panels */
    --radius-sm: 4px;          /* radius-sm: inputs, chips */
    --radius-full: 999px;      /* radius-full: buttons, pills */
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    /* Keep the footer at the bottom of the window on short pages. */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body > main { flex: 1 0 auto; width: 100%; }

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .75rem; color: var(--ink); font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 1rem; top: 1rem; background: #fff; padding: .5rem 1rem; z-index: 10; }

/* Header and navigation */

.site-header { background: var(--brand); color: #fff; }
.site-header .inner {
    max-width: 1200px; margin: 0 auto; padding: .6rem 1rem;
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
}
.site-header a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0; padding: 0; list-style: none; flex: 1; }
.nav a { display: block; padding: .35rem .75rem; border-radius: var(--radius-full); font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .15); }
.nav a[aria-current="page"] { background: var(--brand-dark); }
.user-menu { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.user-menu form { margin: 0; }
.link-button {
    background: none; border: 0; padding: 0; color: inherit; font: inherit;
    text-decoration: underline; cursor: pointer;
}
/* Shown while staff use "customer view"; hard to miss so nobody forgets they're in it. */
.customer-view-bar { background: var(--warning-bg); color: var(--warning); border-bottom: 2px solid #e0b84a; font-size: .9rem; }
.customer-view-bar .inner {
    max-width: 1200px; margin: 0 auto; padding: .45rem 1rem;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
}
.customer-view-bar form { margin: 0; }
body.fill-page .customer-view-bar { flex: none; }

.subnav { background: var(--surface-nav); }
.subnav .nav { max-width: 1200px; margin: 0 auto; padding: .25rem 1rem; font-size: .9rem; }
.subnav .nav a { color: #fff; text-decoration: none; }
.subnav .nav a[aria-current="page"] { background: var(--brand); }

/* Layout */

main { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.25rem; margin-bottom: 1.25rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-2 { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-2 > .card { margin-bottom: 0; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; }
.stat.alert .value { color: var(--danger); }

.auth-box { max-width: 420px; margin: 2.5rem auto; }
.auth-box .brand-title { text-align: center; color: var(--brand); margin-bottom: 1.25rem; }

/* Tables */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: .5rem .65rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; background: #f6f7f6; }
th a { color: inherit; text-decoration: none; }
tbody tr:hover { background: #f6f7f6; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
table.compact th, table.compact td { padding: .35rem .5rem; }
.empty { color: var(--muted); padding: 1rem 0; }

dl.details { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1.25rem; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; }

/* Badges */

.badge {
    display: inline-block; padding: .1rem .5rem; border-radius: var(--radius-full); font-size: .8rem; font-weight: 600;
    background: #ececec; color: var(--text); white-space: nowrap;
}
.badge.paid { background: var(--success-bg); color: var(--success); }
.badge.open { background: var(--info-bg); color: var(--brand-dark); }
.badge.partial { background: var(--warning-bg); color: var(--warning); }
.badge.overdue { background: var(--danger-bg); color: var(--danger); }
.badge.void { background: #eee; color: #666; text-decoration: line-through; }

/* Forms */

form.inline { display: inline; }
.form-row { margin-bottom: .9rem; }
.form-row label { display: block; font-weight: 600; margin-bottom: .25rem; }
.form-row .hint { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="search"],
input[type="tel"], input[type="number"], input[type="file"], select, textarea {
    width: 100%; padding: .45rem .6rem; font: inherit; color: inherit;
    border: 1px solid #b5b5b5; border-radius: var(--radius-sm); background: #fff;
}
input[type="file"] { padding: .35rem; }
textarea { min-height: 6rem; }
input:focus, select:focus, textarea:focus, button:focus, .button:focus { outline: 3px solid var(--focus); outline-offset: 1px; }
.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 400 !important; }
.field-error { color: var(--danger); font-size: .85rem; margin-top: .2rem; }

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.filters .form-row { margin: 0; min-width: 140px; flex: 1 1 140px; }
.filters .form-row.wide { flex: 2 1 220px; }

.button, button {
    display: inline-block; padding: .45rem 1rem; font: inherit; font-weight: 600; line-height: 1.4;
    color: #fff; background: var(--brand); border: 1px solid var(--brand); border-radius: var(--radius-full);
    cursor: pointer; text-decoration: none; white-space: nowrap;
}
.button:hover, button:hover { background: var(--brand-dark); color: #fff; }
.button.secondary, button.secondary { background: #fff; color: var(--brand); }
.button.secondary:hover, button.secondary:hover { background: var(--info-bg); }
.button.danger, button.danger { background: var(--danger); border-color: var(--danger); }
.button.small, button.small { padding: .2rem .6rem; font-size: .85rem; }
.button.block, button.block { display: block; width: 100%; text-align: center; }
.button.microsoft { background: #2f2f2f; border-color: #2f2f2f; }

/* Messages */

.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash.success { background: var(--success-bg); border-color: #a9d4b8; color: var(--success); }
.flash.error { background: var(--danger-bg); border-color: #f4b8b2; color: var(--danger); }
.flash.info { background: var(--info-bg); border-color: #a9d4b8; color: var(--brand-dark); }
.flash ul { margin: .25rem 0 0; padding-left: 1.25rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: .5rem; }
.divider { text-align: center; color: var(--muted); margin: 1.25rem 0; font-size: .9rem; }

/* Project file viewer */

.viewer { display: block; width: 100%; height: 70vh; min-height: 360px; background: #eef0ee; border: 1px solid var(--border); border-radius: var(--radius); }
.viewer-image { object-fit: contain; background: #fff; }

/* Full-window pages (the file viewer): header on top, viewer takes every remaining pixel, no page scroll. */
body.fill-page { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
body.fill-page .site-header, body.fill-page .subnav { flex: none; }
body.fill-page main { flex: 1; min-height: 0; width: 100%; max-width: none; display: flex; flex-direction: column; gap: .5rem; padding: .6rem 1rem; }
body.fill-page main > * { flex: none; margin: 0; }
body.fill-page .viewer { flex: 1 1 auto; height: auto; min-height: 240px; }
body.fill-page .site-footer { display: none; }
.viewer-head h1 { font-size: 1.2rem; }
.viewer-head p { font-size: .9rem; }

/* Viewer with an optional specs panel on the right (below it on narrow screens). */
.viewer-layout { display: flex; gap: 1rem; align-items: stretch; }
.viewer-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .4rem; }
.viewer-specs { flex: none; width: 320px; margin: 0; overflow-y: auto; }
body.fill-page main > .viewer-layout { flex: 1 1 auto; min-height: 0; }

@media (max-width: 800px) {
    .viewer-layout { flex-direction: column; }
    .viewer-specs { width: auto; overflow: visible; }
    /* Let the page scroll so the specs below the viewer can be read. */
    body.fill-page { height: auto; overflow: visible; }
    body.fill-page .viewer { flex: none; height: 65vh; }
}

/* Specs tables */
.specs > h2 { font-size: 1.05rem; margin-bottom: .25rem; }
.specs + .specs { margin-top: 1.25rem; }
.specs h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .9rem 0 .25rem; }
.specs-table th { width: 55%; background: none; color: var(--text); font-size: .9rem; font-weight: 600; text-transform: none; letter-spacing: 0; white-space: normal; }
.specs-table td { font-variant-numeric: tabular-nums; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: .9rem; }
tr.highlight td { background: var(--brand-tint); }
details > summary { cursor: pointer; color: var(--brand); margin: .25rem 0 .75rem; }

.site-footer { text-align: center; color: var(--text-on-dark); background: var(--surface-footer); font-size: .85rem; padding: 1.25rem 1rem; }

/* Pagination */

.pagination { display: flex; flex-wrap: wrap; gap: .25rem; list-style: none; padding: 0; margin: 1rem 0 0; align-items: center; }
.pagination a, .pagination span {
    display: block; padding: .3rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: #fff; text-decoration: none;
}
.pagination .current span { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .disabled span { color: #8a8a8a; }
.pagination .summary { border: 0; background: none; color: var(--muted); }

@media (max-width: 640px) {
    body { font-size: 14px; }
    h1 { font-size: 1.35rem; }
    .card { padding: .85rem; }
    .user-menu { width: 100%; justify-content: space-between; }
    dl.details { grid-template-columns: 1fr; }
    dl.details dd { margin-bottom: .4rem; }
}

@media print {
    .site-header, .subnav, .site-footer, .no-print, .filters, .pagination { display: none !important; }
    body { background: #fff; }
    .card { border: 0; padding: 0; }
}
