@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap');

:root {
  --bg-0: #0f0f10;
  --bg-1: #151516;
  --bg-2: #1c1c1d;
  --bg-3: #242426;
  --bg-4: #2d2d30;
  --bg-5: #3a3a3f;

  --text-1: #f2f2f3;
  --text-2: #d4d4d8;
  --text-3: #a1a1aa;

  --border-1: #313136;
  --border-2: #3b3b42;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.25);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'Open Sans', sans-serif;
  background: var(--bg-2) url('/assets/img/bgright.png') right center / auto no-repeat fixed;
  color: var(--text-1);
  margin: 0;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea, .btn-link, .menu-link {
  font-family: 'Open Sans', sans-serif;
}

a {
  color: #60a5fa;
  text-decoration: none;
}
a:hover { text-decoration: underline; }

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

.sidebar {
  width: 250px;
  background: var(--bg-1);
  border-right: 1px solid var(--border-1);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.content {
  flex: 1;
  padding: 22px;
  overflow-x: auto;
}

.muted {
  color: var(--text-3);
  font-size: 13px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-link {
  width: 100%;
  text-align: left;
  background: var(--bg-3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  color: var(--text-2);
  text-decoration: none;
  border: 1px solid transparent;
  border-left: 4px solid transparent;
  border-radius: var(--radius-sm);
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.menu-link i { width: 16px; text-align: center; }

.menu-link.active {
  background: var(--bg-4);
  color: #fff;
  border-color: var(--border-2);
  border-left-color: var(--primary);
}

.menu-link:hover {
  background: var(--bg-4);
  color: #fff;
  text-decoration: none;
  border-color: var(--border-2);
  border-left-color: #4ade80;
}

.panel { display: none; }
.panel.active { display: block; }

.container {
  max-width: 1040px;
  margin: 24px auto;
  padding: 0 16px;
}
.narrow { max-width: 460px; }

.card {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card.error {
  border-color: #7f1d1d;
  background: #2a1616;
  color: #fecaca;
}

/* Forms */
label {
  display: block;
  margin-top: 10px;
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  color: var(--text-1);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input::placeholder, textarea::placeholder { color: #8f8f98; }

input:hover, select:hover, textarea:hover {
  border-color: #4b4b54;
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.20);
}

/* Buttons */
button {
  cursor: pointer;
  background: #2f6fd8;
  border: 1px solid #2f6fd8;
  color: #f8fafc;
  padding: 9px 9px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  /* min-width: 140px; */
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  transition: transform .06s ease, filter .18s ease, background .18s ease, border-color .18s ease;
}

button:hover { background: #255fc0; border-color: #255fc0; }
button:active { transform: translateY(1px); }

button.secondary {
  background: var(--bg-4);
  border-color: var(--border-2);
}
button.secondary:hover {
  background: #3a3a3f;
  border-color: #50505a;
}

button.btn-start { background: #2563eb; border-color: #2563eb; }
button.btn-start:hover { background: #1d4ed8; border-color: #1d4ed8; }

button.btn-stop { background: #dc2626; border-color: #dc2626; }
button.btn-stop:hover { background: #b91c1c; border-color: #b91c1c; }

button:disabled, .btn-link[aria-disabled="true"] {
  opacity: .6;
  cursor: not-allowed;
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #2f6fd8;
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  border: 1px solid #2f6fd8;
  font-weight: 600;
}
.btn-link:hover {
  background: #255fc0;
  border-color: #255fc0;
  text-decoration: none;
}
.danger { background: #dc2626; border-color: #dc2626; }
.danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 10px;
  min-width: 640px;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

th, td {
  border-bottom: 1px solid var(--border-1);
  padding: 10px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--bg-3);
  color: var(--text-2);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
tbody tr:hover { background: rgba(255, 255, 255, 0.04); }
tbody tr:last-child td { border-bottom: none; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.money-pos { color: #4ade80; font-weight: 700; }
.money-neg { color: #f87171; font-weight: 700; }
.money-zero { color: var(--text-3); }
.money-hidden { color: #d4d4d8 !important; }

.status-pill,
.session-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill.on,
.session-indicator.on {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.status-pill.off,
.session-indicator.off {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
}

.icon-muted { color: #9ca3af; }
pre { white-space: pre-wrap; }

/* Layout helpers */
.room-row {
  padding: 10px;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.01);
}

.row-inline {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.row-inline label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.row-inline input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* Avatars */
.avatar-lg, .avatar-md, .avatar-sm {
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-2);
}
.avatar-lg { width: 72px; height: 72px; }
.avatar-md { width: 40px; height: 40px; }
.avatar-sm { width: 22px; height: 22px; }

.room-icon {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.player-inline, .room-inline {
  align-items: center;
  gap: 6px;
  width: auto;
  max-width: 100%;
}
*:not(td).player-inline,
*:not(td).room-inline { display: inline-flex; }

td.player-inline, td.room-inline { white-space: nowrap; }

td.player-inline img, td.room-inline img {
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

.player-inline span, .room-inline span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.metric-card {
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 12px;
}

.metric-card span {
  display: block;
  color: var(--text-3);
  font-size: 12px;
  margin-bottom: 4px;
}
.metric-card strong { font-size: 18px; }

/* Badges */
.room-nickname-badge,
.currency-badge {
  background: var(--bg-5);
  color: #ececec;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid #4a4a51;
}

.currency-badge.usd {
  background: #334155;
  border-color: #475569;
}

/* Switch */
.ui-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  vertical-align: middle;
}

.ui-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ui-switch-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #6b7280;
  border-radius: 999px;
  transition: .2s;
  border: 1px solid #7b8190;
}

.ui-switch-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}

.ui-switch input:checked + .ui-switch-slider {
  background: var(--success);
  border-color: var(--success);
}

.ui-switch input:checked + .ui-switch-slider::before {
  transform: translateX(20px);
}

.ui-switch input:focus-visible + .ui-switch-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.ui-switch input:disabled + .ui-switch-slider {
  opacity: .55;
  cursor: not-allowed;
}

/* Para texto al lado del switch */
.ui-switch-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Responsive */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }

  .sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--border-1);
  }

  .menu {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .menu-link {
    width: auto;
    flex: 1 1 180px;
  }

  .content { padding: 16px; }
}
