/* LMP+ Admin Panel - Global Styles */

:root {
    --bg-deep:       #0A0E1A;
    --bg-surface:    #111827;
    --bg-elevated:   #1F2937;
    --primary:       #7B2FBE;
    --primary-light: #A855F7;
    --primary-dim:   #2D1B4E;
    --success:       #10B981;
    --danger:        #EF4444;
    --warning:       #F59E0B;
    --text-primary:  #FFFFFF;
    --text-muted:    #9CA3AF;
    --text-disabled: #4B5563;
    --border:        #1F2937;
    --sidebar-w:     240px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--text-primary); }

/* ─── Layout ─────────────────────────────────────────────────────────────── */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 32px;
    min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.sidebar-brand-name {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-left-color: var(--primary-dim);
}

.nav-item.active {
    background: var(--primary-dim);
    color: var(--text-primary);
    border-left-color: var(--primary-light);
}

.nav-item .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ─── Sidebar collapsible: nav-parent + nav-submenu ─────────────────── */

/* Variante de .nav-item que se comporta como header de un sub-menú: no
   navega a una URL, solo expande/contrae sus .nav-subitem. El chevron
   indica el estado visualmente. */
.nav-parent {
    justify-content: space-between;
}
.nav-parent .nav-chevron {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
    color: var(--text-muted);
    margin-left: auto;
}
.nav-parent.open .nav-chevron {
    transform: rotate(180deg);
}
/* Cuando alguna sub-página está activa, el padre mantiene un highlight
   tenue aunque el submenu esté cerrado — así el usuario sabe en qué
   sección está sin tener que expandirlo. */
.nav-parent.has-active-child {
    color: var(--text-primary);
    border-left-color: var(--primary-dim);
}

/* Container del submenú: por defecto cerrado (max-height 0). Cuando se
   agrega .open, se expande con una transición suave. */
.nav-submenu {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.2s ease;
    background: rgba(0, 0, 0, 0.15);
}
.nav-submenu.open {
    max-height: 300px;   /* generoso, suficiente para ~6 sub-items */
}

/* Sub-items: misma altura/look que .nav-item pero indented y sin icono
   propio (visualmente "hijos" del padre). */
.nav-subitem {
    display: flex;
    align-items: center;
    padding: 10px 20px 10px 50px;   /* 50px alinea con el texto del padre */
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    text-decoration: none;
}
.nav-subitem:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.nav-subitem.active {
    background: var(--primary-dim);
    color: var(--text-primary);
    border-left-color: var(--primary-light);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.admin-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.admin-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-light);
}

.admin-username {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ─── Cards ───────────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.card-sm {
    padding: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ─── Stats ───────────────────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ─── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 14px;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-elevated);
}

/* ─── Badges ──────────────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-danger  { background: rgba(239,68,68,0.15);  color: var(--danger); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-primary { background: var(--primary-dim);    color: var(--primary-light); }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.btn-danger {
    background: rgba(239,68,68,0.1);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.2);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239,68,68,0.2);
}

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="color"],
select {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 14px;
    transition: border-color 0.15s;
    outline: none;
}

input:focus, select:focus {
    border-color: var(--primary-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ─── Modal ───────────────────────────────────────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 480px;
    position: relative;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ─── Progress bar ────────────────────────────────────────────────────────── */

.progress-bar {
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width 0.4s ease;
}

/* ─── Page header ─────────────────────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ─── Toast ───────────────────────────────────────────────────────────────── */

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-primary);
    min-width: 240px;
    animation: slideIn 0.2s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ─── Image upload ────────────────────────────────────────────────────────── */

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}

.upload-area:hover {
    border-color: var(--primary-light);
    background: var(--primary-dim);
}

.upload-preview {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 10px;
}

/* ─── Login page ──────────────────────────────────────────────────────────── */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-deep);
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo img {
    height: 48px;
    margin-bottom: 12px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
}

.login-sub {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
}

.btn-login {
    width: 100%;
    justify-content: center;
    padding: 13px;
    font-size: 15px;
    border-radius: 10px;
    margin-top: 8px;
}

/* ─── Utility ─────────────────────────────────────────────────────────────── */

.text-muted    { color: var(--text-muted); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.text-primary  { color: var(--primary-light); }
.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.mt-8          { margin-top: 8px; }
.mt-16         { margin-top: 16px; }
.mt-24         { margin-top: 24px; }
.mb-16         { margin-bottom: 16px; }
.mb-24         { margin-bottom: 24px; }
.w-full        { width: 100%; }
.hidden        { display: none !important; }

/* ─── Health indicator dot ────────────────────────────────────────────────── */
/* Usado por dashboard + vpn para representar el estado de un VPS WG (verde
   = OK, ámbar = stale, rojo = down, gris = nunca chequeado). Convención
   de colores hardcoded (no via tokens) porque son universales en monitoring
   y no queremos que el tema futuro los reinterprete. */
.health-dot     { display: inline-block; width: 8px; height: 8px;
                  border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.health-ok      { background: #22c55e; }
.health-stale   { background: #f59e0b; }
.health-down    { background: #ef4444; }
.health-unknown { background: #6b7280; }
