/* ==== QYROTH Control de Sala — tema "sala de control" ==== */
:root {
  --bg: #12141c;
  --panel: #1b1e2b;
  --panel-hover: #232841;
  --border: #2a2e42;
  --text: #eceef4;
  --muted: #8b90a8;
  --amber: #f5a623;
  --amber-dim: #c9860f;
  --green: #4ade80;
  --red: #f0555a;
  --blue: #5b8def;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font-body); background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
button { font-family: var(--font-body); }
::selection { background: var(--amber); color: #12141c; }

/* Reduced motion respetado */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.view { min-height: 100vh; }

/* ---------- Login ---------- */
#loginView { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(245,166,35,0.10), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(91,141,239,0.12), transparent 45%),
    var(--bg);
}
.login-box {
  position: relative; z-index: 1;
  width: 340px; display: flex; flex-direction: column; gap: 14px;
  background: var(--panel); border: 1px solid var(--border);
  padding: 34px; border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: rise 0.5s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand-mark { font-size: 1.6rem; color: var(--amber); }
.login-box h1 { font-family: var(--font-display); font-size: 1.15rem; margin: 0; }
.login-sub { margin: 0; font-size: 0.75rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.field input { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-family: var(--font-mono); }
.field input:focus, input:focus, select:focus, textarea:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.btn-primary { padding: 11px; border: none; border-radius: 8px; background: var(--amber); color: #191100; font-weight: 700; cursor: pointer; transition: transform 0.12s, background 0.12s; }
.btn-primary:hover { background: #ffb63a; transform: translateY(-1px); }
.error { color: var(--red); min-height: 1.1em; font-size: 0.8rem; margin: 0; }

/* ---------- Layout general ---------- */
#appView { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 12px; }
.sidebar-brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; padding: 8px 10px 20px; letter-spacing: 0.03em; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item { text-align: left; padding: 10px 12px; border-radius: 8px; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 0.88rem; transition: 0.12s; }
.nav-item:hover { background: var(--panel-hover); color: var(--text); }
.nav-item.active { background: var(--panel-hover); color: var(--amber); }
.sidebar-footer .logout { color: var(--red); }

.main { padding: 26px 32px; overflow-x: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.topbar h1 { font-family: var(--font-display); font-size: 1.4rem; margin: 0 0 4px; }
.topbar-sub { margin: 0; color: var(--muted); font-size: 0.85rem; font-family: var(--font-mono); }
.topbar-sub #onlineCount { color: var(--green); font-weight: 600; }

.toolbar { display: flex; gap: 8px; }
.toolbar input, .toolbar select { padding: 9px 12px; border-radius: 8px; background: var(--panel); color: var(--text); border: 1px solid var(--border); font-size: 0.85rem; }
.toolbar input { width: 200px; }

/* ---------- Grilla de PCs ---------- */
.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.pc-card {
  background: var(--panel); border-radius: 12px; padding: 16px;
  cursor: pointer; border: 1px solid var(--border);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  animation: fadein 0.3s ease both;
}
@keyframes fadein { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
.pc-card:hover { border-color: var(--amber); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
.pc-card .name { font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.pc-card .meta { font-size: 0.75rem; color: var(--muted); font-family: var(--font-mono); }
.pc-card .meta + .meta { margin-top: 2px; }

.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-online { background: var(--green); box-shadow: 0 0 0 0 rgba(74,222,128,0.6); animation: pulse-dot 1.8s infinite; }
.status-offline { background: #4a4e63; }
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(74,222,128,0.55); }
  70% { box-shadow: 0 0 0 7px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}

/* Linea de "vitals" — el elemento distintivo de las tarjetas online */
.pulse-line { width: 100%; height: 22px; margin-top: 10px; opacity: 0.8; }
.pulse-line path { fill: none; stroke: var(--amber); stroke-width: 1.6; stroke-dasharray: 220; stroke-dashoffset: 220; animation: draw-pulse 2.4s linear infinite; }
@keyframes draw-pulse { to { stroke-dashoffset: -220; } }

/* ---------- Modales ---------- */
.modal { position: fixed; inset: 0; background: rgba(8,9,14,0.7); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 50; animation: fadein-bg 0.15s ease both; }
@keyframes fadein-bg { from { opacity: 0; } to { opacity: 1; } }
.modal-content { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px; width: 440px; max-height: 86vh; overflow: auto; animation: modal-in 0.18s cubic-bezier(.2,.8,.3,1.1) both; }
@keyframes modal-in { from { opacity: 0; transform: scale(0.96) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-content.wide { width: 92vw; max-width: 1040px; }
.modal-header { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.modal-header h2 { margin: 0; font-family: var(--font-display); font-size: 1.1rem; }
.modal-sub { margin: 2px 0 0; font-size: 0.75rem; color: var(--muted); font-family: var(--font-mono); }
.modal-header > div:first-child { flex: 1; }
.pc-group-select { margin-top: 8px; padding: 5px 8px; font-size: 0.75rem; border-radius: 6px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.close-btn { background: none; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; line-height: 1; }
.close-btn:hover { color: var(--text); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab-btn { padding: 7px 13px; border: none; border-radius: 7px; background: var(--panel-hover); color: var(--muted); cursor: pointer; font-size: 0.82rem; transition: 0.12s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--amber); color: #191100; font-weight: 600; }
.tab-content { display: none; animation: fadein 0.2s ease both; }
.tab-content.active { display: block; }

/* ---------- Pantalla en vivo ---------- */
.screen-wrap { position: relative; background: #000; border-radius: 10px; overflow: hidden; display: flex; justify-content: center; min-height: 200px; }
.screen-wrap video { max-width: 100%; max-height: 60vh; display: block; cursor: crosshair; }
.screen-offline { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-family: var(--font-mono); }
.hint { font-size: 0.76rem; color: var(--muted); margin-top: 10px; }
.hint code { font-family: var(--font-mono); background: var(--panel-hover); padding: 1px 5px; border-radius: 4px; }

/* ---------- Archivos ---------- */
.file-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.file-toolbar button { padding: 7px 11px; border: none; border-radius: 7px; background: var(--panel-hover); color: var(--text); cursor: pointer; font-size: 0.8rem; }
.file-toolbar button:hover { background: #2c3150; }
#filePath { flex: 1; font-family: var(--font-mono); color: var(--muted); font-size: 0.82rem; }
.file-list { border: 1px solid var(--border); border-radius: 10px; max-height: 400px; overflow: auto; }
.file-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--panel-hover); }
.file-row .fname { cursor: pointer; }
.file-row .factions button { margin-left: 6px; background: var(--panel-hover); border: none; color: var(--text); border-radius: 5px; padding: 4px 9px; cursor: pointer; }
.file-row .factions button:hover { background: #2c3150; }

/* ---------- Terminal ---------- */
#terminalContainer { height: 420px; background: #000; border-radius: 10px; padding: 8px; }

/* ---------- Acciones ---------- */
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.action-card { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.action-card h3 { margin: 0 0 2px; font-size: 0.88rem; font-family: var(--font-display); }
.action-card input, .action-card textarea { padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 0.82rem; font-family: var(--font-body); resize: vertical; }
.btn-secondary { padding: 8px; border: none; border-radius: 7px; background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; font-size: 0.82rem; transition: 0.12s; }
.btn-secondary:hover { filter: brightness(1.1); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms genericos (grupos / bloqueo) ---------- */
form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
form input, form select { padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 0.85rem; }

.simple-list { list-style: none; padding: 0; margin: 0; }
.simple-list li { display: flex; justify-content: space-between; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--border); font-size: 0.85rem; font-family: var(--font-mono); }
.simple-list li:last-child { border-bottom: none; }
.simple-list li button { background: rgba(240,85,90,0.12); border: none; color: var(--red); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-family: var(--font-body); }
.simple-list li button:hover { background: rgba(240,85,90,0.22); }

/* ---------- Toasts ---------- */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--blue); padding: 12px 16px; border-radius: 8px; font-size: 0.85rem; box-shadow: 0 8px 24px rgba(0,0,0,0.35); animation: toast-in 0.2s ease both; max-width: 320px; }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast.out { animation: toast-out 0.2s ease both; }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ---------- Responsive ---------- */
@media (max-width: 780px) {
  #appView { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; padding: 10px 14px; overflow-x: auto; }
  .sidebar-brand { padding: 0 10px 0 0; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-footer { margin-left: auto; }
  .main { padding: 18px; }
}
