/* onDuty Link - consola del operador */

:root {
  --bg: #07131f;
  --surface: #0b1b2c;
  --surface-2: #0f2437;
  --border: #1e3a54;
  --text: #e6f1f8;
  --muted: #8aa6bd;
  --primary: #199aa1;
  --primary-soft: rgba(25, 154, 161, 0.16);
  --mint: #00bf9a;
  --danger: #e5484d;
  --warning: #f7b733;
  --radius: 12px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1100px 600px at 10% -10%, rgba(25, 154, 161, 0.18), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(0, 191, 154, 0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.tiny {
  font-size: 12px;
}
.grow {
  flex: 1 1 0;
  min-width: 0;
}
.wide {
  width: 100%;
}

/* ---------------------------------------------------------------- Marca */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  font-size: 17px;
  font-weight: 700;
}

.brand h1 span {
  color: var(--mint);
}

.brand p {
  font-size: 12px;
  color: var(--muted);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--primary), var(--mint));
  color: #04211f;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.brand.big h1 {
  font-size: 22px;
}

.brand.big .brand-mark {
  width: 46px;
  height: 46px;
  font-size: 16px;
}

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

.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  display: grid;
  gap: 16px;
  padding: 28px;
  background: linear-gradient(180deg, rgba(15, 36, 55, 0.92), rgba(11, 27, 44, 0.92));
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.auth-card .brand {
  margin-bottom: 6px;
}

.auth-note {
  min-height: 18px;
  font-size: 12.5px;
  color: var(--danger);
}

.auth-server {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.auth-server b {
  color: var(--text);
  font-weight: 600;
}

.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:hover {
  color: var(--mint);
}

.server-pill {
  cursor: pointer;
  font-family: inherit;
}

.server-pill:hover {
  border-color: var(--primary);
  color: var(--text);
}

.server-recent {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.server-recent button {
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(7, 19, 31, 0.6);
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-recent button:hover {
  border-color: var(--primary);
  color: var(--text);
}

/* ---------------------------------------------------------------- Formularios */

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[inputmode="numeric"],
input:not([type]) {
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(7, 19, 31, 0.75);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.search {
  margin: 0 0 10px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* ---------------------------------------------------------------- Botones */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover {
  background: #143049;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--mint));
  color: #04211f;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

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

.btn.ghost:hover {
  background: rgba(25, 154, 161, 0.1);
}

.btn.danger {
  background: rgba(229, 72, 77, 0.14);
  border-color: rgba(229, 72, 77, 0.5);
  color: #ffb4b6;
}

.btn.danger:hover {
  background: rgba(229, 72, 77, 0.24);
}

.btn.sm {
  padding: 7px 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

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

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(25, 154, 161, 0.12);
}

/* ---------------------------------------------------------------- Estructura */

#console {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 19, 31, 0.75);
  backdrop-filter: blur(8px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(25, 154, 161, 0.1);
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 0;
}

/* ---------------------------------------------------------------- Sidebar */

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 14px;
  border-right: 1px solid var(--border);
  background: rgba(11, 27, 44, 0.55);
  min-height: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sidebar-head h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.device-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
  min-height: 0;
}

.sidebar-foot {
  margin-top: 10px;
  line-height: 1.45;
}

.device {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15, 36, 55, 0.6);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.device:hover {
  border-color: var(--primary);
  background: rgba(25, 154, 161, 0.08);
}

.device.offline {
  opacity: 0.62;
}

.device .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #48657e;
}

.device .dot.online {
  background: var(--mint);
  box-shadow: 0 0 0 3px rgba(0, 191, 154, 0.16);
}

.device-main {
  min-width: 0;
}

.device-name {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-meta {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-actions {
  display: flex;
  gap: 4px;
}

.dot.online {
  background: var(--mint);
}

/* ---------------------------------------------------------------- Workspace */

.workspace {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.home {
  padding: 28px;
  max-width: 780px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.hero h2 {
  font-size: 26px;
  margin-bottom: 6px;
}

.hero p {
  max-width: 560px;
  line-height: 1.5;
}

.card {
  background: rgba(11, 27, 44, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.card h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.tips ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

/* ---------------------------------------------------------------- Sesion */

.session {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #04090f;
}

.session-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.session-device {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.session-device strong {
  font-size: 13.5px;
  white-space: nowrap;
}

.session-device .muted {
  font-size: 12px;
}

.session-device .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #48657e;
}

.session-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.session-actions {
  display: flex;
  gap: 8px;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
  outline: none;
  cursor: default;
}

.stage.controlling {
  cursor: none;
}

.stage img,
.stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.stage.controlling video {
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: rgba(4, 9, 15, 0.82);
  color: var(--muted);
  font-size: 13px;
  z-index: 5;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(25, 154, 161, 0.25);
  border-top-color: var(--mint);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.control-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(25, 154, 161, 0.92);
  color: #04211f;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  z-index: 6;
}

.session-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ---------------------------------------------------------------- Modal */

.modal {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  padding: 22px;
  width: min(400px, 92vw);
  box-shadow: var(--shadow);
}

.modal.wide-modal {
  width: min(560px, 94vw);
  display: grid;
  gap: 12px;
}

.modal::backdrop {
  background: rgba(2, 6, 10, 0.65);
  backdrop-filter: blur(3px);
}

.modal form {
  display: grid;
  gap: 14px;
}

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

/* ---------------------------------------------------------------- Usuarios */

.user-list {
  display: grid;
  gap: 6px;
  max-height: 230px;
  overflow: auto;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(15, 36, 55, 0.6);
}

.user-row .name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row .role {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.new-user {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
}

.new-user input,
.new-user select {
  width: 100%;
  padding: 9px 11px;
  color: var(--text);
  background: rgba(7, 19, 31, 0.75);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
  outline: none;
}

.new-user select {
  cursor: pointer;
}

@media (max-width: 560px) {
  .new-user {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------------------------------------------------------------- Toast */

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 50;
}

.toast.error {
  border-color: rgba(229, 72, 77, 0.6);
  background: #2a1116;
}

.toast.ok {
  border-color: rgba(0, 191, 154, 0.5);
}

/* ---------------------------------------------------------------- Responsive */

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 220px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .home {
    padding: 18px;
  }

  .session-bar {
    gap: 8px;
  }

  .session-stats {
    order: 3;
    width: 100%;
    margin-left: 0;
  }
}
