/* Copareo Analytics Dashboard - Dark Theme */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-hover: #242430;
    
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b7b;
    
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --border-color: #2a2a3a;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Header */
.dashboard-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.live-indicator {
    font-size: 0.75rem;
    color: var(--success);
    animation: pulse 2s infinite;
}

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

/* KPI Cards */
.kpi-cards {
    display: flex;
    gap: 1rem;
    flex: 1;
    justify-content: center;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    min-width: 140px;
    text-align: center;
    transition: all 0.2s ease;
}

.kpi-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.kpi-card.highlight {
    background: var(--accent-gradient);
    border: none;
}

.kpi-card.highlight .kpi-label {
    color: rgba(255, 255, 255, 0.9);
}

.kpi-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.kpi-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.kpi-trend {
    font-size: 0.7rem;
    font-weight: 500;
}

.kpi-trend.positive { color: var(--success); }
.kpi-trend.negative { color: var(--danger); }

.header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.btn-refresh {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

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

.last-update {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Main Layout */
.dashboard-main {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    min-height: calc(100vh - 80px);
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Funnel */
.funnel-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.funnel-stage {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.funnel-bar {
    height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    width: calc(var(--width) * 0.6);
    min-width: 60px;
    transition: width 0.5s ease;
}

.funnel-stage[data-stage="visit"] .funnel-bar { background: var(--info); }
.funnel-stage[data-stage="lead"] .funnel-bar { background: var(--accent-primary); }
.funnel-stage[data-stage="engaged"] .funnel-bar { background: var(--accent-secondary); }
.funnel-stage[data-stage="trial"] .funnel-bar { background: var(--warning); }
.funnel-stage[data-stage="paid"] .funnel-bar { background: var(--success); }

.funnel-info {
    display: flex;
    flex-direction: column;
}

.stage-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stage-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.funnel-arrow {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-left: 1rem;
}

/* Email Sequence */
.email-sequence {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.email-step {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

.email-step:hover {
    border-color: var(--accent-primary);
}

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.step-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.step-count {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.step-metrics {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.step-metrics .metric {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.step-metrics .metric b {
    color: var(--text-primary);
}

.step-bar {
    height: 4px;
    background: var(--bg-hover);
    border-radius: 2px;
    overflow: hidden;
}

.step-progress {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* Ads Table */
.ads-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.ads-table th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

.ads-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.ads-table tr:hover td {
    background: var(--bg-hover);
}

.ads-table .loading {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.active { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.status-badge.paused { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.status-badge.review { background: rgba(59, 130, 246, 0.2); color: var(--info); }

/* Chart */
.chart-card canvas {
    max-height: 250px;
}

/* Angles Grid */
.angles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.angle-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.angle-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.angle-leads {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.angle-rate {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* AI Panel */
.ai-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 100px;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.ai-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.btn-analyze {
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-analyze:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-analyze:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-analyze.loading {
    background: var(--bg-hover);
}

.ai-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.8rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.ai-status.analyzing .status-dot {
    background: var(--warning);
    animation: pulse 1s infinite;
}

.ai-current-analysis {
    margin-bottom: 1.5rem;
}

.analysis-placeholder {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
}

.analysis-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
    font-size: 0.85rem;
    line-height: 1.7;
    max-height: 400px;
    overflow-y: auto;
}

.analysis-content h4 {
    color: var(--accent-primary);
    margin: 1rem 0 0.5rem;
    font-size: 0.9rem;
}

.analysis-content h4:first-child {
    margin-top: 0;
}

.analysis-content ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.analysis-content li {
    margin-bottom: 0.25rem;
}

/* Alerts */
.ai-alerts {
    margin-bottom: 1.5rem;
}

.ai-alerts h3, .ai-history h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    border-left: 3px solid transparent;
}

.alert-item.danger { border-left-color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.alert-item.warning { border-left-color: var(--warning); background: rgba(245, 158, 11, 0.1); }
.alert-item.success { border-left-color: var(--success); background: rgba(16, 185, 129, 0.1); }
.alert-item.info { border-left-color: var(--info); background: rgba(59, 130, 246, 0.1); }

/* History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.history-item:hover {
    background: var(--bg-hover);
}

.history-date {
    color: var(--text-muted);
}

.history-summary {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Footer */
.dashboard-footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border-color);
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 1200px) {
    .dashboard-main {
        grid-template-columns: 1fr;
    }
    
    .ai-panel {
        position: static;
    }
    
    .kpi-cards {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .kpi-cards {
        width: 100%;
        justify-content: space-between;
    }
    
    .kpi-card {
        min-width: 100px;
    }
}

