/* =========================================================
   Ads Analysis – Modern Admin Dashboard Styles
   ========================================================= */

/* ---------- CSS Variables ---------- */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 64px;

    /* Colors */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --accent: #06b6d4;
    --accent-light: #22d3ee;

    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(99, 102, 241, 0.15);
    --sidebar-active: rgba(99, 102, 241, 0.25);
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;

    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.04);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-info:    linear-gradient(135deg, #06b6d4 0%, #22d3ee 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    --gradient-danger:  linear-gradient(135deg, #ef4444 0%, #f87171 100%);
    --gradient-dark:    linear-gradient(135deg, #1e293b 0%, #334155 100%);
}


/* ---------- Global Reset & Typography ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a { color: var(--primary); transition: color var(--transition-fast); }
a:hover { color: var(--primary-dark); }

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}


/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-slow);
    overflow: hidden;
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    text-decoration: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    min-height: 72px;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.sidebar-brand-text small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--sidebar-text);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 16px 12px 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    text-decoration: none !important;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 2px;
    position: relative;
}

.sidebar-link:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-hover);
}

.sidebar-link.active {
    color: var(--sidebar-text-active);
    background: var(--sidebar-active);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-link .badge {
    margin-left: auto;
    font-size: 0.68rem;
    padding: 3px 8px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
}

.sidebar-user-role {
    font-size: 0.72rem;
    color: var(--sidebar-text);
}


/* =========================================================
   MAIN CONTENT AREA
   ========================================================= */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

/* Top Bar */
.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-title i {
    color: var(--primary);
    margin-right: 8px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none !important;
}

.topbar-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Content wrapper */
.content-wrapper {
    padding: 28px;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}


/* =========================================================
   CARDS (Override Bootstrap)
   ========================================================= */
.card {
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    background: var(--card-bg);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-secondary);
    padding: 14px 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.card-header i {
    color: var(--primary);
    margin-right: 6px;
}

.card-body {
    padding: 20px;
}

.card-footer {
    background: transparent;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding: 14px 20px;
}


/* =========================================================
   STAT CARDS (Dashboard summary)
   ========================================================= */
.stat-card {
    border: none;
    border-radius: var(--radius-lg);
    color: #fff;
    overflow: hidden;
    position: relative;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.stat-card .card-body {
    position: relative;
    z-index: 2;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -30%;
    right: -20%;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    z-index: 1;
}

.stat-card::before {
    content: '';
    position: absolute;
    bottom: -40%;
    right: 10%;
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
    z-index: 1;
}

.stat-card.gradient-primary { background: var(--gradient-primary); }
.stat-card.gradient-success { background: var(--gradient-success); }
.stat-card.gradient-info    { background: var(--gradient-info); }
.stat-card.gradient-warning { background: var(--gradient-warning); }
.stat-card.gradient-danger  { background: var(--gradient-danger); }
.stat-card.gradient-dark    { background: var(--gradient-dark); }

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.3;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.stat-card .stat-label {
    font-size: 0.78rem;
    font-weight: 500;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.stat-card .stat-sub {
    font-size: 0.82rem;
    opacity: 0.7;
    margin-top: 2px;
}


/* =========================================================
   TABLES
   ========================================================= */
.table {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.table > thead {
    background: #f8fafc;
}

.table > thead th {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid rgba(0, 0, 0, 0.06);
    padding: 12px 16px;
    white-space: nowrap;
}

.table > tbody > tr {
    transition: background var(--transition-fast);
}

.table-hover > tbody > tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

.table > tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-color: rgba(0, 0, 0, 0.04);
}

/* Override dark table header for campaign list */
.table-dark th, thead.table-dark th {
    background: var(--sidebar-bg) !important;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: none;
}


/* =========================================================
   BADGES
   ========================================================= */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 5px 10px;
    border-radius: 20px;
    letter-spacing: 0.03em;
    text-transform: capitalize;
}

.badge.bg-success { background: #10b981 !important; }
.badge.bg-danger  { background: #ef4444 !important; }
.badge.bg-warning { background: #f59e0b !important; color: #fff !important; }
.badge.bg-info    { background: #06b6d4 !important; }
.badge.bg-secondary { background: #64748b !important; }
.badge.bg-dark    { background: #334155 !important; }
.badge.bg-primary { background: var(--primary) !important; }


/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    transition: all var(--transition-base);
    letter-spacing: 0.01em;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--gradient-primary);
    border: none;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--gradient-success);
    border: none;
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-outline-danger:hover {
    background: #ef4444;
    border-color: #ef4444;
}

.btn-outline-warning:hover {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #fff;
}

.btn-outline-info:hover {
    background: #06b6d4;
    border-color: #06b6d4;
    color: #fff;
}

.btn-outline-secondary {
    border-color: #cbd5e1;
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: var(--text-primary);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
}


/* =========================================================
   FORMS
   ========================================================= */
.form-control, .form-select {
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control-lg {
    padding: 14px 18px;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

.input-group .form-control {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.input-group .btn {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}


/* =========================================================
   ALERTS
   ========================================================= */
.alert {
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    padding: 14px 20px;
    font-weight: 500;
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    color: #0e7490;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
}


/* =========================================================
   PROGRESS BARS
   ========================================================= */
.progress {
    border-radius: 20px;
    background: #e2e8f0;
    overflow: hidden;
}

.progress-bar {
    border-radius: 20px;
    transition: width var(--transition-slow);
}


/* =========================================================
   HEATMAP CANVAS
   ========================================================= */
#heatmapCanvas {
    border-radius: var(--radius-sm);
    background: #fafbfc;
}


/* =========================================================
   PAGE HEADER (detail pages)
   ========================================================= */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.page-header h4 {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header h4 i {
    color: var(--primary);
}

.page-header .actions {
    display: flex;
    gap: 8px;
}


/* =========================================================
   CHART CONTAINERS
   ========================================================= */
.chart-card canvas {
    max-height: 260px;
}


/* =========================================================
   EMPTY STATE
   ========================================================= */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 0;
}


/* =========================================================
   CAMPAIGN REPORT SECTION
   ========================================================= */
.report-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0 24px;
}

.report-divider h5 {
    margin: 0;
    white-space: nowrap;
    font-size: 1rem;
    color: var(--text-secondary);
}

.report-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
}


/* =========================================================
   LOGIN PAGE
   ========================================================= */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    top: -200px;
    left: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
    animation: float 20s ease-in-out infinite;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    bottom: -200px;
    right: -200px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.12) 0%, transparent 70%);
    animation: float 25s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(30px, -30px); }
    66% { transform: translate(-20px, 20px); }
}

.login-card {
    max-width: 420px;
    width: 100%;
    z-index: 10;
    padding: 0 20px;
}

.login-card .card {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
}

.login-card .card-body {
    padding: 48px 40px;
}

.login-brand-icon {
    width: 64px;
    height: 64px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    margin: 0 auto 16px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.login-card h3 {
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.login-card .text-muted {
    color: var(--text-secondary) !important;
    font-size: 0.88rem;
}

.login-card .btn-primary {
    padding: 14px;
    font-size: 1rem;
    border-radius: var(--radius-md);
}


/* =========================================================
   ANIMATIONS
   ========================================================= */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.animate-in {
    animation: fadeInUp 0.5s ease forwards;
}

.content-wrapper .row {
    animation: fadeIn 0.4s ease;
}

/* Staggered animation for stat cards */
.stat-card:nth-child(1) { animation: fadeInUp 0.4s ease 0.05s both; }
.stat-card:nth-child(2) { animation: fadeInUp 0.4s ease 0.10s both; }
.stat-card:nth-child(3) { animation: fadeInUp 0.4s ease 0.15s both; }
.stat-card:nth-child(4) { animation: fadeInUp 0.4s ease 0.20s both; }


/* =========================================================
   SCROLLBAR (Global)
   ========================================================= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }


/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }

    .sidebar-backdrop.show {
        display: block;
    }

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

    .sidebar-toggle {
        display: block;
    }

    .content-wrapper {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .stat-card .stat-value {
        font-size: 1.4rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header .actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 12px;
    }

    .topbar-title {
        font-size: 0.95rem;
    }

    .card-body { padding: 14px; }
    .card-header { padding: 12px 14px; }

    .table > thead th,
    .table > tbody td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
}


/* =========================================================
   UTILITY OVERRIDES
   ========================================================= */
.text-muted { color: var(--text-muted) !important; }

.fw-bold, .fw-bolder { font-weight: 700 !important; }

code {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* Override Bootstrap container-fluid padding within sidebar layout */
.main-content .container-fluid {
    padding: 0;
}

/* Make the .container-fluid act as content-wrapper if no .content-wrapper exists */
.main-content > .container-fluid {
    padding: 28px;
}

@media (max-width: 991.98px) {
    .main-content > .container-fluid {
        padding: 16px;
    }
}
