/* ==========================================================================
   IPTV Relay Panel — Sistema de diseño (tema claro profesional)
   ========================================================================== */

:root {
    /* Superficies */
    --bg-base: #f4f6f9;
    --bg-surface: #ffffff;
    --bg-surface-2: #f8fafc;
    --bg-elevated: #eef1f6;
    --bg-topbar: #ffffff;
    --border-subtle: #e5e9f0;
    --border-strong: #d7dce5;
    --overlay-backdrop: rgba(15, 23, 42, 0.45);

    /* Texto */
    --text-primary: #101828;
    --text-secondary: #475467;
    --text-muted: #8a94a6;

    /* Acento de marca: azul de señal (broadcast/signal) */
    --accent: #0284c7;
    --accent-hover: #0369a1;
    --accent-soft: rgba(2, 132, 199, 0.09);
    --accent-secondary: #7c3aed;
    --accent-secondary-soft: rgba(124, 58, 237, 0.09);

    /* Estados */
    --state-online: #16a34a;
    --state-online-soft: rgba(22, 163, 74, 0.10);
    --state-warning: #d97706;
    --state-warning-soft: rgba(217, 119, 6, 0.10);
    --state-error: #dc2626;
    --state-error-soft: rgba(220, 38, 38, 0.09);
    --state-idle: #8a94a6;
    --state-idle-soft: rgba(138, 148, 166, 0.12);

    /* Espaciado y forma */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px -8px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

body {
    background: var(--bg-base);
    background-image:
        radial-gradient(circle at 15% 0%, rgba(2, 132, 199, 0.05), transparent 40%),
        radial-gradient(circle at 85% 100%, rgba(124, 58, 237, 0.04), transparent 40%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

.font-mono, code, pre, .mono { font-family: 'JetBrains Mono', 'Consolas', monospace; }

h1, h2, h3 { letter-spacing: -0.01em; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
}

.brand-mark {
    display: flex; align-items: center; gap: 10px;
}
.brand-signal {
    display: flex; align-items: flex-end; gap: 2px; height: 16px;
}
.brand-signal span {
    width: 3px; background: var(--accent); border-radius: 1px;
    animation: signal-pulse 1.6s ease-in-out infinite;
}
.brand-signal span:nth-child(1) { height: 40%; animation-delay: 0s; }
.brand-signal span:nth-child(2) { height: 70%; animation-delay: 0.2s; }
.brand-signal span:nth-child(3) { height: 100%; animation-delay: 0.4s; }
.brand-signal span:nth-child(4) { height: 60%; animation-delay: 0.6s; }
@keyframes signal-pulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .brand-signal span { animation: none; opacity: 0.85; }
}

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 14px; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 13.5px; font-weight: 500;
    border-left: 2px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-link.active {
    background: var(--accent-soft); color: var(--accent);
    border-left-color: var(--accent);
}
.nav-link i { width: 18px; text-align: center; font-size: 13px; opacity: 0.85; }

/* ---------- Cards ---------- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border-subtle);
}
.card-header h3 {
    font-size: 13px; font-weight: 600; color: var(--text-primary);
    text-transform: uppercase; letter-spacing: 0.04em;
    display: flex; align-items: center; gap: 10px;
}
.card-header h3 .chip {
    width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, currentColor 14%, transparent);
    color: currentColor; font-size: 12px;
}
.card-header h3:not([style*="color"]) { color: var(--text-primary); }
.card-header h3:not([style*="color"]) .chip { color: var(--accent); }
.card-header h3 i:not(.chip i) { color: var(--accent); font-size: 12px; }
.card-body { padding: 18px; }

/* ---------- Barra superior (desktop) ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px; background: var(--bg-topbar); border-bottom: 1px solid var(--border-subtle);
}
.topbar h2 { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.status-pill {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px;
    background: var(--state-online-soft); color: var(--state-online);
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: dot-pulse 1.6s ease-in-out infinite; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 13px; font-weight: 600; padding: 9px 16px;
    border-radius: var(--radius-sm); border: 1px solid transparent;
    cursor: pointer; transition: all 0.15s ease; line-height: 1.2;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #ffffff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-elevated); }
.btn-success { background: var(--state-online); color: #ffffff; }
.btn-success:hover { filter: brightness(1.08); }
.btn-danger { background: var(--state-error); color: #ffffff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-subtle); }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-strong); }
.btn-icon { padding: 7px 9px; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Iconos de acción en tablas (play/stop/editar/etc.) */
.icon-action {
    width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); color: var(--text-secondary);
    transition: all 0.15s ease; border: 1px solid transparent;
}
.icon-action:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-strong); }
.icon-action.action-start:hover { color: var(--state-online); }
.icon-action.action-stop:hover { color: var(--state-error); }
.icon-action.action-restart:hover { color: var(--state-warning); }
.icon-action.action-edit:hover { color: var(--accent); }

/* ---------- Formularios ---------- */
.field-label {
    display: block; font-size: 11.5px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px;
}
.field-input, .field-select, select.field-input {
    width: 100%; background: var(--bg-surface); border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); padding: 9px 12px; color: var(--text-primary);
    font-size: 13.5px; transition: border-color 0.15s ease;
}
.field-input::placeholder { color: var(--text-muted); }
.field-input:focus, .field-select:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.field-group { margin-bottom: 16px; }

/* ---------- Badges de estado (con indicador pulsante) ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px 3px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-online   { background: var(--state-online-soft); color: var(--state-online); }
.badge-online::before { animation: dot-pulse 1.4s ease-in-out infinite; }
.badge-connecting { background: var(--state-warning-soft); color: var(--state-warning); }
.badge-connecting::before { animation: dot-pulse 0.9s ease-in-out infinite; }
.badge-error, .badge-offline { background: var(--state-error-soft); color: var(--state-error); }
.badge-stopped { background: var(--state-idle-soft); color: var(--state-idle); }
@keyframes dot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
@media (prefers-reduced-motion: reduce) {
    .badge-online::before, .badge-connecting::before { animation: none; }
}

/* ---------- Tablas ---------- */
.table-clean { width: 100%; font-size: 13px; border-collapse: collapse; }
.table-clean thead th {
    text-align: left; padding: 10px 12px; font-size: 10.5px; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface-2);
}
.table-clean tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); }
.table-clean tbody tr:last-child td { border-bottom: none; }
.table-clean tbody tr:hover { background: var(--bg-surface-2); }
.table-clean tbody td:first-child { color: var(--text-primary); font-weight: 500; }

/* ---------- Stat tiles (dashboard) ---------- */
.stat-tile { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 16px 18px; box-shadow: var(--shadow-card); }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; font-family: 'JetBrains Mono', monospace; }
.stat-bar { width: 100%; height: 4px; background: var(--border-subtle); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.stat-bar > div { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s ease; }

/* ---------- Login ---------- */
.login-shell {
    background: radial-gradient(circle at 50% 20%, #eef3fb 0%, #f4f6f9 60%);
}
.login-card {
    background: var(--bg-surface); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); box-shadow: 0 20px 60px -24px rgba(16, 24, 40, 0.18);
}

/* ---------- Utilidades ---------- */
.text-accent { color: var(--accent); }
.divider { border-top: 1px solid var(--border-subtle); margin: 18px 0; }
