/* ============================================================
   LegalSuite — Admin Panel Styles
   Premium dark theme with glassmorphism effects
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
    /* Core palette */
    --bg-dark:        #0b0e14;
    --bg-surface:     #111620;
    --bg-card:        #161c2a;
    --bg-card-hover:  #1c2436;
    --bg-elevated:    #1e2638;
    --bg-input:       #131926;

    --border:         rgba(255,255,255,0.06);
    --border-hover:   rgba(255,255,255,0.12);
    --border-focus:   rgba(99,102,241,0.5);

    --text-primary:   #e8ecf4;
    --text-secondary: #8b95a8;
    --text-muted:     #5a6478;
    --text-inverse:   #0b0e14;

    /* Accents */
    --accent:         #6366f1;
    --accent-hover:   #818cf8;
    --accent-subtle:  rgba(99,102,241,0.12);
    --accent-glow:    rgba(99,102,241,0.25);

    --emerald:        #10b981;
    --emerald-subtle: rgba(16,185,129,0.12);
    --amber:          #f59e0b;
    --amber-subtle:   rgba(245,158,11,0.12);
    --rose:           #f43f5e;
    --rose-subtle:    rgba(244,63,94,0.12);
    --sky:            #0ea5e9;
    --sky-subtle:     rgba(14,165,233,0.12);

    /* Status */
    --success:        #10b981;
    --danger:         #f43f5e;
    --warning:        #f59e0b;

    /* Sizes */
    --sidebar-width:  260px;
    --header-height:  60px;
    --radius:         12px;
    --radius-sm:      8px;
    --radius-lg:      16px;

    /* Font */
    --font-sans:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:      'JetBrains Mono', 'Fira Code', monospace;

    /* Transitions */
    --t-fast:         0.15s ease;
    --t-base:         0.25s ease;
    --t-slow:         0.4s ease;
}

/* ---------- LIGHT THEME ---------- */
[data-theme="light"] {
    --bg-dark:        #f5f7fa;
    --bg-surface:     #ffffff;
    --bg-card:        #ffffff;
    --bg-card-hover:  #f0f2f5;
    --bg-elevated:    #f5f7fa;
    --bg-input:       #f0f2f5;

    --border:         rgba(0,0,0,0.08);
    --border-hover:   rgba(0,0,0,0.15);
    --border-focus:   rgba(99,102,241,0.5);

    --text-primary:   #1a1d26;
    --text-secondary: #5f6980;
    --text-muted:     #9ca3b4;
    --text-inverse:   #ffffff;

    --accent:         #4f46e5;
    --accent-hover:   #6366f1;
    --accent-subtle:  rgba(79,70,229,0.08);
    --accent-glow:    rgba(79,70,229,0.18);

    --emerald:        #059669;
    --emerald-subtle: rgba(5,150,105,0.08);
    --amber:          #d97706;
    --amber-subtle:   rgba(217,119,6,0.08);
    --rose:           #e11d48;
    --rose-subtle:    rgba(225,29,72,0.08);
    --sky:            #0284c7;
    --sky-subtle:     rgba(2,132,199,0.08);

    --success:        #059669;
    --danger:         #e11d48;
    --warning:        #d97706;
}

/* ---------- Reset ---------- */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; }
body { font-family: var(--font-sans); background: var(--bg-dark); color: var(--text-primary); line-height: 1.6; min-height: 100vh; overflow-x: hidden; transition: background-color 0.35s ease, color 0.35s ease; }
a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }
input,textarea,select { font-family: inherit; font-size: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background: var(--bg-dark);
    background-image:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99,102,241,0.12), transparent),
        radial-gradient(ellipse 60% 50% at 80% 100%, rgba(16,185,129,0.06), transparent);
}
.login-card {
    width: 100%; max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.4);
    animation: fadeUp 0.5s ease;
    transition: background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}
[data-theme="light"] .login-screen {
    background-image:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(79,70,229,0.07), transparent),
        radial-gradient(ellipse 60% 50% at 80% 100%, rgba(5,150,105,0.04), transparent);
}
[data-theme="light"] .login-card {
    box-shadow: 0 8px 32px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-icon {
    width: 64px; height: 64px; margin: 0 auto 16px;
    background: var(--accent-subtle);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent-hover);
}
.login-logo-icon svg { width: 32px; height: 32px; }
.login-logo h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.login-logo p { color: var(--text-secondary); font-size: 0.875rem; margin-top: 4px; }

.login-form, .setup-section form { display: flex; flex-direction: column; gap: 16px; }
.setup-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.setup-text { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 8px; text-align: center; }

.password-input-wrapper { position: relative; }
.password-input-wrapper input { padding-right: 44px; }
.password-toggle {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); color: var(--text-muted); transition: color var(--t-fast);
}
.password-toggle:hover { color: var(--text-primary); }
.password-toggle svg { width: 18px; height: 18px; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-container { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width); min-width: var(--sidebar-width);
    height: 100vh; position: sticky; top: 0;
    display: flex; flex-direction: column;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    z-index: 100;
    transition: transform var(--t-base), background-color 0.35s ease, border-color 0.35s ease;
}
[data-theme="light"] .sidebar { box-shadow: 1px 0 4px rgba(0,0,0,0.04); }
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); }
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: var(--accent-subtle); color: var(--accent-hover);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-icon svg { width: 22px; height: 22px; }
.logo-text h1 { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.logo-subtitle { font-size: 0.6875rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.sidebar-close { display: none; }

.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.sidebar-nav ul { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    width: 100%; display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 0.875rem; font-weight: 500;
    color: var(--text-secondary); transition: all var(--t-fast);
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-item.active { color: var(--accent-hover); background: var(--accent-subtle); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
    margin-left: auto; background: var(--accent-subtle); color: var(--accent-hover);
    font-size: 0.6875rem; font-weight: 600; padding: 2px 8px;
    border-radius: 10px; min-width: 24px; text-align: center;
}

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.nav-item-theme { color: var(--text-muted); margin-bottom: 4px; }
.nav-item-theme:hover { color: var(--amber); background: var(--amber-subtle); }
[data-theme="light"] .nav-item-theme:hover { color: var(--accent); background: var(--accent-subtle); }
.nav-item-logout { color: var(--text-muted); margin-bottom: 8px; }
.nav-item-logout:hover { color: var(--rose); background: var(--rose-subtle); }
.sidebar-footer-info {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; font-size: 0.6875rem;
    color: var(--text-muted);
}
.sidebar-footer-info svg { width: 14px; height: 14px; color: var(--emerald); }

/* Theme toggle - mobile */
.mobile-right-actions { display: flex; align-items: center; gap: 4px; }
.mobile-theme-btn {
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); color: var(--text-secondary); transition: all var(--t-fast);
}
.mobile-theme-btn:hover { background: var(--bg-card); color: var(--amber); }
[data-theme="light"] .mobile-theme-btn:hover { color: var(--accent); }
.mobile-theme-btn svg { width: 20px; height: 20px; }

/* MOBILE HEADER */
.mobile-header {
    display: none;
    position: sticky; top: 0; z-index: 90;
    height: var(--header-height);
    padding: 0 16px; background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    align-items: center; justify-content: space-between;
}
.mobile-menu-btn, .mobile-logout-btn {
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); color: var(--text-secondary);
}
.mobile-menu-btn:hover, .mobile-logout-btn:hover { background: var(--bg-card); color: var(--text-primary); }
.mobile-menu-btn svg, .mobile-logout-btn svg { width: 22px; height: 22px; }
.mobile-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.125rem; }
.mobile-logo svg { width: 22px; height: 22px; color: var(--accent-hover); }

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    z-index: 99;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    flex: 1; min-width: 0;
    padding: 32px;
    max-width: 1200px;
}

.view { display: none; animation: fadeUp 0.35s ease; }
.view.active { display: block; }

.view-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    flex-wrap: wrap; gap: 16px; margin-bottom: 28px;
}
.view-title { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.view-subtitle { color: var(--text-secondary); font-size: 0.875rem; margin-top: 4px; }
.view-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px; border-radius: var(--radius-sm);
    font-size: 0.875rem; font-weight: 600;
    transition: all var(--t-fast); white-space: nowrap;
    border: 1px solid transparent;
}
.btn svg { width: 16px; height: 16px; }
.btn-sm { padding: 6px 10px; font-size: 0.8125rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-primary {
    background: var(--accent); color: #fff; border-color: var(--accent);
    box-shadow: 0 1px 3px rgba(99,102,241,0.3);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.35); }

.btn-secondary { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-hover); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }

.btn-danger { background: var(--rose-subtle); color: var(--rose); border-color: rgba(244,63,94,0.2); }
.btn-danger:hover { background: var(--rose); color: #fff; }

.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-card); }

.btn-back { margin-bottom: 8px; padding: 6px 10px; font-size: 0.8125rem; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); }
.required { color: var(--rose); }
.form-error { font-size: 0.8125rem; color: var(--rose); min-height: 20px; }

input[type="text"],input[type="email"],input[type="tel"],input[type="url"],input[type="password"],input[type="search"],textarea {
    width: 100%; padding: 10px 14px;
    background: var(--bg-input); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.875rem; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); outline: none; }
input::placeholder, textarea::placeholder { color: var(--text-muted); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group-full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.client-form { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; transition: background-color 0.35s ease, border-color 0.35s ease; }
[data-theme="light"] .client-form { box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
[data-theme="light"] .clients-table { box-shadow: 0 1px 3px rgba(0,0,0,0.04); }

/* ============================================================
   SEARCH BOX
   ============================================================ */
.search-box {
    position: relative; display: flex; align-items: center;
}
.search-box i { position: absolute; left: 12px; color: var(--text-muted); width: 16px; height: 16px; pointer-events: none; }
.search-box input { padding-left: 36px; min-width: 220px; }

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
    display: flex; align-items: center; gap: 16px;
    padding: 20px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius);
    transition: border-color var(--t-fast), transform var(--t-fast), background-color 0.35s ease, box-shadow 0.35s ease;
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
[data-theme="light"] .stat-card { box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
[data-theme="light"] .stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.stat-icon {
    width: 48px; height: 48px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.si-indigo { background: var(--accent-subtle); color: var(--accent-hover); }
.si-emerald { background: var(--emerald-subtle); color: var(--emerald); }
.si-amber { background: var(--amber-subtle); color: var(--amber); }
.si-rose { background: var(--rose-subtle); color: var(--rose); }

.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 500; margin-top: 4px; }
.stat-info { display: flex; flex-direction: column; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    transition: background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}
[data-theme="light"] .card { box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 0.9375rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-header h3 svg { width: 16px; height: 16px; color: var(--accent-hover); }
.card-body { padding: 16px 20px; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Activity List */
.activity-list, .recent-clients-list { display: flex; flex-direction: column; gap: 0; }
.activity-list li, .recent-clients-list li {
    padding: 12px 0; border-bottom: 1px solid var(--border);
    font-size: 0.8125rem; display: flex; align-items: center; gap: 10px;
}
.activity-list li:last-child, .recent-clients-list li:last-child { border-bottom: none; }
.activity-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.activity-dot.green { background: var(--emerald); }
.activity-dot.blue { background: var(--accent); }
.activity-dot.amber { background: var(--amber); }
.activity-dot.red { background: var(--rose); }
.activity-time { margin-left: auto; font-size: 0.6875rem; color: var(--text-muted); white-space: nowrap; }
.activity-text { color: var(--text-secondary); }
.activity-text strong { color: var(--text-primary); font-weight: 600; }

.empty-msg {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 24px; color: var(--text-muted); text-align: center;
}
.empty-msg svg { width: 28px; height: 28px; opacity: 0.4; }

/* Recent client item */
.rc-item { display: flex; align-items: center; gap: 12px; width: 100%; cursor: pointer; }
.rc-avatar {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    background: var(--accent-subtle); color: var(--accent-hover);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.75rem; flex-shrink: 0;
}
.rc-info { flex: 1; min-width: 0; }
.rc-name { font-weight: 600; color: var(--text-primary); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-id { font-size: 0.6875rem; color: var(--text-muted); font-family: var(--font-mono); }

/* ============================================================
   CLIENTS TABLE
   ============================================================ */
.clients-table-wrap { overflow-x: auto; }
.clients-table {
    width: 100%; border-collapse: collapse;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden;
}
.clients-table thead { background: var(--bg-elevated); }
.clients-table th {
    padding: 12px 16px; text-align: left;
    font-size: 0.6875rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.clients-table td {
    padding: 14px 16px; font-size: 0.875rem; border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.clients-table tbody tr { transition: background var(--t-fast); }
.clients-table tbody tr:hover { background: var(--bg-card-hover); }
.clients-table tbody tr:last-child td { border-bottom: none; }

.client-name-cell { display: flex; align-items: center; gap: 12px; }
.client-avatar {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: var(--accent-subtle); color: var(--accent-hover);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8125rem; flex-shrink: 0;
}
.client-name-text { font-weight: 600; }
.client-id-mono { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }

.doc-count-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 10px; font-size: 0.75rem; font-weight: 600;
}
.doc-count-badge.has-docs { background: var(--emerald-subtle); color: var(--emerald); }
.doc-count-badge.no-docs { background: var(--rose-subtle); color: var(--rose); }

.table-actions { display: flex; gap: 6px; }
.table-actions .btn { padding: 6px 10px; }

/* Empty state */
.empty-state {
    display: none; flex-direction: column; align-items: center; justify-content: center;
    padding: 64px 24px; text-align: center;
}
.empty-state.active { display: flex; }
.empty-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--accent-subtle); color: var(--accent-hover); display: flex; align-items: center; justify-content: center; margin-bottom: 20px; }
.empty-icon svg { width: 32px; height: 32px; }
.empty-state h3 { font-size: 1.25rem; font-weight: 700; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 20px; max-width: 360px; }

/* ============================================================
   CLIENT DETAIL
   ============================================================ */
.client-id-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 6px;
    background: var(--bg-elevated); font-family: var(--font-mono);
    font-size: 0.8125rem; color: var(--text-secondary);
    border: 1px solid var(--border);
}

.client-info-card { margin-bottom: 28px; }
.client-info-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0;
}
.client-info-item {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px; font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    color: var(--text-secondary);
}
.client-info-item:last-child { border-right: none; }
.client-info-item svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.client-info-item a { color: var(--accent-hover); }
.client-info-item strong { color: var(--text-primary); font-weight: 600; }

.section-title {
    font-size: 1.125rem; font-weight: 700; display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px;
}
.section-title svg { width: 20px; height: 20px; color: var(--accent-hover); }

/* Documents Grid */
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.doc-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; cursor: pointer; transition: all var(--t-fast);
    position: relative; overflow: hidden;
}
.doc-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
[data-theme="light"] .doc-card { box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
[data-theme="light"] .doc-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.doc-card-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.doc-card-icon svg { width: 20px; height: 20px; }
.doc-card h4 { font-size: 0.875rem; font-weight: 600; margin-bottom: 4px; }
.doc-card-status { font-size: 0.75rem; display: flex; align-items: center; gap: 6px; }
.doc-status-dot { width: 6px; height: 6px; border-radius: 50%; }
.doc-status-dot.filled { background: var(--emerald); }
.doc-status-dot.empty { background: var(--text-muted); }
.doc-card-date { font-size: 0.6875rem; color: var(--text-muted); margin-top: 8px; }
.doc-card-strip {
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
}

/* Doc type colors */
.doc-type-privacy .doc-card-icon   { background: var(--accent-subtle); color: var(--accent-hover); }
.doc-type-privacy .doc-card-strip  { background: var(--accent); }
.doc-type-legal .doc-card-icon     { background: var(--emerald-subtle); color: var(--emerald); }
.doc-type-legal .doc-card-strip    { background: var(--emerald); }
.doc-type-cookies .doc-card-icon   { background: var(--amber-subtle); color: var(--amber); }
.doc-type-cookies .doc-card-strip  { background: var(--amber); }
.doc-type-sales .doc-card-icon     { background: var(--rose-subtle); color: var(--rose); }
.doc-type-sales .doc-card-strip    { background: var(--rose); }
.doc-type-access .doc-card-icon    { background: var(--sky-subtle); color: var(--sky); }
.doc-type-access .doc-card-strip   { background: var(--sky); }
.doc-type-terms .doc-card-icon     { background: rgba(168,85,247,0.12); color: #a855f7; }
.doc-type-terms .doc-card-strip    { background: #a855f7; }
.doc-type-disclaimer .doc-card-icon { background: rgba(236,72,153,0.12); color: #ec4899; }
.doc-type-disclaimer .doc-card-strip { background: #ec4899; }

[data-theme="light"] .doc-type-terms .doc-card-icon     { background: rgba(168,85,247,0.08); color: #7c3aed; }
[data-theme="light"] .doc-type-terms .doc-card-strip    { background: #7c3aed; }
[data-theme="light"] .doc-type-disclaimer .doc-card-icon { background: rgba(236,72,153,0.08); color: #db2777; }
[data-theme="light"] .doc-type-disclaimer .doc-card-strip { background: #db2777; }

/* ============================================================
   DOCUMENT EDITOR
   ============================================================ */
.editor-layout { display: flex; gap: 16px; }
.editor-main { flex: 1; min-width: 0; }
.editor-card { overflow: visible; }

/* Quill overrides */
.ql-toolbar.ql-snow { border: none !important; border-bottom: 1px solid var(--border) !important; background: var(--bg-elevated); border-radius: var(--radius) var(--radius) 0 0; padding: 10px 14px !important; transition: background-color 0.35s ease, border-color 0.35s ease; }
.ql-container.ql-snow { border: none !important; font-size: 0.9375rem; min-height: 400px; }
.ql-editor { padding: 24px !important; color: var(--text-primary); line-height: 1.8; transition: color 0.35s ease; }
.ql-editor.ql-blank::before { color: var(--text-muted); font-style: normal; }
.ql-snow .ql-stroke { stroke: var(--text-secondary); }
.ql-snow .ql-fill { fill: var(--text-secondary); }
.ql-snow .ql-picker-label { color: var(--text-secondary); }
.ql-snow .ql-picker-options { background: var(--bg-card); border-color: var(--border); border-radius: var(--radius-sm); }
.ql-snow .ql-picker-item:hover { color: var(--accent-hover); }
.ql-snow button:hover .ql-stroke { stroke: var(--accent-hover); }
.ql-snow button:hover .ql-fill { fill: var(--accent-hover); }
.ql-snow button.ql-active .ql-stroke { stroke: var(--accent-hover); }
.ql-snow button.ql-active .ql-fill { fill: var(--accent-hover); }
.ql-snow .ql-picker-label:hover { color: var(--accent-hover); }
[data-theme="light"] .ql-snow .ql-picker-options { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* History Sidebar */
.editor-sidebar {
    width: 300px; flex-shrink: 0;
    display: none;
}
.editor-sidebar.open { display: block; animation: slideInRight 0.3s ease; }
.history-panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); position: sticky; top: 32px;
    max-height: calc(100vh - 160px); overflow: hidden; display: flex; flex-direction: column;
}
.history-header {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.history-header h4 { font-size: 0.8125rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.history-header h4 svg { width: 14px; height: 14px; color: var(--accent-hover); }
.history-list { overflow-y: auto; flex: 1; padding: 8px; }
.history-list li {
    padding: 10px 12px; border-radius: var(--radius-sm);
    font-size: 0.8125rem; cursor: pointer;
    transition: background var(--t-fast); margin-bottom: 2px;
}
.history-list li:hover { background: var(--bg-card-hover); }
.history-date { font-weight: 600; color: var(--text-primary); font-size: 0.75rem; }
.history-preview { color: var(--text-muted); font-size: 0.6875rem; margin-top: 2px; display: block;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 250px; }
.history-badge { font-size: 0.625rem; color: var(--emerald); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    padding: 24px; animation: fadeIn 0.2s ease;
}
.modal {
    width: 100%; max-width: 440px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 32px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    animation: scaleIn 0.3s ease;
}
[data-theme="light"] .modal { box-shadow: 0 24px 64px rgba(0,0,0,0.15); }
[data-theme="light"] .modal-overlay { background: rgba(0,0,0,0.3); }
.modal-header { text-align: center; margin-bottom: 24px; }
.modal-icon-danger {
    width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 16px;
    background: var(--rose-subtle); color: var(--rose);
    display: flex; align-items: center; justify-content: center;
}
.modal-icon-danger svg { width: 28px; height: 28px; }
.modal-header h3 { font-size: 1.25rem; font-weight: 700; }
.modal-header p { color: var(--text-secondary); font-size: 0.875rem; margin-top: 4px; }
.modal-body { margin-bottom: 24px; }
.modal-body > p { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 12px; text-align: center; }
.delete-code {
    font-family: var(--font-mono); font-size: 2rem; font-weight: 700;
    letter-spacing: 0.25em; text-align: center;
    color: var(--rose); background: var(--rose-subtle);
    padding: 12px; border-radius: var(--radius-sm);
    margin-bottom: 16px; user-select: none;
}
.modal-body .form-group input { text-align: center; font-size: 1.25rem; letter-spacing: 0.15em; font-family: var(--font-mono); }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 2000;
    display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px; border-radius: var(--radius-sm);
    background: var(--bg-elevated); border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    font-size: 0.875rem; font-weight: 500;
    animation: slideInRight 0.35s ease;
    max-width: 380px;
}
[data-theme="light"] .toast { background: var(--bg-card); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success { border-color: rgba(16,185,129,0.3); }
.toast.success svg { color: var(--emerald); }
.toast.error { border-color: rgba(244,63,94,0.3); }
.toast.error svg { color: var(--rose); }
.toast.info { border-color: rgba(99,102,241,0.3); }
.toast.info svg { color: var(--accent-hover); }
.toast-exit { animation: slideOutRight 0.3s ease forwards; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .editor-sidebar { position: fixed; right: 0; top: 0; bottom: 0; width: 300px; z-index: 200; border-radius: 0; }
    .editor-sidebar.open { display: block; }
    .editor-sidebar .history-panel { height: 100%; max-height: 100%; border-radius: 0; border-right: none; }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%); z-index: 100;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: flex; width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-muted); }
    .sidebar-close:hover { background: var(--bg-card); color: var(--text-primary); }
    .sidebar-overlay.open { display: block; }

    .mobile-header { display: flex; }
    .main-content { padding: 20px 16px; }
    .view-title { font-size: 1.375rem; }
    .view-header { flex-direction: column; }
    .view-actions { width: 100%; }
    .search-box { flex: 1; }
    .search-box input { min-width: 0; width: 100%; }

    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .docs-grid { grid-template-columns: 1fr; }

    .hide-mobile { display: none; }

    .modal { padding: 24px; }
    .toast-container { bottom: 16px; right: 16px; left: 16px; }
    .toast { max-width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.5rem; }
}

/* ============================================================
   PUBLISH STATUS INDICATORS
   ============================================================ */

/* --- Client detail header indicator --- */
.publish-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
}
.publish-indicator svg { width: 15px; height: 15px; }

.publish-indicator--synced {
    background: var(--emerald-subtle);
    color: var(--emerald);
}
.publish-indicator--pending {
    background: var(--amber-subtle);
    color: var(--amber);
}
.publish-indicator--never {
    background: rgba(100,116,139,0.1);
    color: var(--text-muted);
}

[data-theme="light"] .publish-indicator--synced { background: #ecfdf5; color: #059669; }
[data-theme="light"] .publish-indicator--pending { background: #fffbeb; color: #b45309; }
[data-theme="light"] .publish-indicator--never { background: #f1f5f9; color: #94a3b8; }

/* --- Document card publish badges --- */
.doc-publish-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    margin-top: 8px;
    letter-spacing: 0.2px;
}
.doc-publish-badge svg { width: 12px; height: 12px; }

.doc-publish-badge--synced {
    background: var(--emerald-subtle);
    color: var(--emerald);
}
.doc-publish-badge--pending {
    background: var(--amber-subtle);
    color: var(--amber);
    animation: pulse-badge 2s ease-in-out infinite;
}
.doc-publish-badge--never {
    background: rgba(100,116,139,0.08);
    color: var(--text-muted);
}

[data-theme="light"] .doc-publish-badge--synced { background: #ecfdf5; color: #059669; }
[data-theme="light"] .doc-publish-badge--pending { background: #fffbeb; color: #b45309; }
[data-theme="light"] .doc-publish-badge--never { background: #f8fafc; color: #94a3b8; }

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

/* --- Doc card date with icon --- */
.doc-card-date {
    display: flex;
    align-items: center;
    gap: 5px;
}
.doc-card-date svg { width: 12px; height: 12px; opacity: 0.6; }

.doc-card-date--pub {
    color: var(--accent-hover) !important;
}
.doc-card-date--pub svg { opacity: 0.8; }

[data-theme="light"] .doc-card-date--pub { color: var(--accent) !important; }

/* --- Clean text button ghost style refinement --- */
#btn-clean-text {
    border: 1px solid var(--border);
}
#btn-clean-text:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}
[data-theme="light"] #btn-clean-text {
    border-color: #d1d5db;
}
[data-theme="light"] #btn-clean-text:hover {
    background: #f1f5f9;
    border-color: #9ca3af;
}
