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

:root {
    --bg: #0a0a0f;
    --bg-card: rgba(17, 17, 27, 0.8);
    --bg-card-hover: rgba(25, 25, 40, 0.9);
    --border: rgba(255, 255, 255, 0.06);
    --text: #e4e4e7;
    --text-dim: #71717a;
    --text-muted: #52525b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --green: #22c55e;
    --green-glow: rgba(34, 197, 94, 0.3);
    --red: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.3);
    --yellow: #eab308;
    --yellow-glow: rgba(234, 179, 8, 0.3);
    --blue: #3b82f6;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0,0,0,0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Background Glow Effects ───────────────────────────────────── */
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}
.bg-glow-1 {
    width: 600px; height: 600px;
    background: var(--accent);
    top: -200px; left: -100px;
    animation: float1 20s ease-in-out infinite;
}
.bg-glow-2 {
    width: 400px; height: 400px;
    background: #8b5cf6;
    bottom: -100px; right: -100px;
    animation: float2 25s ease-in-out infinite;
}
.bg-glow-3 {
    width: 300px; height: 300px;
    background: var(--green);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    animation: float3 30s ease-in-out infinite;
}

@keyframes float1 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(80px, 60px); } }
@keyframes float2 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-60px, -40px); } }
@keyframes float3 { 0%, 100% { transform: translate(-50%, -50%); } 50% { transform: translate(-30%, -60%); } }

/* ── Container ─────────────────────────────────────────────────── */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
    position: relative;
    z-index: 1;
}

/* ── Header ────────────────────────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.logo {
    font-size: 40px;
    filter: drop-shadow(0 0 12px var(--accent-glow));
}
.header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #e4e4e7, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.subtitle {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: 2px;
}

/* ── Status Badge ──────────────────────────────────────────────── */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    transition: all 0.4s ease;
}
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}
.status-running { background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.3); }
.status-running .status-dot { background: var(--green); box-shadow: 0 0 12px var(--green-glow); }
.status-stopped { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); }
.status-stopped .status-dot { background: var(--red); box-shadow: 0 0 8px var(--red-glow); animation: none; }
.status-error { background: rgba(234, 179, 8, 0.1); border-color: rgba(234, 179, 8, 0.3); }
.status-error .status-dot { background: var(--yellow); box-shadow: 0 0 8px var(--yellow-glow); }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: border-color 0.3s ease, transform 0.2s ease;
}
.card:hover {
    border-color: rgba(255,255,255,0.1);
}
.card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-dim);
}

/* ── Controls Section ──────────────────────────────────────────── */
.controls-card {
    margin-bottom: 24px;
}
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 16px;
    align-items: end;
}
.control-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.control-group select,
.control-group input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.control-group select:focus,
.control-group input:focus {
    border-color: var(--accent);
}
.control-group select option {
    background: #1a1a2e;
    color: var(--text);
}
.control-buttons {
    display: flex;
    gap: 10px;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
    white-space: nowrap;
}
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.btn-start {
    background: linear-gradient(135deg, var(--green), #16a34a);
    color: white;
    box-shadow: 0 4px 16px var(--green-glow);
}
.btn-start:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--green-glow);
}
.btn-stop {
    background: linear-gradient(135deg, var(--red), #dc2626);
    color: white;
    box-shadow: 0 4px 16px var(--red-glow);
}
.btn-stop:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--red-glow);
}
.btn-small {
    padding: 6px 14px;
    font-size: 0.75rem;
    background: rgba(255,255,255,0.06);
    color: var(--text-dim);
    border: 1px solid var(--border);
}
.btn-small:hover { background: rgba(255,255,255,0.1); }

/* ── Uptime Bar ────────────────────────────────────────────────── */
.uptime-bar {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    padding: 10px 16px;
    background: rgba(34, 197, 94, 0.06);
    border: 1px solid rgba(34, 197, 94, 0.15);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-dim);
}
.uptime-bar strong { color: var(--green); }

/* ── Stats Section ─────────────────────────────────────────────── */
.stats-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    text-align: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.5;
}
.stat-icon { font-size: 1.6rem; margin-bottom: 8px; }
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: 4px;
}
.stat-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Main Content (Rubros + Logs) ──────────────────────────────── */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

/* ── Rubros Chart ──────────────────────────────────────────────── */
.rubros-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.rubro-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.rubro-name {
    width: 110px;
    font-size: 0.82rem;
    color: var(--text-dim);
    text-align: right;
    flex-shrink: 0;
}
.rubro-bar-bg {
    flex: 1;
    height: 24px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}
.rubro-bar {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    transition: width 0.8s ease;
    min-width: 2px;
}
.rubro-count {
    width: 36px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

/* ── Logs ───────────────────────────────────────────────────────── */
.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.logs-header h2 { margin-bottom: 0; }
.logs-container {
    height: 320px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    line-height: 1.7;
    padding: 12px;
    background: rgba(0,0,0,0.3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.logs-container::-webkit-scrollbar { width: 6px; }
.logs-container::-webkit-scrollbar-track { background: transparent; }
.logs-container::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
.log-line { padding: 2px 0; }
.log-time { color: var(--text-muted); }
.log-level-INFO { color: var(--blue); }
.log-level-SUCCESS { color: var(--green); }
.log-level-WARNING { color: var(--yellow); }
.log-level-ERROR { color: var(--red); }

/* ── Leads Table ───────────────────────────────────────────────── */
.leads-card { margin-bottom: 24px; }
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 10px 14px;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
tbody tr:hover { background: rgba(255,255,255,0.02); }
.phone-found { color: var(--green); font-weight: 600; }
.phone-missing { color: var(--text-muted); }

/* ── Empty State ───────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-size: 0.85rem;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .controls-grid { grid-template-columns: 1fr 1fr; }
    .stats-section { grid-template-columns: repeat(2, 1fr); }
    .main-content { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .header { flex-direction: column; gap: 12px; text-align: center; }
    .controls-grid { grid-template-columns: 1fr; }
    .stats-section { grid-template-columns: 1fr 1fr; }
    .uptime-bar { flex-direction: column; gap: 4px; }
}
