/* ═══════════════════════════════════════════════════════════════════════════
   PAPYRUS.IO — Design System
   Aesthetic: Refined editorial + emerald accents + geometric precision
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --papyrus-emerald: #10b981;
    --papyrus-emerald-glow: rgba(16, 185, 129, 0.12);
    --papyrus-gold: #f59e0b;
    --papyrus-radius: 10px;
    --papyrus-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    /* Dark-mode tokens (default). Light overrides live under body.papyrus-light. */
    --papyrus-surface-glass: rgba(255, 255, 255, 0.03);
    --papyrus-border-subtle: rgba(255, 255, 255, 0.06);
    --papyrus-appbar-bg: rgba(15, 17, 24, 0.85);
    --papyrus-appbar-border: rgba(255, 255, 255, 0.06);
    --papyrus-dialog-actions-bg: rgba(255, 255, 255, 0.02);
    --papyrus-scrollbar-thumb: rgba(148, 163, 184, 0.2);
    --papyrus-scrollbar-thumb-hover: rgba(148, 163, 184, 0.4);
    --papyrus-overlay-strong: rgba(0, 0, 0, 0.35);

    /* Semantic surfaces & text — flip with theme so feature CSS can stop hardcoding
       slate-400/cbd5e1/f1f5f9 and rgba(30,41,59,…) which only read right on dark. */
    --papyrus-text-strong: #f1f5f9;
    --papyrus-text-soft: #cbd5e1;
    --papyrus-text-muted: #94a3b8;
    --papyrus-panel-bg: rgba(30, 41, 59, 0.4);
    --papyrus-panel-bg-strong: rgba(15, 17, 24, 0.6);
    --papyrus-hover-bg: rgba(255, 255, 255, 0.04);
    --papyrus-hover-bg-strong: rgba(255, 255, 255, 0.08);
    --papyrus-kbd-bg: rgba(255, 255, 255, 0.05);
}

body.papyrus-light {
    --papyrus-surface-glass: rgba(15, 23, 42, 0.03);
    --papyrus-border-subtle: rgba(15, 23, 42, 0.10);
    --papyrus-appbar-bg: rgba(255, 255, 255, 0.92);
    --papyrus-appbar-border: rgba(15, 23, 42, 0.08);
    --papyrus-dialog-actions-bg: rgba(15, 23, 42, 0.03);
    --papyrus-scrollbar-thumb: rgba(100, 116, 139, 0.35);
    --papyrus-scrollbar-thumb-hover: rgba(100, 116, 139, 0.55);
    --papyrus-overlay-strong: rgba(15, 23, 42, 0.20);

    --papyrus-text-strong: #0f172a;
    --papyrus-text-soft: #334155;
    --papyrus-text-muted: #64748b;
    --papyrus-panel-bg: rgba(15, 23, 42, 0.04);
    --papyrus-panel-bg-strong: rgba(15, 23, 42, 0.06);
    --papyrus-hover-bg: rgba(15, 23, 42, 0.05);
    --papyrus-hover-bg-strong: rgba(15, 23, 42, 0.08);
    --papyrus-kbd-bg: rgba(15, 23, 42, 0.06);
}

html, body {
    font-family: 'DM Sans', system-ui, sans-serif;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── MudFileUpload chip fix (dark mode) ──────────────────────────────────── */
.mud-file-upload .mud-chip {
    background: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
    border: 1px solid var(--mud-palette-primary) !important;
}

/* ─── Appbar ──────────────────────────────────────────────────────────────── */
.papyrus-appbar {
    border-bottom: 1px solid var(--papyrus-appbar-border) !important;
    backdrop-filter: blur(20px) saturate(1.4);
    background: var(--papyrus-appbar-bg) !important;
    overflow: visible !important;
}
body.papyrus-light .papyrus-appbar {
    /* On light theme the AppBar text/icons must use the dark palette text so
       MudIconButtons with Color="Color.Inherit" remain legible. */
    color: var(--mud-palette-text-primary) !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
}
body.papyrus-light .papyrus-appbar .mud-icon-button,
body.papyrus-light .papyrus-appbar .mud-button-text {
    color: var(--mud-palette-text-primary) !important;
}
body.papyrus-light .papyrus-appbar .mud-input-outlined-border {
    border-color: rgba(15, 23, 42, 0.12) !important;
}
.papyrus-appbar .mud-toolbar-appbar {
    overflow: visible !important;
}

.papyrus-wordmark {
    font-weight: 700 !important;
    letter-spacing: 0.18em !important;
    font-size: 0.85rem !important;
    background: linear-gradient(135deg, #10b981 0%, #34d399 50%, #a7f3d0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
body.papyrus-light .papyrus-wordmark {
    /* Deeper emerald stops carry the gradient against a white AppBar. */
    background: linear-gradient(135deg, #047857 0%, #10b981 60%, #059669 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.papyrus-logo-mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: linear-gradient(135deg, #10b981, #059669);
    position: relative;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.25);
}
.papyrus-logo-mark::after {
    content: '';
    position: absolute;
    inset: 5px;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-right: none;
    border-bottom: none;
}

.papyrus-search {
    max-width: 420px;
}
.papyrus-search .mud-input-outlined {
    border-radius: 20px !important;
}

/* ─── Drawer ──────────────────────────────────────────────────────────────── */
.papyrus-drawer {
    border-right: 1px solid var(--papyrus-border-subtle) !important;
}
.papyrus-drawer .mud-nav-link {
    border-radius: 8px;
    margin: 2px 8px;
    transition: var(--papyrus-transition);
}
.papyrus-drawer .mud-nav-link:hover {
    background: var(--papyrus-emerald-glow) !important;
}
.papyrus-drawer .mud-nav-link.active {
    background: var(--papyrus-emerald-glow) !important;
    color: var(--papyrus-emerald) !important;
    font-weight: 600;
}
.papyrus-drawer .mud-nav-link.active .mud-icon-root {
    color: var(--papyrus-emerald) !important;
}

/* ─── Main Content ────────────────────────────────────────────────────────── */
.papyrus-main {
    min-height: 100vh;
}

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.papyrus-card {
    border: 1px solid var(--papyrus-border-subtle);
    border-radius: var(--papyrus-radius);
    transition: var(--papyrus-transition);
    overflow: hidden;
}
.papyrus-card:hover {
    border-color: rgba(16, 185, 129, 0.2);
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.08);
    transform: translateY(-1px);
}

/* ─── Anonymous Fill Mode (eForm share-link) ──────────────────────────────── */
/* Applied by FormFillPage when an unauthenticated visitor opens /forms/share/{token}.
   Hides MainLayout's chrome so the form is the only thing on screen. */
body.papyrus-anonymous-fill .mud-appbar,
body.papyrus-anonymous-fill .mud-drawer {
    display: none !important;
}
body.papyrus-anonymous-fill .mud-main-content {
    padding-top: 0 !important;
    padding-left: 0 !important;
}
body.papyrus-anonymous-fill .mud-layout {
    min-height: 100vh;
}

/* ─── Dialogs ─────────────────────────────────────────────────────────────── */
/* Match the papyrus-card border treatment so dialogs visually align with the
   dashboard cards, with a soft emerald-tinted shadow to lift them above the page. */
.mud-dialog {
    border: 1px solid var(--papyrus-border-subtle) !important;
    border-radius: var(--papyrus-radius) !important;
    box-shadow: 0 12px 48px rgba(16, 185, 129, 0.10), 0 2px 8px rgba(0, 0, 0, 0.25) !important;
    overflow: hidden;
}
/* Slightly punch up the title bar separator so the header reads as a distinct band. */
.mud-dialog .mud-dialog-title {
    border-bottom: 1px solid var(--papyrus-border-subtle);
}
/* And the actions footer mirrors it from below. */
.mud-dialog .mud-dialog-actions {
    border-top: 1px solid var(--papyrus-border-subtle);
    background: var(--papyrus-dialog-actions-bg);
}

/* ─── Stat Cards ──────────────────────────────────────────────────────────── */
.stat-card {
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--papyrus-emerald), transparent);
}
.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
}
.stat-card .stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.6;
    margin-top: 4px;
}
.stat-card .stat-trend {
    font-size: 0.75rem;
    font-weight: 600;
}
.stat-card .stat-trend.up { color: #10b981; }
.stat-card .stat-trend.down { color: #ef4444; }

/* ─── Document Grid ───────────────────────────────────────────────────────── */
.doc-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.doc-type-badge.pdf { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.doc-type-badge.docx { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.doc-type-badge.xlsx { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.doc-type-badge.img { background: rgba(168, 85, 247, 0.12); color: #a855f7; }
.doc-type-badge.default { background: rgba(148, 163, 184, 0.12); color: #94a3b8; }

/* Search result row — clickable title with hover link feedback */
.search-result-title { cursor: pointer; }
.search-result-title-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--mud-palette-primary);
    display: block;
    text-decoration: none;
    transition: text-decoration 0.15s ease;
}
.search-result-title:hover .search-result-title-text { text-decoration: underline; }

/* ─── Document Detail Panel (resizable right-side drawer) ────────────────── */
.doc-detail-overlay {
    position: fixed; inset: 0; z-index: 1199;
    background: var(--papyrus-overlay-strong);
    backdrop-filter: blur(2px);
}
.doc-detail-panel {
    position: fixed; top: 0; right: 0; bottom: 0;
    z-index: 1200;
    background: var(--mud-palette-surface);
    border-left: 1px solid var(--mud-palette-divider);
    display: flex; flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,0.25);
    min-width: 320px; max-width: 80vw;
    animation: slideInRight 0.2s ease-out;
}
@keyframes slideInRight {
    from { transform: translateX(40px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
.doc-detail-resize-handle {
    position: absolute; top: 0; bottom: 0; left: -4px; width: 8px;
    cursor: col-resize; z-index: 10;
    background: transparent;
    transition: background 0.15s;
}
.doc-detail-resize-handle:hover,
.doc-detail-resize-handle.active {
    background: var(--mud-palette-primary);
    opacity: 0.5;
}
.doc-detail-panel-header {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--mud-palette-divider);
    flex-shrink: 0;
}
.doc-detail-panel-body {
    flex: 1; overflow-y: auto;
    padding: 16px;
}
.doc-detail-panel-footer {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid var(--mud-palette-divider);
    flex-shrink: 0;
}

/* ─── Public Page Theme Tokens ────────────────────────────────────────────── */
/* Tokens used by Landing, Login, Register, ForgotPassword, ResetPassword,
   Verify2fa, TermsOfUse, NotFound, and ResourcesLayout. Flip on body class. */
:root {
    --pub-bg: #0c0e14;
    --pub-bg-elev: #141720;
    --pub-bg-elev-2: #1a1f2e;
    --pub-border: #1e293b;
    --pub-border-strong: #334155;
    --pub-text: #f1f5f9;
    --pub-text-muted: #94a3b8;
    --pub-text-faint: #64748b;
    --pub-hero-grad: linear-gradient(160deg, #0c0e14 0%, #0f2922 50%, #0d3b2e 100%);
    --pub-input-bg: #141720;
    --pub-input-border: #1e293b;
    --pub-divider: #1e293b;
    --pub-nav-bg: rgba(12, 14, 20, 0.85);
    --pub-card-bg: rgba(20, 23, 32, 0.6);
    --pub-overlay-strong: rgba(0, 0, 0, 0.6);
}
body.papyrus-light {
    --pub-bg: #ffffff;
    --pub-bg-elev: #f8fafc;
    --pub-bg-elev-2: #f1f5f9;
    --pub-border: #e2e8f0;
    --pub-border-strong: #cbd5e1;
    --pub-text: #0f172a;
    --pub-text-muted: #475569;
    --pub-text-faint: #64748b;
    --pub-hero-grad: linear-gradient(160deg, #ecfdf5 0%, #d1fae5 50%, #a7f3d0 100%);
    --pub-input-bg: #ffffff;
    --pub-input-border: #cbd5e1;
    --pub-divider: #e2e8f0;
    --pub-nav-bg: rgba(255, 255, 255, 0.92);
    --pub-card-bg: rgba(248, 250, 252, 0.85);
    --pub-overlay-strong: rgba(15, 23, 42, 0.35);
}

/* ─── Public Theme Toggle (fixed floating button) ─────────────────────────── */
.pub-theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--pub-bg-elev);
    border: 1px solid var(--pub-border);
    color: var(--pub-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.pub-theme-toggle:hover {
    border-color: var(--papyrus-emerald);
    color: var(--papyrus-emerald);
    transform: scale(1.05);
}

/* ─── Login Page ──────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    background: var(--pub-bg);
}
.login-hero {
    background: var(--pub-hero-grad);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
    position: relative;
    overflow: hidden;
}
.login-hero::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.15), transparent 70%);
    top: -100px;
    right: -200px;
}
.login-hero::after {
    content: '';
    position: absolute;
    bottom: -50px;
    left: -100px;
    width: 400px;
    height: 400px;
    border: 1px solid rgba(16, 185, 129, 0.18);
    border-radius: 50%;
}
.login-hero h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--pub-text);
    line-height: 1.1;
}
.login-hero h1 span {
    background: linear-gradient(135deg, #10b981, #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
body.papyrus-light .login-hero h1 span {
    background: linear-gradient(135deg, #047857, #059669);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.login-hero p {
    color: var(--pub-text-muted);
    font-size: 1.1rem;
    line-height: 1.7;
    max-width: 480px;
    margin-top: 1.5rem;
}
.login-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: var(--pub-bg);
}
.login-form-container {
    width: 100%;
    max-width: 400px;
}

/* ─── Public Form Controls (used by Login/Register/Forgot/Reset/Verify2fa) ── */
.pub-label {
    display: block;
    font-size: 0.85rem;
    color: var(--pub-text-muted);
    margin-bottom: 6px;
}
.pub-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--pub-input-bg);
    border: 1px solid var(--pub-input-border);
    border-radius: 10px;
    color: var(--pub-text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.pub-input:focus { border-color: var(--papyrus-emerald); }
.pub-input.with-icon-right { padding-right: 48px; }
.pub-input-icon-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--pub-text-faint);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
}
.pub-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--pub-text-muted);
}
.pub-checkbox { accent-color: var(--papyrus-emerald); width: 16px; height: 16px; }
.pub-link {
    color: var(--papyrus-emerald);
    text-decoration: none;
    font-weight: 500;
}
.pub-link-muted {
    font-size: 0.85rem;
    color: var(--pub-text-faint);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}
.pub-link-muted:hover { color: var(--papyrus-emerald); }
.pub-btn-primary {
    width: 100%;
    height: 48px;
    background: var(--papyrus-emerald);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.pub-btn-primary:hover:not(:disabled) { background: #059669; }
.pub-btn-secondary {
    width: 100%;
    height: 48px;
    background: transparent;
    color: var(--pub-text);
    border: 1px solid var(--pub-border-strong);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.pub-btn-secondary:hover {
    border-color: var(--papyrus-emerald);
    color: var(--papyrus-emerald);
}
.pub-divider {
    border-top: 1px solid var(--pub-divider);
    margin: 24px 0;
    position: relative;
}
.pub-divider-label {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--pub-bg);
    padding: 0 12px;
    font-size: 0.75rem;
    color: var(--pub-text-faint);
}

@media (max-width: 960px) {
    .login-page { grid-template-columns: 1fr; }
    .login-hero { display: none; }
}

/* ─── Landing Page chrome ─────────────────────────────────────────────────── */
body { background: var(--pub-bg); color: var(--pub-text); }
.lp-page { background: var(--pub-bg); color: var(--pub-text); min-height: 100vh; }
.lp-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--pub-nav-bg);
    border-bottom: 1px solid var(--pub-border);
    backdrop-filter: blur(20px) saturate(1.4);
    transition: background 0.3s;
}
.lp-nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.lp-nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.lp-nav-links { display: flex; gap: 28px; }
.lp-nav-link {
    color: var(--pub-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}
.lp-nav-link:hover { color: var(--papyrus-emerald); }
.lp-nav-actions { display: flex; align-items: center; gap: 12px; }
@media (max-width: 768px) {
    .lp-nav-links { display: none; }
}

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--papyrus-scrollbar-thumb);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--papyrus-scrollbar-thumb-hover); }

/* ─── Animations ──────────────────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in {
    animation: fadeInUp 0.5s ease forwards;
}
.animate-in:nth-child(1) { animation-delay: 0s; }
.animate-in:nth-child(2) { animation-delay: 0.08s; }
.animate-in:nth-child(3) { animation-delay: 0.16s; }
.animate-in:nth-child(4) { animation-delay: 0.24s; }
.animate-in:nth-child(5) { animation-delay: 0.32s; }
.animate-in:nth-child(6) { animation-delay: 0.40s; }

/* ─── Utility ─────────────────────────────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }
.text-mono { font-family: 'JetBrains Mono', monospace; }
