/* ═══════════════════════════════════════════════════════════════════════════
   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-surface-glass: rgba(255, 255, 255, 0.03);
    --papyrus-border-subtle: rgba(255, 255, 255, 0.06);
    --papyrus-radius: 10px;
    --papyrus-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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-border-subtle) !important;
    backdrop-filter: blur(20px) saturate(1.4);
    background: rgba(15, 17, 24, 0.85) !important;
    overflow: visible !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;
}

.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: rgba(255, 255, 255, 0.02);
}

/* ─── 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: rgba(0,0,0,0.35);
    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;
}

/* ─── Login Page ──────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
}
.login-hero {
    background: linear-gradient(160deg, #0c0e14 0%, #0f2922 50%, #0d3b2e 100%);
    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.1);
    border-radius: 50%;
}
.login-hero h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #f1f5f9;
    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;
}
.login-hero p {
    color: #94a3b8;
    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: #0c0e14;
}
.login-form-container {
    width: 100%;
    max-width: 400px;
}

@media (max-width: 960px) {
    .login-page { grid-template-columns: 1fr; }
    .login-hero { display: none; }
}

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.4); }

/* ─── 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; }
