/* ================================================================
   AdTrack Pro — Enhanced Styles
   ================================================================ */

:root {
    --bg-primary: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-table: #16213e;
    --text-primary: #e0e0e0;
    --text-muted: #8a8a9a;
    --accent-blue: #0d6efd;
    --accent-green: #198754;
    --accent-yellow: #ffc107;
    --accent-red: #dc3545;
    --accent-purple: #6f42c1;
    --accent-cyan: #0dcaf0;
    --quality-excellent: #34d399;
    --quality-good: #60a5fa;
    --quality-fair: #fbbf24;
    --quality-poor: #f97316;
    --quality-bad: #ef4444;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.navbar {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a3e 100%) !important;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.nav-tabs {
    border-bottom-color: rgba(255,255,255,0.1);
}

.nav-tabs .nav-link {
    color: var(--text-muted);
    border: none;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
}

.nav-tabs .nav-link:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}

.nav-tabs .nav-link.active {
    color: var(--accent-blue);
    background: transparent;
    border-bottom: 2px solid var(--accent-blue);
}

/* KPI Cards */
.kpi-card {
    border: none;
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.kpi-card .card-body {
    padding: 1.2rem;
}

.kpi-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
    margin-bottom: 0.3rem;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-sub {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
}

.card-header {
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
}

.card-body {
    padding: 1rem;
}

/* ===== QUALITY SCORE BADGE ===== */
.quality-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.quality-excellent { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.quality-good { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
.quality-fair { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.quality-poor { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.quality-bad { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* Quality Score Gauge */
.quality-gauge {
    width: 120px;
    height: 120px;
    margin: 0 auto;
    position: relative;
}

.quality-gauge canvas {
    width: 100%;
    height: 100%;
}

.quality-gauge .gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    font-weight: 800;
    text-align: center;
    line-height: 1;
}

.quality-gauge .gauge-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
    display: block;
}

/* Campaign badge */
.campaign-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    background: rgba(13, 110, 253, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(13, 110, 253, 0.2);
}

/* Alert badge */
.alert-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.alert-badge:hover { transform: translateY(-1px); }

.alert-badge.bot { background: rgba(220, 53, 69, 0.2); color: #ef4444; }
.alert-badge.quality { background: rgba(249, 115, 22, 0.2); color: #f97316; }
.alert-badge.duplicate { background: rgba(13, 202, 240, 0.2); color: #0dcaf0; }
.alert-badge.info { background: rgba(96, 165, 250, 0.2); color: #60a5fa; }

/* Alert bar */
.alert-bar {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.2);
    border-radius: 8px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: alert-pulse 2s infinite;
}

@keyframes alert-pulse {
    0% { background: rgba(220, 53, 69, 0.1); }
    50% { background: rgba(220, 53, 69, 0.15); }
    100% { background: rgba(220, 53, 69, 0.1); }
}

/* ===== TABLES ===== */
.table {
    margin-bottom: 0;
    font-size: 0.85rem;
}

.table-dark {
    --bs-table-bg: var(--bg-table);
}

.table > :not(:first-child) {
    border-top: 1px solid rgba(255,255,255,0.05);
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.table td {
    vertical-align: middle;
    border-color: rgba(255,255,255,0.03);
}

.table-warning {
    --bs-table-bg: rgba(255, 193, 7, 0.1) !important;
}

.table-danger {
    --bs-table-bg: rgba(220, 53, 69, 0.1) !important;
}

/* Badge */
#liveBadge {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Chart canvas */
#performanceChart {
    max-height: 300px;
}

/* Code blocks */
code {
    background: rgba(255,255,255,0.1);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--accent-yellow);
}

pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

pre {
    font-size: 0.8rem;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Alerts */
.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.2);
    color: var(--accent-yellow);
}

.alert-info {
    background: rgba(13, 110, 253, 0.1);
    border: 1px solid rgba(13, 110, 253, 0.2);
    color: var(--accent-blue);
}

.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.2);
    color: var(--accent-red);
}

/* Pagination */
.pagination {
    --bs-pagination-bg: var(--bg-table);
    --bs-pagination-border-color: rgba(255,255,255,0.1);
    --bs-pagination-color: var(--text-primary);
    --bs-pagination-hover-bg: rgba(255,255,255,0.1);
    --bs-pagination-hover-color: var(--text-primary);
    --bs-pagination-active-bg: var(--accent-blue);
    --bs-pagination-active-border-color: var(--accent-blue);
}

/* Buttons */
.btn-outline-secondary {
    color: var(--text-muted);
    border-color: rgba(255,255,255,0.15);
}

.btn-outline-secondary:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.3);
}

.btn-outline-secondary.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* Form controls */
.form-control, .form-select {
    background: var(--bg-table);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    background: var(--bg-table);
    border-color: var(--accent-blue);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* ===== PROGRESS BAR ===== */
.progress {
    background: rgba(255,255,255,0.05);
    border-radius: 20px;
    overflow: hidden;
}

.progress-bar {
    transition: width 0.5s ease;
}

/* Quality score bar */
.qs-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.05);
    overflow: hidden;
    position: relative;
}

.qs-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.live-toast {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 12px 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    animation: slideIn 0.3s ease;
    max-width: 400px;
    font-size: 0.85rem;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.live-toast .toast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.live-toast .toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
}

.live-toast .toast-type { font-weight: 600; }
.live-toast .toast-type.bot { color: #ef4444; }
.live-toast .toast-type.quality { color: #f97316; }
.live-toast .toast-type.duplicate { color: #0dcaf0; }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* Responsive */
@media (max-width: 768px) {
    .kpi-value {
        font-size: 1.4rem;
    }
    .nav-tabs .nav-link {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }
    .quality-gauge {
        width: 80px;
        height: 80px;
    }
    .quality-gauge .gauge-value {
        font-size: 1.2rem;
    }
}
