/* Antauri Nexus · centro de control del VPS. Oscuro por defecto; claro si el sistema lo pide. */

:root {
    --bg: #0b0d12;
    --surface: #12151c;
    --surface-2: #181c25;
    --border: #232835;
    --text: #e7e9ef;
    --muted: #8a90a2;
    --accent: #7c9cff;
    --accent-text: #0b0d12;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --ok-bg: rgba(74, 222, 128, .12);
    --warn-bg: rgba(251, 191, 36, .12);
    --bad-bg: rgba(248, 113, 113, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --radius: 14px;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f4f5f8;
        --surface: #ffffff;
        --surface-2: #f0f2f6;
        --border: #e1e4eb;
        --text: #171a21;
        --muted: #646b7d;
        --accent: #4f6fe8;
        --accent-text: #ffffff;
        --ok: #16a34a;
        --warn: #d97706;
        --bad: #dc2626;
        --ok-bg: rgba(22, 163, 74, .1);
        --warn-bg: rgba(217, 119, 6, .1);
        --bad-bg: rgba(220, 38, 38, .08);
        --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 6px 20px rgba(20, 24, 40, .06);
        color-scheme: light;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .9em; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; }
h3 { margin: 0 0 14px; font-size: 18px; }
h4 { margin: 0; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; }

/* ---------- Marca y barra superior ---------- */

/* La «A» es una máscara: se pinta con el color del texto (blanca en oscuro, tinta en claro). */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
    flex: none; width: 34px; height: 34px; background: var(--text);
    -webkit-mask: url("logo-a.png") center / contain no-repeat;
    mask: url("logo-a.png") center / contain no-repeat;
}
.brand-text { display: flex; align-items: baseline; gap: 8px; line-height: 1; }
.brand-name { font-size: 16px; font-weight: 500; letter-spacing: .28em; }
.brand-sub { font-size: 11px; font-weight: 600; letter-spacing: .3em; color: var(--accent); }

/* Login: apilado como el logo (A grande, ANTAURI espaciado y debajo NEXUS). */
.brand-lg { flex-direction: column; gap: 14px; margin: 4px 0 10px; }
.brand-lg .brand-mark { width: 92px; height: 92px; }
.brand-lg .brand-text { flex-direction: column; align-items: center; gap: 9px; }
.brand-lg .brand-name { font-size: 24px; letter-spacing: .32em; margin-right: -.32em; }
.brand-lg .brand-sub { font-size: 12px; letter-spacing: .42em; margin-right: -.42em; }

.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 16px; padding: 12px 24px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-host { display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: 13px; min-width: 0; }
.topbar-host .sep { opacity: .5; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.inline-form { display: contents; }

.page { max-width: 1180px; margin: 0 auto; padding: 20px 24px 64px; display: flex; flex-direction: column; gap: 24px; }
.page > section { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.loading-line { margin: 40px 0; text-align: center; }

/* ---------- Botones y campos ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid transparent; border-radius: 9px; padding: 7px 13px;
    font: inherit; font-size: 13.5px; font-weight: 550; cursor: pointer; text-decoration: none;
    transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; padding: 10px; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--bad); border-color: var(--border); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--bad-bg); }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field > span { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
input, select {
    font: inherit; font-size: 14px; color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; width: 100%; min-width: 0;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 0; border-color: var(--accent); }
input[type=color] { width: 44px; height: 36px; padding: 3px; cursor: pointer; }
select { width: auto; padding: 4px 8px; font-size: 12.5px; }
.color-row { display: flex; align-items: center; gap: 10px; color: var(--text); }

/* ---------- Avisos ---------- */

.alert { padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-bad { background: var(--bad-bg); color: var(--bad); }

.status-banner {
    display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px;
    border-radius: var(--radius); font-size: 14px; border: 1px solid var(--border); background: var(--surface);
}
.status-banner.ok { color: var(--ok); align-items: center; }
.status-banner.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); background: var(--bad-bg); }
.status-banner.bad b { color: var(--bad); }
.status-banner ul { margin: 4px 0 0; padding-left: 18px; }
.status-banner .dot { margin-top: 4px; }
.status-banner.ok .dot { margin-top: 0; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.dot.off { background: var(--border); }

.pill { flex: none; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }

.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
    padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 550;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.toast.ok { color: var(--ok); }
.toast.bad { color: var(--bad); }

/* ---------- Medidores del VPS ---------- */

.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.meter {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
}
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; color: var(--muted); }
.meter-head span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-head b { font-size: 22px; color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 3px; transition: width .4s; }
.bar .ok { background: var(--ok); }
.bar .warn { background: var(--warn); }
.bar .bad { background: var(--bad); }

/* ---------- Apps ---------- */

.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; }

.app-card {
    --app: var(--accent);
    position: relative; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.app-card::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--app);
}
.app-main {
    display: flex; align-items: center; gap: 14px; padding: 18px 18px 12px; text-decoration: none;
}
.app-main:hover .app-name { color: var(--app); }
.app-main:hover .open-arrow { opacity: 1; transform: translate(1px, -1px); }
.app-icon {
    flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 13px;
    background: color-mix(in srgb, var(--app) 18%, var(--surface-2));
    color: var(--app); font-size: 24px; font-weight: 700; overflow: hidden;
}
.app-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-name { font-size: 17px; font-weight: 650; transition: color .15s; }
.open-arrow { display: inline-block; font-size: 13px; opacity: .35; transition: opacity .15s, transform .15s; }
.app-host { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-desc { margin: 0; padding: 0 18px 10px; font-size: 13.5px; color: var(--muted); }

.app-links { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 14px; }
.chip {
    font-size: 12.5px; padding: 3px 10px; border-radius: 999px; text-decoration: none;
    border: 1px solid var(--border); color: var(--text); background: var(--surface-2);
}
.chip::after { content: " ↗"; color: var(--muted); }
.chip:hover { border-color: var(--app); }

.ctr-toggle {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 18px;
    background: var(--surface-2); border: 0; border-top: 1px solid var(--border);
    color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.ctr-toggle:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--border)); }
.ctr-toggle .muted { margin-left: auto; font-variant-numeric: tabular-nums; }
.chevron { transition: transform .2s; color: var(--muted); }
.chevron.open { transform: rotate(180deg); }
.ctr-toggle > span:nth-child(2):last-of-type { margin-right: auto; }

.app-edit-bar { display: flex; gap: 6px; padding: 10px 18px; border-top: 1px solid var(--border); }

.empty {
    grid-column: 1 / -1; text-align: center; padding: 40px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted);
}

/* ---------- Contenedores ---------- */

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.group-name {
    padding: 10px 16px 4px; font-size: 12px; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: .06em;
}
.ctr-list { display: flex; flex-direction: column; }
.ctr {
    display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px;
    padding: 10px 16px; border-top: 1px solid var(--border);
}
.ctr-list > .ctr:first-child { border-top: 0; }
.app-card .ctr-list { border-top: 1px solid var(--border); }
.ctr-main { min-width: 0; }
.ctr-main > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctr-name b { font-weight: 600; }
.ctr-stats { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.ctr-actions { display: flex; gap: 6px; align-items: center; }
.busy { padding: 0 12px; }

/* ---------- Espacio de Docker ---------- */

.disk-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 14px 16px; }
.disk-totals > div { display: flex; flex-direction: column; }
.disk-totals b { font-size: 18px; font-variant-numeric: tabular-nums; }
.volumes { display: flex; flex-direction: column; gap: 6px; padding: 4px 16px 14px; }
.volume { display: grid; grid-template-columns: minmax(120px, 240px) 1fr 70px; gap: 12px; align-items: center; font-size: 13px; }
.volume-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.volume-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.volume-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.volume-size { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.panel > p { padding: 0 16px 14px; margin: 0; }
.panel > p:first-child { padding-top: 14px; }

/* ---------- Ventanas ---------- */

.modal-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(5, 7, 12, .6); backdrop-filter: blur(2px); }
.modal {
    position: fixed; z-index: 31; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
}
.modal-sm { width: min(420px, calc(100vw - 32px)); }
.modal-sm p { margin: 0; color: var(--muted); }
.modal-lg { width: min(1000px, calc(100vw - 32px)); height: min(720px, calc(100vh - 48px)); display: flex; flex-direction: column; gap: 12px; }
.modal-lg h3 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }
.links-editor { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.link-row { display: grid; grid-template-columns: 160px 1fr auto; gap: 8px; }
.modal .alert { margin-top: 14px; }

.logs-tools { display: flex; gap: 6px; align-items: center; }
/* column-reverse: empieza abajo del todo (lo más reciente) sin JavaScript. */
.logs {
    flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column-reverse;
    background: #07090d; color: #c9d1e0; border-radius: 10px; border: 1px solid var(--border);
}
.logs pre { margin: 0; padding: 12px 14px; font: 12px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; word-break: break-word; }

/* ---------- Login ---------- */

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
    width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow);
}
.login-title { margin: 0; font-size: 20px; }

/* ---------- Varios ---------- */

.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    padding: 10px 20px; background: var(--bad); color: #fff;
}
#blazor-error-ui .reload { color: #fff; font-weight: 600; margin-left: 8px; }

/* ---------- Móvil ---------- */

@media (max-width: 720px) {
    .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
    .topbar-host { order: 3; width: 100%; font-size: 12px; }
    .refresh-time { display: none; }
    .page { padding: 16px 16px 48px; gap: 20px; }
    .apps { grid-template-columns: 1fr; }
    .meters { grid-template-columns: 1fr 1fr; }
    .meter-head b { font-size: 18px; }
    .ctr { grid-template-columns: auto 1fr auto; padding: 10px 14px; }
    .ctr-actions { grid-column: 2 / -1; justify-content: flex-end; }
    .ctr-toggle .muted { display: none; }
    .disk-totals { grid-template-columns: 1fr 1fr; }
    .volume { grid-template-columns: 1fr 64px; }
    .volume-bar { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .link-row { grid-template-columns: 1fr auto; }
    .link-row input:first-child { grid-column: 1 / -1; }
}
