/* Sin esto, [hidden] no gana contra las reglas display:flex de abajo (misma
   prioridad que la regla por defecto del navegador, pero el autor pisa al
   user-agent): las pantallas login/devices/live quedaban todas apiladas y
   visibles a la vez en vez de mostrarse una sola por vez. */
[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #12141c;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #1b1f2a;
  border-bottom: 1px solid #262b38;
}

.topbar-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #4fc3f7;
}

.topbar-title-sub {
  color: #9aa4b2;
  font-weight: 400;
  font-size: 0.9rem;
  margin-left: 8px;
}

/* ---------- Generic screens ---------- */

.screen {
  min-height: calc(100vh - 54px);
  padding: 24px;
}

.center-card {
  max-width: 380px;
  margin: 60px auto;
  background: #1b1f2a;
  border: 1px solid #262b38;
  border-radius: 12px;
  padding: 28px;
  text-align: center;
}

.center-card h1 {
  margin-top: 0;
  font-size: 1.3rem;
  color: #ffffff;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

#login-form label {
  font-size: 0.85rem;
  color: #9aa4b2;
}

#login-form input {
  background: #12141c;
  border: 1px solid #333a4a;
  border-radius: 8px;
  padding: 10px 12px;
  color: #ffffff;
  font-size: 1rem;
}

#login-form input:focus {
  outline: none;
  border-color: #4fc3f7;
}

.error-text {
  color: #ff8a65;
  margin-top: 14px;
  margin-bottom: 0;
}

/* ---------- Buttons ---------- */

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: #4fc3f7;
  color: #0b0d12;
  margin-top: 6px;
}

.btn-primary:hover {
  background: #7ad4f9;
}

.btn-secondary {
  background: #262b38;
  color: #ffffff;
}

.btn-secondary:hover {
  background: #333a4a;
}

.btn-ghost {
  background: transparent;
  color: #9aa4b2;
  border: 1px solid #333a4a;
}

.btn-ghost:hover {
  color: #ffffff;
  border-color: #4fc3f7;
}

.btn-approve {
  background: #66bb6a;
  color: #0b0d12;
}

.btn-approve:hover {
  background: #85cc88;
}

.btn-revoke {
  background: #ff8a65;
  color: #0b0d12;
}

.btn-revoke:hover {
  background: #ffa587;
}

.btn-view {
  background: #4fc3f7;
  color: #0b0d12;
}

.btn-view:hover {
  background: #7ad4f9;
}

/* ---------- Devices list ---------- */

.panel {
  max-width: 900px;
  margin: 0 auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h1 {
  font-size: 1.4rem;
  margin: 0;
}

.section-title {
  font-size: 1rem;
  color: #9aa4b2;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 28px 0 12px;
}

.empty-note {
  color: #6b7280;
  font-style: italic;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #1b1f2a;
  border: 1px solid #262b38;
  border-radius: 10px;
  padding: 14px 16px;
}

.device-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.device-id {
  font-weight: 700;
  font-family: "Courier New", monospace;
  color: #4fc3f7;
}

.device-meta {
  font-size: 0.82rem;
  color: #9aa4b2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 480px;
}

.device-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot--pending {
  background: #ff8a65;
}

.status-dot--approved {
  background: #66bb6a;
}

/* ---------- Live view ---------- */

.live-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.live-device-id {
  font-family: "Courier New", monospace;
  color: #4fc3f7;
  font-weight: 700;
}

.conn-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 0.9rem;
  color: #9aa4b2;
}

.conn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.conn-dot--online {
  background: #66bb6a;
  box-shadow: 0 0 6px #66bb6a;
}

.conn-dot--offline {
  background: #6b7280;
}

.live-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 18px;
  max-width: 1200px;
  margin: 0 auto;
}

.live-video-panel {
  position: relative;
  background: #000000;
  border: 1px solid #262b38;
  border-radius: 10px;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.live-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.live-video.has-frame {
  display: block;
}

.live-video-placeholder {
  color: #6b7280;
  font-size: 0.95rem;
}

.live-video.has-frame + .live-video-placeholder {
  display: none;
}

.live-side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.live-info-block {
  background: #1b1f2a;
  border: 1px solid #262b38;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.info-row--col {
  flex-direction: column;
  align-items: flex-start;
}

.info-label {
  color: #9aa4b2;
  flex-shrink: 0;
}

.info-value {
  color: #ffffff;
  word-break: break-word;
}

.state-badge {
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.08);
}

.state-idle, .state-speaking {
  color: #4fc3f7;
}

.state-listening {
  color: #66bb6a;
}

.state-thinking {
  color: #ffb74d;
}

.state-success {
  color: #81c784;
}

.state-retry {
  color: #ff8a65;
}

.audio-meter {
  width: 100%;
  height: 12px;
  background: #12141c;
  border: 1px solid #333a4a;
  border-radius: 6px;
  overflow: hidden;
}

.audio-meter-fill {
  height: 100%;
  width: 0%;
  background: #4fc3f7;
  transition: width 80ms linear;
}

.summary-block {
  border-top: 1px solid #262b38;
  padding-top: 10px;
}

.summary-block h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: #9aa4b2;
}

.summary-block ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.88rem;
}

.live-log-block {
  background: #1b1f2a;
  border: 1px solid #262b38;
  border-radius: 10px;
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 260px;
}

.live-log-block h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: #9aa4b2;
}

.event-log {
  flex: 1;
  overflow-y: auto;
  font-family: "Courier New", monospace;
  font-size: 0.82rem;
  color: #d1d5db;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-log-entry {
  border-bottom: 1px solid #21262f;
  padding-bottom: 4px;
}

.event-log-time {
  color: #6b7280;
  margin-right: 6px;
}

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