/* ═══════════════════════════════════════════
   DESIGN SYSTEM — set once, inherit everywhere
   ═══════════════════════════════════════════ */
:root {
    /* ── Typography ── */
    --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono:  'SF Mono', 'Fira Code', 'Courier New', monospace;

    /* ── Layout ── */
    --sidebar-width:  240px;
    --topbar-height:  48px;
    --radius:         4px;
    --radius-lg:      8px;

    /* ── Spacing ── */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* ── Shadows ── */
    --shadow:    0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.10);

    /* ── Brand / Sidebar ── */
    --color-brand:        #0f172a;
    --color-accent:       #fbbf24;
    --color-primary:      #3b82f6;
    --color-primary-soft: #eff6ff;
    --color-link:         #2563eb;

    /* ── Surfaces ── */
    --color-bg:           #e3e8ef;
    --color-surface:      #ffffff;
    --color-input-edit-bg: #eef2f7;
    --color-border:  #d1d9e0;
    --color-hover:   #f0f4f8;

    /* ── Text ── */
    --color-text:       #111827;
    --color-text-muted: #4b5563;
    --color-text-light: #6b7280;

    /* ── Status ── */
    --color-success:      #059669;
    --color-success-soft: #ecfdf5;
    --color-success-border: rgba(16,185,129,0.25);
    --color-warning:      #d97706;
    --color-warning-soft: #fffbeb;
    --color-warning-border: rgba(245,158,11,0.25);
    --color-danger:       #dc2626;
    --color-danger-soft:  #fef2f2;
    --color-danger-border: rgba(239,68,68,0.25);
    --color-neutral:      #4b5563;
    --color-neutral-soft: #f8fafc;
    --color-neutral-border: rgba(203,213,225,0.25);

    /* ── Sidebar (Dark) ── */
    --sidebar-bg:        #1a2035;
    --sidebar-text:      #c8d0de;
    --sidebar-active-bg: rgba(255,255,255,0.08);
    --sidebar-active:    #ffffff;
    --sidebar-section:   #5a677d;
}

/* ── Global reset — font size set ONCE here ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
code, pre, kbd, samp { font-size: inherit; }

html {
    font-size: 13px;
    font-family: var(--font-sans);
}

body {
    font-family: inherit;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* All form controls inherit the global font */
input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
}

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

/* ── Tables ──
   td uses monospace — that is the ONLY font-family override allowed.
   All other table elements inherit from html/body.
*/
.table-wrapper { overflow-x: auto; background: var(--color-surface); }

table { width: 100%; border-collapse: collapse; text-align: left; }

th {
    padding: var(--space-sm) var(--space-md);
    font-family: inherit;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-hover);
    white-space: nowrap;
}

td {
    padding: 0.25rem var(--space-md);
    font-family: var(--font-mono);   /* API data = monospace */
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--color-hover); }

.th-sortable { cursor: pointer; user-select: none; }
.th-sortable:hover { color: var(--color-primary); }
.th-sortable::after { content: ' ⇅'; opacity: 0.4; }
.th-sortable.sort-asc::after  { content: ' ⇑'; opacity: 1; color: var(--color-primary); }
.th-sortable.sort-desc::after { content: ' ⇓'; opacity: 1; color: var(--color-primary); }

/* Column width hints */
.col-avatar  { width: 40px; padding-right: 0; }
.col-iov-id  { width: 140px; }
.col-dob     { width: 120px; }
.col-status  { width: 120px; }
.col-created { width: 120px; }
.col-hidden  { display: none !important; }

/* ── IOV-ID ── */
.iov-id {
    font-family: var(--font-mono);
    color: var(--color-primary);
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* iov-link is a <button> styled like text — used in the persons table */
.iov-link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}
.iov-link:hover  { text-decoration: underline; }
.iov-link:disabled { opacity: 0.5; cursor: wait; }

/* ── Avatar ── */
.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--color-surface);
    flex-shrink: 0;
    user-select: none;
    font-family: var(--font-sans);
    position: relative;
    overflow: hidden;
}

/* ── Avatar color palette ── */
.avatar-c0 { background: #3b82f6; }
.avatar-c1 { background: #8b5cf6; }
.avatar-c2 { background: #059669; }
.avatar-c3 { background: #d97706; }
.avatar-c4 { background: #dc2626; }
.avatar-c5 { background: #0891b2; }
.avatar-c6 { background: #7c3aed; }

/* Photo overlay — sits on top of the initials; removed by onerror if image fails */
.avatar-photo-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* ── Status badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px var(--space-sm);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 72px;
    text-align: center;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-active    { background: var(--color-success-soft); color: var(--color-success); border: 1px solid var(--color-success-border); }
.badge-pending   { background: var(--color-warning-soft); color: var(--color-warning); border: 1px solid var(--color-warning-border); }
.badge-suspended { background: var(--color-danger-soft);  color: var(--color-danger);  border: 1px solid var(--color-danger-border); }
.badge-archived  { background: var(--color-neutral-soft); color: var(--color-neutral); border: 1px solid var(--color-neutral-border); }

/* ── Page layout ── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}
.page-title {
    font-weight: 700;
    color: var(--color-text);
    font-family: var(--font-sans);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.update-badge {
    font-size: 0.6em;
    font-weight: 600;
    letter-spacing: 0.04em;
    background: var(--color-primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 20px;
    vertical-align: middle;
    opacity: 0.85;
}

/* ── Cards ── */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: var(--space-lg);
}
.card-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    font-family: var(--font-sans);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-body { padding: var(--space-md); }

/* ── Alerts ── */
.alert {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius);
    margin-bottom: var(--space-md);
    font-family: var(--font-sans);
    font-weight: 500;
}
.alert-success { background: var(--color-success-soft); color: #065f46; border: 1px solid var(--color-success-border); }
.alert-error   { background: var(--color-danger-soft);  color: #991b1b; border: 1px solid var(--color-danger-border); }
.alert-warning { background: var(--color-warning-soft); color: #92400e; border: 1px solid var(--color-warning-border); }

/* ── Stats ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}
.stat-card {
    background: var(--color-surface);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
    font-family: var(--font-sans);
}
.stat-value           { font-weight: 800; color: var(--color-primary); line-height: 1; margin-bottom: var(--space-sm); }
.stat-value.stat-active    { color: var(--color-success); }
.stat-value.stat-pending   { color: var(--color-warning); }
.stat-value.stat-suspended { color: var(--color-danger); }
.stat-value.stat-archived  { color: var(--color-text-muted); }
.stat-label { font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }

/* ── Pagination ── */
.pagination {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: var(--space-md);
    gap: var(--space-sm);
    border-top: 1px solid var(--color-border);
    font-family: var(--font-sans);
}
.pagination span { color: var(--color-text-muted); margin-right: var(--space-md); }
.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-weight: 600;
    font-family: var(--font-sans);
}
.pagination a.pagination-wide { width: auto; padding: 0 var(--space-md); white-space: nowrap; }
.pagination span.pagination-off { display: inline-flex; align-items: center; justify-content: center; height: 28px; padding: 0 var(--space-md); margin: 0; border: 1px solid var(--color-border); border-radius: var(--radius); color: var(--color-text-light); opacity: .55; font-weight: 600; white-space: nowrap; cursor: default; }
.pagination a:hover           { background: var(--color-hover); color: var(--color-primary); border-color: var(--color-border); }
.pagination a.active          { background: var(--color-primary); color: var(--color-surface); border-color: var(--color-primary); }

/* ── Utility ── */
.td-muted            { color: var(--color-text-light); }
.person-name-link    { font-weight: 600; color: var(--color-text); font-family: var(--font-mono); }
.person-name-link:hover { color: var(--color-primary); text-decoration: none; }
.empty-state         { padding: var(--space-xl); text-align: center; color: var(--color-text-muted); font-family: var(--font-sans); }
.result-count-footer { color: var(--color-text-muted); margin-top: var(--space-sm); font-family: var(--font-sans); }
.text-muted          { color: var(--color-text-muted); }
.ml-sm               { margin-left: var(--space-sm); }

/* ── Table actions column ── */
.col-actions { width: 60px; text-align: center; }
.col-center  { text-align: center; }

/* ── Icon buttons ── */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
}
.btn-icon:hover { background: var(--color-bg); color: var(--color-primary); border-color: var(--color-border); }
.btn-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon-sm { width: 28px; height: 28px; }
.btn-icon-sm svg { width: 14px; height: 14px; }
.btn-icon-md { width: 36px; height: 36px; }
.btn-icon-md svg { width: 18px; height: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-icon.spinning svg { animation: spin 0.6s linear; }

/* ── Dashboard modules ── */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-sm);
}
.module-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg);
    font-family: var(--font-sans);
}
.module-name { font-weight: 600; margin-bottom: var(--space-xs); }
.module-meta { color: var(--color-text-muted); display: flex; align-items: center; gap: var(--space-sm); }
.quick-links { display: flex; gap: var(--space-sm); }

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
}

/* Centered Box */
.login-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
}

.login-box {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-xl) 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}
.login-header h1 {
    font-weight: 800;
    color: var(--color-brand);
    margin-bottom: var(--space-xs);
}
.login-header p {
    color: var(--color-text-muted);
    font-weight: 500;
}

.login-footer {
    text-align: center;
    margin-top: var(--space-xl);
    color: var(--color-text-light);
}

/* ── Session inactivity timeout ── */

/* Blur applied to all page content except the overlay */
.session-blur .main-content,
.session-blur .topbar,
.session-blur .sidebar {
    filter: blur(5px);
    pointer-events: none;
    user-select: none;
    transition: filter 0.4s ease;
}

/* Full-screen overlay on top of blurred content */
.session-timeout-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    animation: session-fade-in 0.3s ease;
}
.session-timeout-overlay.is-visible {
    display: flex;
}

@keyframes session-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.session-timeout-box {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 48px rgba(0,0,0,0.3);
    padding: 2.5rem 3rem;
    max-width: 380px;
    width: 90%;
    text-align: center;
}

.session-timeout-icon {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: var(--space-md);
}

.session-timeout-title {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
}

.session-timeout-countdown {
    font-size: 3rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: var(--color-danger);
    line-height: 1;
    margin: var(--space-md) 0;
    transition: color 0.3s;
}

.session-timeout-hint {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* ── Settings page ── */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
    align-items: start;
}

.settings-account-info { margin-bottom: var(--space-sm); }

.settings-info-row {
    display: flex;
    gap: var(--space-md);
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--color-border);
}
.settings-info-row:last-child { border-bottom: none; }
.settings-info-label { width: 80px; color: var(--color-text-muted); font-weight: 600; flex-shrink: 0; }
.settings-info-value { font-family: var(--font-mono); color: var(--color-text); }

.settings-th {
    width: 40%;
    text-transform: none;
    font-weight: 600;
    color: var(--color-text-muted);
}

/* ── Help page ── */
.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.help-topic {
    padding: var(--space-lg);
}

.help-topic h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

.help-icon { font-size: 1.2em; }

.help-topic p { color: var(--color-text-muted); margin-bottom: var(--space-sm); line-height: 1.6; }
.help-topic ul { padding-left: 1.2rem; color: var(--color-text-muted); line-height: 1.7; }
.help-topic li { margin-bottom: 0.2rem; }
.help-topic strong { color: var(--color-text); }

.help-lang-btns { display: flex; gap: var(--space-sm); }

.faq-item {
    border-bottom: 1px solid var(--color-border);
}
.faq-item:last-child { border-bottom: none; }

.faq-q {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    font-weight: 600;
    color: var(--color-text);
    user-select: none;
}
.faq-q:hover { background: var(--color-hover); }

.faq-a {
    display: none;
    padding: 0 var(--space-md) var(--space-md);
    color: var(--color-text-muted);
    line-height: 1.6;
}
.faq-a.open { display: block; }

/* Image lightbox — click a photo/signature preview to view it enlarged. */
.field-img-preview,
.field-img-zoomable {
    cursor: zoom-in;
}
.img-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.8);
    cursor: zoom-out;
}
.img-lightbox.open { display: flex; }
.img-lightbox img {
    max-width: none;
    max-height: none;
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    background: #fff;
}
