/* Spheric Capital — Production Library
   Dark warm background, forest-green accent, Fraunces + DM Sans.
   Brand tokens mirror demo/static/style.css so the production app
   reads as a continuation of the demo, not a separate visual world. */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,500;0,9..144,700;1,9..144,300&display=swap');

:root {
    --accent:        #2D5A3D;
    --accent-light:  #3a7a52;
    --accent-muted:  rgba(45,90,61,0.25);
    --accent-text:   #6abf82;
    --bg:            #0F0F0E;
    --bg-raised:     #1A1918;
    --bg-card:       #1F1E1D;
    --bg-input:      #141413;
    --ink:           #E8E6DF;
    --ink-soft:      #A8A49C;
    --ink-faint:     #6B6760;
    --amber:         #C8943E;
    --amber-muted:   rgba(200,148,62,0.15);
    --amber-text:    #E8B34A;
    --red:           #D94444;
    --red-muted:     rgba(217,68,68,0.15);
    --border:        #2E2D2A;
    --border-light:  #252422;
    --radius:        6px;
    --shadow:        0 1px 4px rgba(0,0,0,0.3);
    --shadow-lg:     0 8px 24px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.65;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-text);
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.15s;
}
a:hover { border-bottom-color: var(--accent-text); }

/* ─── Header (copied shape from demo/templates/base.html) ─── */
header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.header-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 24px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
}
.header-brand { display: flex; flex-direction: column; }
.subtitle {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 20px;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 2px;
}
.logo {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-faint);
    letter-spacing: 1.5px;
}
.header-nav {
    display: flex;
    gap: 20px;
    align-items: center;
}
.header-nav a {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
    border-bottom: none;
    letter-spacing: 0.2px;
}
.header-nav a:hover { color: var(--accent-text); }

/* ─── Main layout ─── */
main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

h1, h2, h3 {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.25;
}
h1 { font-size: 28px; margin-bottom: 4px; }
h2 { font-size: 22px; margin-bottom: 4px; }
h3 { font-size: 17px; margin-bottom: 4px; }

.page-desc {
    font-size: 14px;
    color: var(--ink-faint);
    margin-bottom: 24px;
}

/* ─── Search bar ─── */
.search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}
.search-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    outline: none;
}
.search-input:focus {
    border-color: var(--accent-text);
    background: var(--bg-raised);
}
.search-input::placeholder { color: var(--ink-faint); }

/* ─── Filter chips ─── */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    align-items: center;
    justify-content: flex-start;
}
.filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-faint);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-right: 12px;
    min-width: 70px;           /* fixed column so all chip rows line up */
    display: inline-block;
    text-align: left;
}
.chip {
    background: var(--bg-card);
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    transition: all 0.15s;
}
.chip:hover {
    border-color: var(--accent-text);
    color: var(--ink);
}
.chip.active {
    background: var(--accent-muted);
    border-color: var(--accent);
    color: var(--accent-text);
}

/* ─── Document list ─── */
.doc-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.doc-row-link {
    text-decoration: none;
    color: inherit;
    border-bottom: none;
    display: block;
}
.doc-row-link:hover { border-bottom: none; }
.doc-row {
    display: grid;
    grid-template-columns: 54px 1fr auto auto;
    gap: 18px;
    align-items: center;
    padding: 18px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, background 0.15s, transform 0.05s;
    cursor: pointer;
}
.doc-row:hover {
    border-color: var(--accent-text);
    background: var(--bg-raised);
}
.doc-row:active { transform: scale(0.998); }
.type-badge {
    background: var(--border);
    color: var(--ink-soft);
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    padding: 6px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    min-width: 46px;
}
.type-badge.pdf     { background: #c0392b; color: white; }
.type-badge.xlsx,
.type-badge.xls     { background: #1e6641; color: white; }
.type-badge.docx,
.type-badge.doc     { background: #1e4e8c; color: white; }
.type-badge.csv     { background: #7a5c1c; color: white; }
.type-badge.body    { background: var(--ink-faint); color: var(--bg); }

/* Main column: subject (big) + filename-row (smaller) + optional snippet */
.doc-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.doc-subject {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 17px;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}
.doc-filename-row {
    font-size: 12px;
    color: var(--ink-faint);
    display: flex;
    gap: 10px;
    align-items: baseline;
    flex-wrap: wrap;
}
.doc-filename-row .doc-filename {
    color: var(--ink-soft);
    font-weight: 500;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 320px;
}
.doc-filename-row .doc-filename::before {
    content: "📄 ";
    font-size: 11px;
    margin-right: 2px;
}
.doc-filename-row .doc-sender {
    color: var(--ink-faint);
}
.doc-filename-row .doc-sender::before {
    content: "· ";
    opacity: 0.6;
    margin-right: 2px;
}
.doc-snippet {
    font-size: 13px;
    color: var(--ink-soft);
    margin-top: 6px;
    grid-column: 2 / -1;
    line-height: 1.55;
}
.doc-snippet mark {
    background: var(--amber-muted);
    color: var(--amber-text);
    padding: 0 2px;
    border-radius: 2px;
}

/* Vendor pill on the right — text is centered, the pill box fits
   its content exactly (no fixed min-width) so it ends where the
   text ends. */
.doc-vendor-pill {
    background: var(--accent-muted);
    color: var(--accent-text);
    border: 1px solid var(--accent);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
    text-align: center;
    align-self: center;
}
.doc-vendor-pill--none {
    background: transparent;
    color: var(--ink-faint);
    border-color: var(--border);
    font-style: italic;
    font-weight: 500;
}

/* Row-action buttons (admin panel — Remove / Resend on each row) */
.btn-row-action {
    padding: 8px 14px;
    background: var(--bg-raised);
    color: var(--ink-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
    align-self: center;
}
.btn-row-action:hover {
    border-color: var(--accent-text);
    color: var(--ink);
    background: var(--bg-card);
}
.btn-row-action--danger {
    color: var(--red);
    border-color: var(--red-muted);
}
.btn-row-action--danger:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-muted);
}
.btn-row-action-placeholder {
    padding: 8px 14px;
    font-size: 11px;
    font-style: italic;
    color: var(--ink-faint);
    align-self: center;
    white-space: nowrap;
}

/* Far-right stack: status + size/pages + date, each on its own line,
   tabular-nums for clean right alignment. */
.doc-right-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 120px;
    font-variant-numeric: tabular-nums;
}
.doc-right-stack .status-tag { align-self: flex-end; }
.doc-size-line {
    font-size: 11px;
    color: var(--ink-faint);
    white-space: nowrap;
}
.doc-date-line {
    font-size: 11px;
    color: var(--ink-faint);
    white-space: nowrap;
}

/* ─── Status tags ─── */
.status-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.status-tag.queued     { background: var(--amber-muted); color: var(--amber-text); }
.status-tag.processing { background: var(--amber-muted); color: var(--amber-text); }
.status-tag.done       { background: var(--accent-muted); color: var(--accent-text); }
.status-tag.failed     { background: var(--red-muted);    color: var(--red); }

/* ─── Empty state ─── */
.empty {
    text-align: center;
    padding: 80px 24px;
    color: var(--ink-faint);
    font-size: 14px;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* ─── Document detail view ─── */
.back-link {
    display: inline-block;
    font-size: 13px;
    color: var(--ink-soft);
    margin-bottom: 20px;
    border-bottom: none;
}
.back-link:hover { color: var(--accent-text); }
.doc-header {
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.doc-header h1 {
    font-size: 22px;
    margin-bottom: 8px;
    word-break: break-word;
}
.doc-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 32px;
    font-size: 13px;
    color: var(--ink-soft);
    margin-top: 16px;
}
.doc-header-meta span { display: flex; gap: 6px; }
.doc-header-meta strong {
    color: var(--ink-faint);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
}
.doc-text {
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    line-height: 1.75;
    color: var(--ink);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 60vh;
    overflow-y: auto;
}

/* ─── Extract sections (fast + enhanced) on document detail ─── */
.extract-section {
    margin-bottom: 28px;
}
.extract-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.extract-header h3 { margin: 0; }
.extract-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    font-family: 'DM Sans', sans-serif;
    white-space: nowrap;
}
.extract-tag--fast {
    background: var(--bg-raised);
    color: var(--ink-soft);
    border: 1px solid var(--border);
}
.extract-tag--enhanced {
    background: var(--accent-muted);
    color: var(--accent-text);
    border: 1px solid var(--accent);
}
.extract-tag--pending {
    background: var(--amber-muted);
    color: var(--amber-text);
    border: 1px solid var(--amber);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.extract-tag--failed {
    background: var(--red-muted);
    color: var(--red);
    border: 1px solid var(--red);
}
.pending-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--amber-text);
    animation: pending-pulse 1.4s ease-in-out infinite;
}
@keyframes pending-pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50%      { opacity: 1.0; transform: scale(1.2); }
}

.enhance-loading {
    padding: 28px;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 16px;
}
.enhance-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-text);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    flex-shrink: 0;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.enhance-loading-text {
    font-size: 13px;
    color: var(--ink-soft);
    line-height: 1.5;
}
.enhance-loading-text small {
    color: var(--ink-faint);
    font-size: 11px;
}

/* ─── Login form ─── */
.login-wrap {
    max-width: 400px;
    margin: 80px auto;
}
.login-form {
    padding: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.login-form h1 { text-align: center; margin-bottom: 8px; }
.login-form label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.login-form input {
    padding: 12px 14px;
    background: var(--bg-input);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    outline: none;
}
.login-form input:focus {
    border-color: var(--accent-text);
    background: var(--bg-raised);
}
.login-error {
    color: var(--red);
    font-size: 13px;
    text-align: center;
    padding: 8px;
    background: var(--red-muted);
    border-radius: var(--radius);
}

/* ─── Buttons ─── */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
    font-family: 'DM Sans', sans-serif;
    letter-spacing: 0.2px;
    display: inline-block;
    text-align: center;
}
.btn-primary {
    background: var(--accent);
    color: var(--ink);
}
.btn-primary:hover { background: var(--accent-light); }
.btn-secondary {
    background: var(--bg-card);
    color: var(--ink-soft);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-raised); color: var(--ink); }

/* ─── Footer ─── */
footer {
    max-width: 1000px;
    margin: 60px auto 20px;
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--ink-faint);
    text-align: center;
    letter-spacing: 0.5px;
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .header-inner { flex-direction: column; align-items: flex-start; gap: 16px; }
    .header-nav { width: 100%; }
    .doc-row {
        grid-template-columns: 48px 1fr;
        gap: 10px;
    }
    .doc-size, .doc-date { grid-column: 2; text-align: left; }
    main { padding: 24px 16px 60px; }
}
