/* ============================================================================
   StationMonitor — Design System
   Tema oscuro (Dark Mode) estilo app.smartfox.ai
   ============================================================================ */

/* ── Variables ────────────────────────────────────────────────── */
:root {
    --bg-primary: #1c1c1e;
    --bg-secondary: #252528;
    --bg-card: #2d2d30;
    --bg-card-hover: #3a3a3e;
    --bg-input: #333336;
    --border-color: #404044;
    --border-active: #5c5c60;

    --text-primary: #f0f0f0;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;

    --accent-primary: #ff4500;     /* SmartFox Orange */
    --accent-primary-hover: #ff5722;
    --accent-secondary: #ff8c00;

    /* Semáforo adaptado para modo oscuro */
    --color-verde: #22c55e;
    --color-verde-bg: rgba(34,197,94,0.15);
    --color-verde-light: #064e3b;
    --color-amarillo: #facc15;
    --color-amarillo-bg: rgba(250,204,21,0.15);
    --color-amarillo-light: #713f12;
    --color-rojo: #ef4444;
    --color-rojo-bg: rgba(239,68,68,0.15);
    --color-rojo-light: #7f1d1d;
    --color-gris: #9ca3af;
    --color-gris-bg: rgba(156,163,175,0.15);
    --color-gris-light: #374151;
    --color-azul: #3b82f6;
    --color-azul-bg: rgba(59,130,246,0.15);
    --color-azul-light: #1e3a8a;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --shadow-card: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-card-hover: 0 6px 24px rgba(0,0,0,0.10);
    --shadow-glow: 0 0 20px rgba(79,70,229,0.12);

    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

html { font-size: 14px; scroll-behavior: smooth; }
body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-primary-hover); }

/* ── Layout ───────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: #151515;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand .sidebar-logo-img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.login-logo-img {
    width: 160px;
    height: auto;
    margin: 0 auto 1rem;
    display: block;
}

.sidebar-brand h1 {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-nav { flex: 1; padding: 1rem 0.6rem; overflow-y: auto; }

.nav-section { margin-bottom: 1.25rem; }
.nav-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.35);
    padding: 0 0.75rem;
    margin-bottom: 0.4rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.65);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link.active {
    background: rgba(79,70,229,0.2);
    color: #a5b4fc;
}
.nav-link .icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.7rem;
    color: rgba(255,255,255,0.35);
}

.main-content {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

.page-title { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); }

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

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}

.content-area { flex: 1; padding: 1.5rem 2rem; }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all var(--transition-normal);
}
.card:hover { border-color: var(--border-active); box-shadow: var(--shadow-card); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.card-title { font-size: 1rem; font-weight: 600; }

/* ── Station Cards Grid ───────────────────────────────────────── */
.station-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.6rem;
}

.station-card {
    background: var(--bg-card);
    border: 4px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.8rem 1rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}
.station-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
}

@keyframes sismo-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.9); }
    70% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.station-card.verde { border-color: var(--color-verde); box-shadow: 0 0 10px rgba(34,197,94,0.3); }
.station-card.amarillo { border-color: var(--color-amarillo); box-shadow: 0 0 10px rgba(250,204,21,0.3); }
.station-card.rojo { 
    border-color: var(--color-rojo); 
    animation: sismo-pulse 1.2s infinite; 
}
.station-card.gris { border-color: var(--color-gris); }
.station-card.azul { border-color: var(--color-azul); }

.station-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.85rem;
}

.station-name { font-size: 0.85rem; font-weight: 700; color: var(--text-primary); }
.station-code { font-size: 0.65rem; color: var(--text-muted); margin-top: 1px; }

.station-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.metric {
    text-align: center;
    padding: 0.35rem 0.2rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}
.metric-value {
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}
.metric-label {
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.1rem;
    font-weight: 600;
}

/* Semaphore dots for metrics */
.metric-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.metric-dot.verde { background: var(--color-verde); box-shadow: 0 0 6px rgba(22,163,74,0.4); }
.metric-dot.amarillo { background: var(--color-amarillo); box-shadow: 0 0 6px rgba(234,179,8,0.4); }
.metric-dot.rojo { background: var(--color-rojo); box-shadow: 0 0 6px rgba(220,38,38,0.4); }
.metric-dot.gris { background: var(--color-gris); }

/* ── Semaphore Badge ──────────────────────────────────────────── */
.semaphore {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.semaphore .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}
.semaphore.verde { background: var(--color-verde-light); color: var(--color-verde); }
.semaphore.verde .dot { background: var(--color-verde); }
.semaphore.amarillo { background: var(--color-amarillo-light); color: var(--color-amarillo); }
.semaphore.amarillo .dot { background: var(--color-amarillo); }
.semaphore.rojo { background: var(--color-rojo-light); color: var(--color-rojo); }
.semaphore.rojo .dot { background: var(--color-rojo); }
.semaphore.gris { background: var(--color-gris-light); color: var(--color-gris); }
.semaphore.gris .dot { background: var(--color-gris); }
.semaphore.azul { background: var(--color-azul-light); color: var(--color-azul); }
.semaphore.azul .dot { background: var(--color-azul); }

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

/* ── Summary Counters ─────────────────────────────────────────── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    transition: all var(--transition-normal);
}
.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }

.summary-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.summary-icon.verde { background: var(--color-verde-light); color: var(--color-verde); }
.summary-icon.amarillo { background: var(--color-amarillo-light); color: var(--color-amarillo); }
.summary-icon.rojo { background: var(--color-rojo-light); color: var(--color-rojo); }
.summary-icon.gris { background: var(--color-gris-light); color: var(--color-gris); }
.summary-icon.azul { background: var(--color-azul-light); color: var(--color-azul); }
.summary-icon.primary { background: #ede9fe; color: var(--accent-primary); }
.summary-icon.warn { background: var(--color-amarillo-light); color: var(--color-amarillo); }

.summary-value { font-size: 1.5rem; font-weight: 800; font-family: var(--font-mono); color: var(--text-primary); }
.summary-label { font-size: 0.72rem; color: var(--text-secondary); font-weight: 500; }

/* ── Status Indicators ────────────────────────────────────────── */
.status-ok { color: var(--color-verde); }
.status-warn { color: var(--color-amarillo); }
.status-error { color: var(--color-rojo); }
.status-offline { color: var(--color-gris); }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}
.status-pill.ok { background: var(--color-verde-light); color: var(--color-verde); }
.status-pill.warn { background: var(--color-amarillo-light); color: var(--color-amarillo); }
.status-pill.error { background: var(--color-rojo-light); color: var(--color-rojo); }

/* ── Tables ───────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th {
    text-align: left;
    padding: 0.65rem 1rem;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-primary);
}
.data-table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-primary);
}
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--bg-card-hover); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-primary {
    background: var(--accent-primary);
    color: #fff;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-glow); }

.btn-secondary { background: var(--bg-primary); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--border-active); background: var(--bg-card-hover); }

.btn-danger { background: var(--color-rojo); color: #fff; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.75rem; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.4rem; }
.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    transition: border-color var(--transition-fast);
}
.form-control:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }
.form-control::placeholder { color: var(--text-muted); }

/* ── Login ────────────────────────────────────────────────────── */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.login-logo .logo-icon {
    width: 64px; height: 64px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
}
.login-logo h2 { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.login-logo p { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.4rem; }

/* ── Smart TV Mode ────────────────────────────────────────────── */
body.tv-mode { font-size: 14px; }
body.tv-mode .sidebar { display: none; }
body.tv-mode .main-content { margin-left: 0; }
body.tv-mode .top-header { padding: 0.8rem 1.5rem; }
body.tv-mode .content-area { padding: 0.8rem 1.5rem; }
body.tv-mode .station-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.5rem; }
body.tv-mode .station-card { padding: 0.6rem; }
body.tv-mode .metric-value { font-size: 1rem; }

/* ── Progress Bar ─────────────────────────────────────────────── */
.progress-bar {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar .fill {
    height: 100%;
    border-radius: 3px;
    transition: width var(--transition-normal);
}
.progress-bar .fill.verde { background: var(--color-verde); }
.progress-bar .fill.amarillo { background: var(--color-amarillo); }
.progress-bar .fill.rojo { background: var(--color-rojo); }

/* ── Clickable Saltos ─────────────────────────────────────────── */
.saltos-clickable {
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s, box-shadow 0.2s;
    padding: 4px 6px;
    margin: -4px -6px;
}
.saltos-clickable:hover {
    background: rgba(52, 120, 246, 0.08);
    box-shadow: 0 0 0 2px rgba(52, 120, 246, 0.2);
}

/* ── Gaps Table ───────────────────────────────────────────────── */
.gaps-section {
    margin-top: 1.5rem;
    scroll-margin-top: 1rem;
}
.gaps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 6px;
}
.gap-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #451a1a;
    border: 1px solid #7f1d1d;
    border-radius: 6px;
    padding: 6px 10px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: #fca5a5;
}
.gap-chip.serie { background: #452b11; border-color: #78350f; color: #fcd34d; }
.gap-chip i { font-size: 0.65rem; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .station-grid { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Utility ──────────────────────────────────────────────────── */
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-05 { gap: 0.5rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.d-flex { display: flex; }
.align-center { align-items: center; }

/* ── Custom Switch ────────────────────────────────────────────────── */
.custom-switch {
    width: 2.8em !important;
    height: 1.4em !important;
    cursor: pointer;
    background-color: var(--color-gris) !important;
    border-color: var(--color-gris) !important;
}
.custom-switch:checked {
    background-color: var(--color-verde) !important;
    border-color: var(--color-verde) !important;
}