/* ============================================================
   TaxSrv Apps — app.css
   Brand colours: #243A5E (navy), #C6A75A (gold), #F2F2F2 (light), #FFFFFF (white)
   Fonts: DM Sans (body), DM Mono (code/data)
   ============================================================ */

/* ── CSS Variables ──────────────────────────────────────────────────────── */
:root {
    --navy:        #243A5E;
    --navy-dark:   #1a2d4a;
    --navy-light:  #2e4d7d;
    --gold:        #C6A75A;
    --gold-light:  #d4b97a;
    --gold-faint:  #f9f4ea;
    --light:       #F2F2F2;
    --white:       #FFFFFF;

    --text-primary:   #1a1a2e;
    --text-secondary: #5a6a7e;
    --text-muted:     #9aa5b4;

    --border:         #e2e8f0;
    --border-dark:    #cbd5e1;

    --success:   #2d7a4f;
    --success-bg:#edf7f1;
    --error:     #c0392b;
    --error-bg:  #fdf2f2;
    --warning:   #b7791f;
    --warning-bg:#fffbeb;
    --info:      #2563eb;
    --info-bg:   #eff6ff;

    --radius-sm:  4px;
    --radius:     8px;
    --radius-lg:  12px;

    --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
    --shadow:     0 2px 8px rgba(0,0,0,.10);
    --shadow-lg:  0 4px 20px rgba(0,0,0,.12);

    --nav-height: 64px;
    --content-max: 1200px;

    --font-body: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'DM Mono', 'Courier New', monospace;
}

/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
    font-family: var(--font-body);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

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

/* ── Navigation Header ──────────────────────────────────────────────────── */
.nav-header {
    background: var(--navy);
    height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.nav-logo svg {
    height: 36px;
    width: auto;
    display: block;
}

.nav-tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.nav-tab {
    color: rgba(242,242,242,0.75);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: color .15s, background .15s;
    letter-spacing: 0.01em;
}

.nav-tab:hover {
    color: var(--light);
    background: rgba(255,255,255,.08);
    text-decoration: none;
}

.nav-tab--active {
    color: var(--gold);
    background: rgba(198,167,90,.12);
}

.nav-tab--active:hover {
    color: var(--gold-light);
    background: rgba(198,167,90,.18);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    flex-shrink: 0;
}

.nav-user__name {
    color: var(--light);
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-user__role {
    color: var(--gold);
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(198,167,90,.15);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
}

.nav-user__link {
    color: rgba(242,242,242,.6);
    font-size: 1.1rem;
    text-decoration: none;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: color .15s;
    line-height: 1;
}

.nav-user__link:hover {
    color: var(--light);
    text-decoration: none;
}

.nav-user__link--logout:hover { color: #fc8181; }

/* ── Main Content ───────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: var(--content-max);
    margin: 0 auto;
    width: 100%;
}

/* ── Page Header ────────────────────────────────────────────────────────── */
.page-header {
    margin-bottom: 2rem;
}

.page-header__title {
    font-size: 1.625rem;
    font-weight: 600;
    color: var(--navy);
    line-height: 1.2;
}

.page-header__sub {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-top: 0.25rem;
}

.page-header__actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card__header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy);
}

.card__body {
    padding: 1.5rem;
}

.card__footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: #fafafa;
}

/* ── Grid / Layout ──────────────────────────────────────────────────────── */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .grid--3, .grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
}

/* ── Stat Cards ─────────────────────────────────────────────────────────── */
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.stat-card__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-card__value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--navy);
    line-height: 1.2;
    margin-top: 0.375rem;
}

.stat-card__meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

.stat-card--gold .stat-card__value { color: var(--gold); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.btn--primary {
    background: var(--navy);
    color: var(--white);
    border-color: var(--navy);
}
.btn--primary:hover {
    background: var(--navy-dark);
    border-color: var(--navy-dark);
    color: var(--white);
    text-decoration: none;
}

.btn--gold {
    background: var(--gold);
    color: var(--white);
    border-color: var(--gold);
}
.btn--gold:hover {
    background: var(--gold-light);
    border-color: var(--gold-light);
    color: var(--white);
    text-decoration: none;
}

.btn--outline {
    background: transparent;
    color: var(--navy);
    border-color: var(--border-dark);
}
.btn--outline:hover {
    background: var(--light);
    border-color: var(--navy);
    text-decoration: none;
}

.btn--danger {
    background: var(--error);
    color: var(--white);
    border-color: var(--error);
}
.btn--danger:hover {
    background: #a93226;
    text-decoration: none;
    color: var(--white);
}

.btn--sm { padding: 0.3125rem 0.75rem; font-size: 0.8125rem; }
.btn--lg { padding: 0.6875rem 1.5rem; font-size: 1rem; }
.btn[disabled], .btn--disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.form-label--required::after {
    content: ' *';
    color: var(--error);
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.875rem;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--white);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
}

.form-control:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(36,58,94,.12);
}

.form-control::placeholder { color: var(--text-muted); }

.form-control--error {
    border-color: var(--error);
}
.form-control--error:focus {
    box-shadow: 0 0 0 3px rgba(192,57,43,.12);
}

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%235a6a7e' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 12px; padding-right: 2.5rem; }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.8125rem;
    color: var(--error);
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead th {
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border);
    background: #fafafa;
    white-space: nowrap;
}

tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

tbody tr:hover { background: #f8fafc; }

.table--card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* ── Badges / Pills ─────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge--green   { background: var(--success-bg);  color: var(--success); }
.badge--red     { background: var(--error-bg);    color: var(--error); }
.badge--gold    { background: var(--gold-faint);  color: #8a6a1a; }
.badge--navy    { background: rgba(36,58,94,.1);  color: var(--navy); }
.badge--grey    { background: #f1f5f9;            color: var(--text-secondary); }

/* ── Flash messages ─────────────────────────────────────────────────────── */
.flash {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
    border-left: 4px solid currentColor;
}

.flash--success { background: var(--success-bg); color: var(--success); }
.flash--error   { background: var(--error-bg);   color: var(--error); }
.flash--warning { background: var(--warning-bg); color: var(--warning); }
.flash--info    { background: var(--info-bg);    color: var(--info); }

.flash__close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    color: inherit;
    opacity: 0.6;
    padding: 0;
    flex-shrink: 0;
}
.flash__close:hover { opacity: 1; }

/* ── Status toggles / checkboxes ────────────────────────────────────────── */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9375rem;
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--navy);
}

/* ── Empty states ───────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state__icon { font-size: 2.5rem; margin-bottom: 1rem; }
.empty-state__title { font-size: 1.125rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state__text  { font-size: 0.9375rem; }

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo svg { height: 44px; width: auto; display: inline-block; }

.login-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--navy);
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ── Site footer ────────────────────────────────────────────────────────── */
.site-footer {
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
    margin-top: auto;
}

.site-footer__inner {
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-footer__copy {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ── Utility classes ────────────────────────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-small   { font-size: 0.8125rem; }
.text-navy    { color: var(--navy); }
.text-gold    { color: var(--gold); }
.text-error   { color: var(--error); }
.text-success { color: var(--success); }
.mono         { font-family: var(--font-mono); }
.fw-600       { font-weight: 600; }
.mt-0  { margin-top: 0; }
.mt-1  { margin-top: 0.5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mt-4  { margin-top: 2rem; }
.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: 0.5rem; }
.mb-2  { margin-bottom: 1rem; }
.mb-3  { margin-bottom: 1.5rem; }
.mb-4  { margin-bottom: 2rem; }
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1         { gap: 0.5rem; }
.gap-2         { gap: 1rem; }
.gap-3         { gap: 1.5rem; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    :root { --nav-height: 56px; }

    .nav-inner { padding: 0 1rem; gap: 1rem; }
    .nav-logo svg { height: 28px; }
    .nav-user__name { display: none; }
    .nav-user__role { display: none; }

    .main-content { padding: 1.25rem 1rem; }

    .page-header__title { font-size: 1.375rem; }

    thead th { padding: 0.625rem 0.75rem; }
    tbody td { padding: 0.75rem; }
}
