/**
 * CampagnaElettorale.net — Backend/Dashboard Design System
 * Design: "Kinetic Governance"
 * Palette: True Dark (#09090B) + Electric Blue (#3B82F6) + Emerald (#10B981)
 * Fonts: Inter + JetBrains Mono (metrics)
 */

:root {
    --bg-canvas: #09090B;
    --bg-card: #18181B;
    --bg-surface-low: #1c1b1d;
    --bg-surface: #201f22;
    --bg-surface-high: #2a2a2c;
    --bg-surface-highest: #353437;

    --color-primary: #FAFAFA;
    --color-on-primary: #09090B;
    --color-blue: #3B82F6;
    --color-emerald: #10B981;
    --color-red: #EF4444;
    --color-secondary: #adc6ff;

    --color-text: #e5e1e4;
    --color-text-variant: #c4c7c8;
    --color-text-muted: #A1A1AA;
    --color-border: #27272A;
    --color-outline-variant: #444748;

    --sidebar-width: 240px;
    --topbar-height: 64px;
    --container-padding: 24px;
    --card-gap: 20px;
    --gutter: 16px;

    --rounded-sm: 2px;
    --rounded: 4px;
    --rounded-md: 6px;
    --rounded-lg: 8px;
    --rounded-xl: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--bg-canvas);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }
::selection { background: rgba(59, 130, 246, 0.3); }

/* Typography */
.text-display { font-size: 48px; font-weight: 700; line-height: 56px; letter-spacing: -0.04em; }
.text-headline-lg { font-size: 32px; font-weight: 600; line-height: 40px; letter-spacing: -0.02em; }
.text-headline-md { font-size: 24px; font-weight: 600; line-height: 32px; letter-spacing: -0.02em; }
.text-body-lg { font-size: 18px; line-height: 28px; }
.text-body-md { font-size: 16px; line-height: 24px; }
.text-body-sm { font-size: 14px; line-height: 20px; }
.text-label-caps { font-size: 12px; font-weight: 600; line-height: 16px; letter-spacing: 0.05em; text-transform: uppercase; }
.text-mono { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 500; line-height: 20px; }

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-surface-low);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    padding: var(--gutter) 16px;
    z-index: 50;
    overflow-y: auto;
}
.sidebar-brand { margin-bottom: 32px; padding: 0 8px; }
.sidebar-brand-row { display: flex; align-items: center; gap: 12px; }
.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--rounded);
    background: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-brand-icon .material-symbols-outlined { color: var(--bg-canvas); font-size: 18px; }
.sidebar-brand-title { font-size: 16px; font-weight: 600; color: var(--color-primary); }
.sidebar-brand-subtitle { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--color-text-muted); }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--rounded-lg);
    color: var(--color-text-variant);
    transition: background 0.2s, color 0.2s;
    font-size: 16px;
}
.sidebar-link:hover { background: rgba(255,255,255,0.05); color: var(--color-primary); }
.sidebar-link.active { background: rgba(255,255,255,0.05); color: var(--color-primary); font-weight: 700; }
.sidebar-link .material-symbols-outlined { font-size: 20px; }
.sidebar-footer { margin-top: auto; padding-top: 24px; border-top: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 2px; }

.sidebar-cta {
    display: block;
    width: 100%;
    margin-bottom: 16px;
    padding: 8px 16px;
    background: var(--color-primary);
    color: var(--bg-canvas);
    font-weight: 700;
    font-size: 14px;
    border-radius: var(--rounded);
    border: none;
    text-align: center;
    transition: opacity 0.2s;
}
.sidebar-cta:hover { opacity: 0.9; }

/* Topbar */
.topbar {
    position: fixed;
    top: 0;
    right: 0;
    width: calc(100% - var(--sidebar-width));
    height: var(--topbar-height);
    background: rgba(9, 9, 11, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--container-padding);
    z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: 24px; }
.topbar-search {
    position: relative;
}
.topbar-search .material-symbols-outlined {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    transition: color 0.2s;
}
.topbar-search-input {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--rounded-lg);
    padding: 6px 16px 6px 40px;
    font-size: 14px;
    color: var(--color-text);
    width: 320px;
    outline: none;
    transition: border-color 0.2s, width 0.3s;
    font-family: 'Inter', sans-serif;
}
.topbar-search-input:focus {
    border-color: var(--color-primary);
    width: 384px;
}
.topbar-search-input::placeholder { color: var(--color-text-muted); }
.topbar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: var(--bg-surface);
    border-radius: 9999px;
    border: 1px solid var(--color-border);
}
.topbar-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-emerald);
    animation: pulse-dot 3s infinite;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.topbar-status-text { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--color-text-variant); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-icon-btn {
    background: none;
    border: none;
    color: var(--color-text-variant);
    transition: color 0.2s;
    padding: 4px;
}
.topbar-icon-btn:hover { color: var(--color-primary); }
.topbar-divider { width: 1px; height: 32px; background: var(--color-border); margin: 0 8px; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-user-info { text-align: right; }
.topbar-user-name { font-size: 12px; font-weight: 700; color: var(--color-primary); }
.topbar-user-role { font-size: 10px; color: var(--color-text-muted); }
.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    object-fit: cover;
    background: var(--bg-surface-high);
}

/* Main content area */
.main-content {
    margin-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
    min-height: 100vh;
    padding: calc(var(--topbar-height) + 16px) var(--container-padding) var(--container-padding);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 32px;
    margin-top: 16px;
}
.page-header-title { color: var(--color-primary); }
.page-header-subtitle { color: var(--color-text-muted); margin-top: 4px; }
.page-header-actions { display: flex; gap: 12px; }

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--card-gap);
    margin-bottom: 32px;
}
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--rounded-xl);
    padding: 24px;
    transition: border-color 0.2s;
}
.kpi-card:hover { border-color: rgba(161, 161, 170, 0.3); }
.kpi-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}
.kpi-card-label { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--color-text-muted); }
.kpi-card-icon { font-size: 24px; }
.kpi-card-icon.blue { color: var(--color-blue); }
.kpi-card-icon.emerald { color: var(--color-emerald); }
.kpi-card-icon.red { color: var(--color-red); }
.kpi-card-value { font-family: 'JetBrains Mono', monospace; font-size: 24px; font-weight: 600; color: var(--color-primary); }
.kpi-card-trend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}
.kpi-trend-pill {
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
}
.kpi-trend-pill.positive { color: var(--color-emerald); background: rgba(16, 185, 129, 0.1); }
.kpi-trend-pill.negative { color: var(--color-red); background: rgba(239, 68, 68, 0.1); }
.kpi-trend-pill.blue { color: var(--color-blue); background: rgba(59, 130, 246, 0.1); }
.kpi-trend-text { font-size: 11px; color: var(--color-text-muted); }

.kpi-progress-bar {
    margin-top: 24px;
    height: 4px;
    background: var(--color-border);
    border-radius: 9999px;
    overflow: hidden;
}
.kpi-progress-fill { height: 100%; border-radius: 9999px; }
.kpi-progress-fill.emerald { background: var(--color-emerald); box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
.kpi-progress-fill.blue { background: var(--color-blue); }
.kpi-progress-fill.white { background: var(--color-primary); }

/* Stripe status card */
.stripe-status-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 12px;
    border-radius: var(--rounded-lg);
}
.stripe-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-emerald);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    flex-shrink: 0;
}
.stripe-status-title { font-size: 12px; font-weight: 700; color: var(--color-emerald); }
.stripe-status-subtitle { font-size: 10px; color: var(--color-text-muted); }

/* Analytics Grid */
.analytics-grid {
    display: grid;
    grid-template-columns: 7fr 3fr;
    gap: var(--card-gap);
    margin-bottom: 32px;
}

/* Chart Card */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--rounded-xl);
    padding: 24px;
    display: flex;
    flex-direction: column;
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}
.chart-title { font-size: 18px; font-weight: 600; color: var(--color-primary); }
.chart-subtitle { font-size: 12px; color: var(--color-text-muted); }
.chart-area { position: relative; flex: 1; min-height: 256px; }
.chart-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    padding: 0 4px;
}
.chart-label { font-size: 10px; color: var(--color-text-muted); }

/* Data Table Card */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--rounded-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.table-card-header {
    padding: 24px;
    border-bottom: 1px solid var(--color-border);
}
.table-card-title { font-size: 16px; font-weight: 600; color: var(--color-primary); }
.table-card-body { flex: 1; overflow-y: auto; }
.table-card-footer {
    padding: 16px;
    text-align: center;
    border-top: 1px solid var(--color-border);
    background: rgba(255,255,255,0.05);
}
.table-card-footer a {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: color 0.2s;
}
.table-card-footer a:hover { color: var(--color-primary); }

/* Data Table */
.data-table { width: 100%; text-align: left; border-collapse: collapse; }
.data-table thead th {
    padding: 12px 24px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
}
.data-table tbody tr { transition: background 0.15s; cursor: pointer; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.data-table tbody td { padding: 16px 24px; border-bottom: 1px solid var(--color-border); }
.data-table .donor-name { font-size: 12px; font-weight: 700; color: var(--color-primary); }
.data-table .donor-status { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.data-table .donor-status .material-symbols-outlined { font-size: 10px; }
.data-table .donor-status-text { font-size: 10px; color: var(--color-text-muted); }
.data-table .amount { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--color-primary); }
.data-table .time-ago { font-size: 10px; color: var(--color-text-muted); }

/* Buttons */
.btn-b-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--color-primary);
    color: var(--bg-canvas);
    padding: 8px 16px;
    border-radius: var(--rounded);
    font-weight: 700;
    font-size: 14px;
    border: none;
    transition: opacity 0.2s;
}
.btn-b-primary:hover { opacity: 0.9; }

.btn-b-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 8px 16px;
    border-radius: var(--rounded-lg);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-b-secondary:hover { background: rgba(255,255,255,0.05); }

.btn-b-ghost {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: opacity 0.2s;
}
.btn-b-ghost:hover { text-decoration: underline; }

/* Forms */
.form-b-group { margin-bottom: 16px; }
.form-b-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}
.form-b-input, .form-b-select, .form-b-textarea {
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--rounded-md);
    color: var(--color-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-b-input:focus, .form-b-select:focus, .form-b-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(250, 250, 250, 0.1);
}
.form-b-textarea { min-height: 120px; resize: vertical; }
.form-b-select { -webkit-appearance: none; appearance: none; }

/* Banner */
.promo-banner {
    position: relative;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--rounded-xl);
    padding: 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.promo-banner-content { position: relative; z-index: 10; }
.promo-banner-title { font-size: 20px; font-weight: 600; color: var(--color-primary); margin-bottom: 8px; }
.promo-banner-text { color: var(--color-text-muted); max-width: 512px; margin-bottom: 24px; }
.promo-banner-actions { display: flex; gap: 16px; }
.promo-banner-icons { display: flex; gap: 16px; position: relative; z-index: 10; }
.promo-banner-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--rounded-xl);
    display: flex;
    align-items: center;
    justify-content: center;
}
.promo-banner-bg {
    position: absolute;
    right: 0;
    top: 0;
    width: 33%;
    height: 100%;
    background: linear-gradient(to left, rgba(59, 130, 246, 0.05), transparent);
    pointer-events: none;
}

/* Chips / Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-active { background: rgba(16, 185, 129, 0.15); color: var(--color-emerald); }
.badge-pending { background: rgba(59, 130, 246, 0.15); color: var(--color-blue); }
.badge-expired { background: rgba(239, 68, 68, 0.15); color: var(--color-red); }
.badge-draft { background: rgba(161, 161, 170, 0.15); color: var(--color-text-muted); }
.badge-published { background: rgba(16, 185, 129, 0.15); color: var(--color-emerald); }
.badge-succeeded { background: rgba(16, 185, 129, 0.15); color: var(--color-emerald); }
.badge-failed { background: rgba(239, 68, 68, 0.15); color: var(--color-red); }

/* Alert messages */
.alert {
    padding: 12px 16px;
    border-radius: var(--rounded-lg);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.2); color: var(--color-emerald); }
.alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.2); color: var(--color-red); }
.alert-info { background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.2); color: var(--color-blue); }

/* Custom scrollbar */
.custom-scrollbar::-webkit-scrollbar { width: 4px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 10px; }

/* Glass panel */
.glass-panel {
    background: rgba(24, 24, 27, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid var(--color-border);
}

/* Auth page (login/register) */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--rounded-xl);
    padding: 48px;
    width: 100%;
    max-width: 440px;
}
.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}
.auth-brand-title { font-size: 24px; font-weight: 700; color: var(--color-primary); }
.auth-brand-subtitle { font-size: 14px; color: var(--color-text-muted); margin-top: 4px; }

/* Responsive */
@media (max-width: 1024px) {
    .analytics-grid { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .topbar { width: 100%; }
    .main-content { margin-left: 0; }
    .kpi-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: stretch; gap: 16px; }
    .page-header-actions { justify-content: stretch; }
}

/* Utility */
.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; vertical-align: middle; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-auto { margin-top: auto; }
.mb-0 { margin-bottom: 0; }
.w-full { width: 100%; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
