/**
 * Advertool.io — Shared Dashboard Styles
 * Dark-first premium design system.
 * Loaded by all dashboard pages.
 */

/* ── Variables (Dark-First) ──────────────────────────────────────────────── */
:root {
    color-scheme: dark;

    /* Background layers */
    --bg-base:       #0c0e14;
    --bg-surface-1:  #13151d;
    --bg-surface-2:  #1a1d27;
    --bg-surface-3:  #222530;

    /* Borders */
    --border-subtle:  #1e2130;
    --border-default: #2a2d3a;
    --border-strong:  #3a3d4a;

    /* Text */
    --text-primary:   #e8eaf0;
    --text-secondary: #9ba1b0;
    --text-muted:     #5c6170;

    /* Accents */
    --primary:         #7c6ef6;
    --primary-hover:   #9589fa;
    --primary-light:   rgba(124, 110, 246, 0.10);
    --primary-glow:    rgba(124, 110, 246, 0.25);
    --primary-surface: rgba(124, 110, 246, 0.10);
    --secondary:       #a78bfa;
    --success:         #34d399;
    --success-surface: rgba(52, 211, 153, 0.12);
    --warning:         #fbbf24;
    --warning-surface: rgba(251, 191, 36, 0.12);
    --danger:          #f87171;
    --danger-surface:  rgba(248, 113, 113, 0.12);
    --info:            #60a5fa;
    --info-surface:    rgba(96, 165, 250, 0.12);
    --purple:          #a78bfa;
    --purple-surface:  rgba(167, 139, 250, 0.12);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #7c6ef6 0%, #5a4fcf 100%);

    /* Legacy aliases (backward compat with inline var() refs) */
    --background:  var(--bg-surface-1);
    --foreground:  var(--text-primary);
    --border:      var(--border-default);
    --neutral-50:  var(--bg-surface-2);
    --neutral-100: var(--bg-surface-2);
    --neutral-200: var(--border-default);
    --neutral-300: var(--border-strong);
    --neutral-400: var(--text-muted);
    --neutral-500: var(--text-secondary);
    --neutral-600: var(--text-secondary);
    --neutral-700: var(--text-primary);
    --neutral-800: var(--text-primary);
    --neutral-900: var(--text-primary);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Animated Background Gradient ─────────────────────────────────────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 80% 50% at 20% 40%, rgba(124, 110, 246, 0.08) 0%, transparent 70%),
        radial-gradient(ellipse 60% 60% at 80% 20%, rgba(52, 211, 153, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 50% 70% at 60% 80%, rgba(96, 165, 250, 0.05) 0%, transparent 70%);
    background-size: 200% 200%;
    animation: gradientDrift 20s ease-in-out infinite;
    pointer-events: none;
}

@keyframes gradientDrift {
    0%, 100% { background-position: 0% 0%; }
    25%      { background-position: 100% 50%; }
    50%      { background-position: 50% 100%; }
    75%      { background-position: 0% 50%; }
}

/* ── Custom Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── App Layout ───────────────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    width: 260px;
    background: var(--bg-base);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-brand {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand-icon {
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary-surface);
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-nav { padding: 0.75rem 0; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    margin: 2px 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
}

.nav-item:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}
.nav-item:hover .nav-item-icon { color: var(--text-secondary); }

.nav-item.active {
    background: var(--primary-surface);
    color: var(--primary);
    box-shadow: inset 3px 0 0 var(--primary);
}

.nav-item-icon { flex-shrink: 0; color: var(--text-muted); }
.nav-item.active .nav-item-icon { color: var(--primary); }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
}

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: 260px;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    background: var(--bg-base);
    flex-shrink: 0;
    z-index: 10;
    gap: 1rem;
}

.header-left { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

.header-title h1 {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.header-subtitle {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 0.2rem;
}

.header-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

/* ── User Avatar ──────────────────────────────────────────────────────────── */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease;
    flex-shrink: 0;
}
.user-avatar:hover { background: var(--border-strong); }

/* ── Content Scroll Container ─────────────────────────────────────────────── */
.content-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.content {
    padding: 2rem;
    min-width: 0;
    animation: fadeIn 0.3s ease-out;
}

/* ── Horizontal Table Scroll ──────────────────────────────────────────────── */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-scroll table {
    min-width: 650px;
}

/* ── Stats Grid ───────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    padding: 1px;
    background: linear-gradient(135deg, transparent 40%, var(--primary-glow));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.stat-card:hover::before { opacity: 1; }

.stat-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.stat-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}
.stat-icon.primary { background: var(--primary-surface); color: var(--primary); }
.stat-icon.success { background: var(--success-surface); color: var(--success); }
.stat-icon.warning { background: var(--warning-surface); color: var(--warning); }
.stat-icon.purple  { background: var(--purple-surface); color: var(--purple); }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

/* ── Status Tabs ──────────────────────────────────────────────────────────── */
.status-tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }

.status-tab {
    padding: 0.35rem 0.85rem;
    border-radius: 99px;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid var(--border-default);
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}
.status-tab:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.status-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

/* ── Export Button ────────────────────────────────────────────────────────── */
.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--bg-surface-3);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
}
.btn-export:hover:not(:disabled) {
    background: var(--border-strong);
    border-color: var(--text-muted);
}
.btn-export:disabled {
    background: var(--bg-surface-2);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* ── Empty / Loading / Error States ──────────────────────────────────────── */
.empty-msg {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.empty-state {
    padding: 3rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--bg-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.empty-state-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.empty-state-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    max-width: 320px;
    line-height: 1.5;
}

.empty-state-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
}
.empty-state-action:hover { text-decoration: underline; }

.error-state {
    padding: 3rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.error-state-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--danger-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--danger);
    margin-bottom: 0.25rem;
}

.error-state-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--danger);
}

.error-state-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    max-width: 360px;
    line-height: 1.5;
}

.loading-state {
    padding: 3rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-default);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ── Mobile Menu ──────────────────────────────────────────────────────────── */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
    flex-shrink: 0;
}

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

/* ── Micro-Animations ─────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--bg-surface-3) 50%, var(--bg-surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

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

@media (max-width: 768px) {
    .mobile-menu-btn { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 100;
    }
    .sidebar.open { transform: translateX(0); }

    .main-content { margin-left: 0; }

    .stats-grid { grid-template-columns: 1fr; gap: 1rem; }

    .header {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }
    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    .header-title h1 { font-size: 1.125rem; }

    .content { padding: 1rem; }
}

@media (max-width: 640px) {
    .stats-grid { gap: 0.75rem; }
    .stat-value { font-size: 1.5rem; }
    .stat-card { padding: 1.25rem; }
    .stat-card:hover { transform: none; }

    .status-tabs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .status-tabs::-webkit-scrollbar { display: none; }
    .status-tab { font-size: 0.75rem; padding: 0.3rem 0.7rem; flex-shrink: 0; }

    .btn-export { width: 100%; justify-content: center; }

    .table-scroll table { font-size: 0.8125rem; }
}

@media (max-width: 480px) {
    .content { padding: 0.75rem; }
    .header { padding: 0.75rem; gap: 0.75rem; }
    .header-title h1 { font-size: 1rem; }
    .header-subtitle { font-size: 0.75rem; }
    .stats-grid { gap: 0.625rem; }
    .stat-card { padding: 1rem; border-radius: 10px; }
    .stat-value { font-size: 1.25rem; }
    .stat-label { font-size: 0.8125rem; }
    .stat-icon { width: 36px; height: 36px; border-radius: 8px; }
    .footer { padding: 1rem; font-size: 0.8125rem; }
}
