* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: #f8fafc;
    color: #1e293b;
    transition: background 0.3s, color 0.3s;
}

/* ============================================
   VARIABLES GLOBALES (Tema Claro)
   ============================================ */
:root {
    --sidebar-width: 280px;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --bg-body: #f8fafc;
    --bg-sidebar: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --table-header: #f8fafc;
}

/* Tema Oscuro */
[data-theme="dark"] {
    --bg-body: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --table-header: #0f172a;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */
.container { display: flex; min-height: 100vh; }

/* Sidebar Moderna */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: white;
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1000;
    border-right: 1px solid rgba(255,255,255,0.05);
}

/* Scrollbar Sidebar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: #1e293b; }
.sidebar::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.logo i { color: var(--primary); font-size: 24px; }

.nav-menu { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s;
    font-weight: 500;
}
.nav-item i { width: 22px; font-size: 18px; }
.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: white;
    transform: translateX(4px);
}
.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    transition: margin-left 0.3s ease;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}
.header h1 { font-size: 28px; font-weight: 700; background: linear-gradient(135deg, #1e293b, #334155); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-theme="dark"] .header h1 { background: linear-gradient(135deg, #f1f5f9, #cbd5e1); -webkit-background-clip: text; background-clip: text; }

/* Botones Mejorados */
.btn-refresh, .btn-primary, .copy-btn {
    padding: 8px 20px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
}
.btn-refresh {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.btn-primary:hover, .btn-refresh:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -8px var(--primary); }
.btn-primary:active { transform: translateY(1px); }

/* Views */
.view { display: none; animation: fadeInUp 0.4s ease-out; }
.view.active { display: block; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

/* Tarjetas Profesionales */
.stat-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--success));
    opacity: 0;
    transition: opacity 0.3s;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -12px rgba(0,0,0,0.15);
}
.stat-card:hover::before { opacity: 1; }

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.3s;
}
.stat-card:hover .stat-icon { transform: scale(1.05); }

/* Colores de iconos con gradiente */
.stat-icon.blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: white; }
.stat-icon.green { background: linear-gradient(135deg, #10b981, #047857); color: white; }
.stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: white; }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; }
.stat-icon.teal { background: linear-gradient(135deg, #14b8a6, #0f766e); color: white; }
.stat-icon.pink { background: linear-gradient(135deg, #ec4899, #be185d); color: white; }
.stat-icon.red { background: linear-gradient(135deg, #ef4444, #b91c1c); color: white; }

.stat-value {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #1e293b, #334155);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.02em;
}
[data-theme="dark"] .stat-value { background: linear-gradient(135deg, #f1f5f9, #cbd5e1); -webkit-background-clip: text; }

.stat-label { display: block; color: var(--text-secondary); font-size: 13px; margin-bottom: 4px; }

/* Secciones y Tablas */
.stats-section, .webhooks-table-container, .settings-section {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stats-section h3, .settings-section h3 { margin-bottom: 20px; font-size: 18px; font-weight: 600; color: var(--text-primary); }

.webhooks-table-container { overflow-x: auto; }
.webhooks-table { width: 100%; border-collapse: collapse; }
.webhooks-table th {
    text-align: left;
    padding: 14px 16px;
    background: var(--table-header);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.webhooks-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-primary);
}
.webhooks-table tr:hover td { background: rgba(59,130,246,0.05); }

/* Formularios */
.config-group { margin-bottom: 20px; }
.config-group label { display: block; font-weight: 500; margin-bottom: 6px; color: var(--text-primary); font-size: 14px; }
.config-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s;
}
.config-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

/* Tabs */
.settings-tabs-container { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.settings-tab {
    padding: 10px 24px;
    background: var(--table-header);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 40px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.settings-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Switch */
.switch { position: relative; display: inline-block; width: 52px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 28px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(24px); }

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}
[data-theme="dark"] .skeleton { background: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%); }
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideUp 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
.toast.warning { background: #f59e0b; }
@keyframes slideUp {
    from { transform: translateY(100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Scrollbar General */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #e2e8f0; border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: #1e293b; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #475569; }

/* Responsive */
.menu-toggle { display: none; position: fixed; top: 16px; left: 16px; z-index: 1001; background: #1e293b; border: none; color: white; font-size: 24px; padding: 10px 14px; border-radius: 12px; cursor: pointer; }
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 999; }

@media (max-width: 768px) {
    .menu-toggle { display: block; }
    .sidebar { left: -280px; top: 0; padding-top: 70px; }
    .sidebar.open { left: 0; }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-left: 0; padding: 16px; padding-top: 70px; }
    .stats-grid { grid-template-columns: 1fr; }
    .header { flex-direction: column; align-items: flex-start; }
    .header-actions { width: 100%; }
    .btn-refresh, .btn-primary { width: 100%; justify-content: center; }
}
/* ============================================
   CORRECCIÓN MODO OSCURO - EMQ CARDS
   ============================================ */

/* Forzar fondo oscuro para todas las tarjetas de cobertura */
[data-theme="dark"] #emq-params-detail > div {
    background: #1e293b !important;
    border: 1px solid #334155 !important;
}

[data-theme="dark"] #emq-params-detail > div > div:first-child {
    background: #0f172a !important;
    border-bottom: 1px solid #334155 !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] #emq-params-detail > div > div:last-child {
    background: #1e293b !important;
}

[data-theme="dark"] #emq-params-detail span,
[data-theme="dark"] #emq-params-detail .emq-param-name {
    color: #e2e8f0 !important;
}

[data-theme="dark"] #emq-params-detail .emq-param-bar {
    background: #334155 !important;
}

/* Forzar el widget de cobertura de Meta */
[data-theme="dark"] .meta-coverage-widget {
    background: #1e293b !important;
    border: 1px solid #334155 !important;
}

[data-theme="dark"] .coverage-bar {
    background: #334155 !important;
}

[data-theme="dark"] .event {
    border-bottom-color: #334155 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .projection {
    background: #0f172a !important;
    color: #94a3b8 !important;
}