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

:root {
    /* Fondos — gris azulado suave */
    --bg-base:     #f0f4f8;
    --bg-surface:  #ffffff;
    --bg-raised:   #f7f9fc;
    --bg-hover:    #e8f4fb;
    --border:      #d4e0ec;
    --border-soft: #b8cfe0;

    /* Texto */
    --text-primary:   #0f1f3d;
    --text-secondary: #4a5e78;
    --text-muted:     #9aafbf;

    /* Azul cielo */
    --accent:      #0ea5e9;
    --accent-glow: rgba(14,165,233,0.18);
    --accent-dim:  rgba(14,165,233,0.09);
    --accent-2:    #38bdf8;

    /* Sidebar blanco con borde */
    --sidebar-bg:       #ffffff;
    --sidebar-border:   #d4e0ec;
    --sidebar-text:     #4a5e78;
    --sidebar-text-act: #0ea5e9;
    --sidebar-active:   rgba(14,165,233,0.08);
    --sidebar-hover:    rgba(14,165,233,0.05);
    --sidebar-muted:    #9aafbf;

    --success:     #059669;
    --success-bg:  rgba(5,150,105,0.08);
    --danger:      #dc2626;
    --danger-bg:   rgba(220,38,38,0.08);
    --warning:     #d97706;
    --warning-bg:  rgba(217,119,6,0.08);

    --sidebar-w:   240px;
    --radius:      10px;
    --radius-sm:   6px;
    --font-mono:   'Space Mono', monospace;
    --font-sans:   'Syne', sans-serif;
    --transition:  all 0.2s ease;
}

html { font-size: 15px; }

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

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

/* ─── SIDEBAR ──────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    padding: 1.5rem 1rem;
    z-index: 100;
}

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

.brand-icon {
    width: 38px; height: 38px;
    background: var(--accent-dim);
    border: 1px solid var(--accent-glow);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}
.brand-icon svg { width: 18px; height: 18px; }

.brand-text { display: flex; flex-direction: column; }
.brand-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.brand-label {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    padding: 0.4rem 0.75rem;
    border-radius: 99px;
    margin-bottom: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.status-active {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16,185,129,0.25);
}
.status-inactive {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(244,63,94,0.25);
}
.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.nav-section-label {
    font-size: 0.62rem;
    font-family: var(--font-mono);
    color: var(--sidebar-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: var(--transition);
    margin-bottom: 0.15rem;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover {
    background: var(--sidebar-hover);
    color: #ffffff;
}
.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-act);
    border: 1px solid rgba(255,255,255,0.15);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--sidebar-border);
    margin-top: auto;
}

.user-info {
    display: flex; align-items: center; gap: 0.65rem; flex: 1; min-width: 0;
}
.user-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, #0ea5e9, #38bdf8);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; flex-shrink: 0; color: #fff;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 0.82rem; font-weight: 700; color: var(--text-primary); }
.user-since { font-size: 0.65rem; font-family: var(--font-mono); color: var(--text-muted); }

.logout-btn {
    color: var(--text-muted);
    transition: var(--transition);
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    display: flex;
}
.logout-btn:hover { color: var(--danger); background: var(--danger-bg); }
.logout-btn svg { width: 16px; height: 16px; }

/* ─── MAIN CONTENT ─────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    position: sticky; top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(37,99,235,0.06);
}

.page-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}
.page-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.top-bar-clock {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-raised);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    letter-spacing: 0.05em;
}

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

/* ─── FLASH MESSAGES ───────────────────────────────── */
.flash {
    margin: 0 2rem;
    margin-top: 1rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.flash-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(244,63,94,0.3); }
.flash-info    { background: var(--accent-dim);  color: var(--accent);  border: 1px solid rgba(59,130,246,0.3); }

/* ─── STAT CARDS ───────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    opacity: 0;
    transition: var(--transition);
}
.stat-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(37,99,235,0.08); }
.stat-card:hover::before { opacity: 1; }

.stat-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 0.85rem;
}
.stat-icon svg { width: 18px; height: 18px; }

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.3rem;
    font-family: var(--font-mono);
}
.stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ─── CARDS / PANELS ───────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.card-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
}
.card-body { padding: 1.5rem; }

/* ─── TABLE ────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.87rem;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

/* ─── BADGES ───────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-info    { background: var(--accent-dim);  color: var(--accent);  }

/* ─── BUTTONS ──────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.83rem;
    font-weight: 700;
    font-family: var(--font-sans);
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: #2563eb; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-soft); }

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(244,63,94,0.3);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(16,185,129,0.3);
}
.btn-success:hover { background: var(--success); color: #fff; }

.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.78rem; }
.btn-group { display: flex; gap: 0.4rem; }

/* ─── FORMS ────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group.full-width { grid-column: 1 / -1; }

.form-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.form-input, .form-select, .form-textarea {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    padding: 0.65rem 0.85rem;
    transition: var(--transition);
    width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-select option { background: var(--bg-raised); }

.form-hint {
    font-size: 0.73rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}
.form-check input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}
.form-check-label {
    font-size: 0.87rem;
    font-weight: 600;
    cursor: pointer;
}

.code-field {
    font-family: var(--font-mono);
    font-size: 0.83rem;
    background: var(--bg-base);
    border-color: var(--border-soft);
}

/* ─── COMMAND PREVIEW ──────────────────────────────── */
.cmd-preview {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}
.cmd-preview .cmd-trigger {
    color: var(--accent);
    font-weight: 700;
}
.cmd-preview .cmd-response {
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

/* ─── EMPTY STATE ──────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 1rem; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

/* ─── GRID LAYOUT ──────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }

/* ─── LOGIN PAGE ───────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0369a1 0%, #0ea5e9 60%, #38bdf8 100%);
}
.login-box {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}
.login-logo {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 2rem;
    justify-content: center;
}
.login-logo-icon {
    width: 48px; height: 48px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: #ffffff;
}
.login-logo-icon svg { width: 24px; height: 24px; }
.login-logo-text { font-size: 1.5rem; font-weight: 800; color: #ffffff; }

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}
.login-card h2 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}
.login-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1.75rem;
}
.login-actions { margin-top: 1.25rem; }
.btn-login {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
    font-size: 0.95rem;
}
.login-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(244,63,94,0.3);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ─── MODAL ────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    width: 90%; max-width: 540px;
    max-height: 90vh; overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.25s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 0.3rem;
    border-radius: var(--radius-sm); transition: var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-close svg { width: 18px; height: 18px; display: block; }
.modal-body { padding: 1.5rem; }

/* ─── SCROLLBAR ────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-soft); border-radius: 99px; }

/* ─── DIVIDER ──────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

/* ─── UTILITIES ────────────────────────────────────── */
.text-mono  { font-family: var(--font-mono); }
.text-sm    { font-size: 0.82rem; }
.text-muted { color: var(--text-muted); }
.text-accent{ color: var(--accent); }
.text-success{color: var(--success);}
.text-danger {color: var(--danger);}
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .two-col, .three-col { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}