@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ============================================================
   CSS VARIABLES — Dark Editorial Brutalism
   ============================================================ */
:root {
    --bg:        #0A0A0B;
    --bg-card:   #141415;
    --bg-hover:  #1C1C1E;
    --border:    #252527;
    --border-hl: #3A3A3D;
    --text:      #F4F1EB;
    --muted:     #8A8A90;
    --accent:    #F5A623;
    --accent-dim: rgba(245,166,35,0.12);
    --accent-glow: 0 0 20px rgba(245,166,35,0.3);
    --success:   #3DD598;
    --danger:    #FF4D6D;
    --warning:   #F5A623;
    --serif:     'Playfair Display', Georgia, serif;
    --mono:      'DM Mono', 'Courier New', monospace;
    --sans:      'DM Sans', system-ui, sans-serif;
    --radius-sm: 4px;
    --radius:    8px;
    --radius-lg: 14px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--sans);
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    font-size: 15px;
    line-height: 1.6;
}

/* Noise texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
    opacity: 0.6;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
h4, h5, h6 { font-family: var(--sans); font-weight: 600; }

.display-lg  { font-family: var(--serif); font-size: clamp(2.5rem, 5vw, 4rem); font-weight: 900; }
.display-md  { font-family: var(--serif); font-size: clamp(1.8rem, 3vw, 2.5rem); font-weight: 700; }
.mono        { font-family: var(--mono); font-size: 0.875em; }
.text-muted  { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    height: 60px;
    background: rgba(10, 10, 11, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.nav-logo {
    font-family: var(--serif);
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-logo .dot { color: var(--accent); }

.nav-links {
    display: flex;
    align-items: center;
    gap: 0;
}

.nav-link {
    font-family: var(--mono);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
    padding: 0 1.2rem;
    height: 60px;
    display: flex;
    align-items: center;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
}
.nav-link:hover, .nav-link.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.nav-email {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
}
.nav-org {
    color: var(--accent);
    font-weight: 600;
    margin-right: 0.15rem;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.main-wrap {
    flex: 1;
    width: 100%;
    max-width: 1380px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.page-title { font-size: clamp(1.8rem, 3vw, 2.4rem); }
.page-subtitle { color: var(--muted); font-size: 0.875rem; margin-top: 4px; }

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.card-title {
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.card-body { padding: 1.5rem; }

/* ============================================================
   STAT TILES
   ============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-tile {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition), transform var(--transition);
    animation: fadeSlideUp 0.5s ease both;
}
.stat-tile:hover { border-color: var(--border-hl); transform: translateY(-2px); }
.stat-tile::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(245,166,35,0.04) 0%, transparent 60%);
    pointer-events: none;
}
.stat-label {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.75rem;
}
.stat-value {
    font-family: var(--serif);
    font-size: 2.4rem;
    font-weight: 900;
    line-height: 1;
    color: var(--text);
}
.stat-tile:nth-child(1) { animation-delay: 0.05s; }
.stat-tile:nth-child(2) { animation-delay: 0.1s; }
.stat-tile:nth-child(3) { animation-delay: 0.15s; }
.stat-tile:nth-child(4) { animation-delay: 0.2s; }

/* ============================================================
   DATA TABLES
   ============================================================ */
.data-table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.data-table thead th {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--bg-card);
}
.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td {
    padding: 0.9rem 1rem;
    vertical-align: middle;
}
.data-table td.mono-val { font-family: var(--mono); font-size: 0.85rem; }

/* ============================================================
   STATUS PILLS
   ============================================================ */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 99px;
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 500;
    white-space: nowrap;
}
.pill::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill-success { background: rgba(61,213,152,0.12); color: var(--success); }
.pill-danger  { background: rgba(255,77,109,0.12); color: var(--danger); }
.pill-warning { background: rgba(245,166,35,0.15); color: var(--accent); }
.pill-muted   { background: rgba(138,138,144,0.15); color: var(--muted); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1;
}

.btn-accent {
    background: var(--accent);
    color: #0A0A0B;
    border-color: var(--accent);
}
.btn-accent:hover {
    background: #FFB84D;
    border-color: #FFB84D;
    box-shadow: var(--accent-glow);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border-hl);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
    padding: 0.45rem 0.8rem;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }

.btn-danger { background: transparent; color: var(--danger); border-color: rgba(255,77,109,0.35); }
.btn-danger:hover { background: rgba(255,77,109,0.12); border-color: var(--danger); }

.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.72rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}
.form-label {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}
.form-input {
    background: var(--bg);
    border: 1px solid var(--border-hl);
    color: var(--text);
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    font-family: var(--sans);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}
.form-input::placeholder { color: var(--muted); opacity: 0.5; }
.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
select.form-input {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%238A8A90' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2rem;
    padding-right: 3rem;
}

/* Multi-select: drop the dropdown arrow and give selected options a
   warm accent band instead of the OS default blue strip. */
select[multiple].form-input {
    appearance: auto;
    background-image: none;
    padding: 0.3rem;
    padding-right: 0.3rem;
    cursor: default;
}
select[multiple].form-input option {
    padding: 0.45rem 0.7rem;
    border-radius: 6px;
    margin: 2px 0;
    color: var(--text);
    background: transparent;
    cursor: pointer;
    transition: background 0.12s;
}
select[multiple].form-input option:hover {
    background: var(--bg-hover);
}
/* linear-gradient overrides the native highlight in Chromium-based browsers. */
select[multiple].form-input option:checked {
    background: linear-gradient(0deg, var(--accent-dim), var(--accent-dim));
    color: var(--text);
    box-shadow: inset 3px 0 0 var(--accent);
    font-weight: 500;
}

.filter-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
}
.filter-group { display: flex; flex-direction: column; gap: 0.4rem; min-width: 160px; flex: 1; }

/* ============================================================
   SIDEBAR (MODERATION)
   ============================================================ */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}
.overlay.open { opacity: 1; pointer-events: all; }

.sidebar {
    position: fixed;
    top: 0; right: -520px;
    width: 520px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    z-index: 301;
    display: flex;
    flex-direction: column;
    transition: right 0.38s cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar.open { right: 0; box-shadow: -20px 0 60px rgba(0,0,0,0.6); }

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-title {
    font-family: var(--serif);
    font-size: 1.3rem;
}
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}
.sidebar-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ============================================================
   COMMENT CARDS
   ============================================================ */
.comment-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: border-color var(--transition);
}
.comment-card:hover { border-color: var(--border-hl); }
.comment-card.hidden-comment { opacity: 0.5; }

.comment-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
    gap: 0.5rem;
}
.comment-text {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 0.75rem;
}
.comment-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ============================================================
   LIST ITEMS (ACCOUNTS / FANPAGES)
   ============================================================ */
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.2rem;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg-hover); }
.list-name { font-weight: 500; font-size: 0.9rem; }
.list-sub { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.list-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ============================================================
   KEYWORDS / TAGS
   ============================================================ */
.keyword-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.keyword-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border-hl);
    border-radius: 99px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text);
    transition: all var(--transition);
}
.keyword-tag:hover { border-color: var(--accent); color: var(--accent); }
.keyword-tag button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.9rem;
    padding: 0;
    line-height: 1;
    transition: color var(--transition);
}
.keyword-tag:hover button { color: var(--danger); }

/* ============================================================
   HTMX LOADING
   ============================================================ */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.htmx-request.htmx-indicator { display: flex; }

.spinner {
    width: 28px; height: 28px;
    border: 2px solid var(--border-hl);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 1.5px; }

/* In-button spinner: keeps button width stable while request is in flight */
.btn-with-spinner { position: relative; }
.btn-with-spinner .btn-spinner { display: none; }
.btn-with-spinner.htmx-request { cursor: wait; pointer-events: none; }
.btn-with-spinner.htmx-request .btn-label { visibility: hidden; }
.btn-with-spinner.htmx-request .btn-spinner {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
}

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}
@media (max-width: 768px) { .auth-layout { grid-template-columns: 1fr; } }
.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
}
.auth-editorial {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 1.5rem;
    padding: 4rem;
    position: relative;
    overflow: hidden;
}
.auth-editorial::before {
    content: '';
    position: absolute;
    top: -30%;
    left: -20%;
    width: 70%;
    height: 70%;
    background: radial-gradient(ellipse, rgba(245,166,35,0.08) 0%, transparent 70%);
    pointer-events: none;
}
.auth-quote {
    font-family: var(--serif);
    font-size: clamp(1.6rem, 2.5vw, 2.4rem);
    font-weight: 700;
    line-height: 1.3;
    max-width: 420px;
    color: var(--text);
}
.auth-quote span { color: var(--accent); }
.auth-citation {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: 0.05em;
}
.auth-form-wrap { width: 100%; max-width: 380px; }
.auth-heading { font-size: 2rem; margin-bottom: 0.5rem; }
.auth-sub { color: var(--muted); font-size: 0.875rem; margin-bottom: 2.5rem; }
.auth-alt { text-align: center; margin-top: 1.5rem; font-size: 0.875rem; color: var(--muted); }
.auth-alt a { color: var(--accent); text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }
.auth-error {
    background: rgba(255,77,109,0.08);
    border: 1px solid rgba(255,77,109,0.35);
    color: #FF8FA3;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* ============================================================
   CHART WRAPPER
   ============================================================ */
.chart-wrap {
    position: relative;
    height: 280px;
    width: 100%;
}

/* ============================================================
   MODERATION DASHBOARD GRID
   ============================================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 1100px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    padding: 1.2rem 2.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.04em;
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.anim-enter { animation: fadeSlideUp 0.45s ease both; }
.anim-enter-1 { animation: fadeSlideUp 0.45s 0.05s ease both; }
.anim-enter-2 { animation: fadeSlideUp 0.45s 0.10s ease both; }
.anim-enter-3 { animation: fadeSlideUp 0.45s 0.15s ease both; }

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; gap: 0.75rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.85rem;
}

/* ── Toggle Switch ──────────────────────────────────────────── */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}
.toggle-switch input { display: none; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border, #333);
    border-radius: 22px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: #22c55e; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-switch--disabled { opacity: 0.4; cursor: not-allowed; }
