/* Remote Work Monitor V2 Lite Hardened — Estilos */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242736;
  --border: #2e3147;
  --accent: #4f7ef8;
  --accent-hover: #6b93ff;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 8px;
  --shadow: 0 4px 16px rgba(0,0,0,0.4);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Login ─────────────────────────────────────────────────── */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  display: block;
  width: 160px;
  margin: 0 auto 16px;
}

.login-card .subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 28px;
  text-align: center;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.form-group input:focus {
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

/* ── Dashboard ─────────────────────────────────────────────── */
#dashboard-page {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

#dashboard-page.visible {
  display: flex;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  height: 36px;
  width: auto;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-left h1 {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface2);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-badge.connected .status-dot { background: var(--green); }
.status-badge.connecting .status-dot { background: var(--yellow); animation: pulse 1.2s infinite; }
.status-badge.disconnected .status-dot { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.btn-logout {
  padding: 6px 14px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  touch-action: manipulation;
}

.btn-logout:hover { color: var(--text); border-color: var(--text-muted); }

.btn-audio {
  padding: 4px 10px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-audio:hover { color: var(--text); border-color: var(--text-muted); }
.btn-audio:not(.muted) { color: var(--green); border-color: var(--green); }

/* Main content */
.content {
  flex: 1;
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Grid layout */
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .grid .span-2 { grid-column: span 2; }
}

@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .grid .span-3 { grid-column: span 3; }
  .grid .span-2 { grid-column: span 2; }
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

/* Metrics */
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.metric-row:last-child { margin-bottom: 0; }

.metric-label { font-size: 0.85rem; color: var(--text-muted); }

.metric-value {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease, background 0.3s;
  background: var(--accent);
}

.progress-fill.warn { background: var(--yellow); }
.progress-fill.danger { background: var(--red); }

/* Stream area */
.stream-container {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stream-container canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.stream-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.75);
  color: var(--text-muted);
  font-size: 0.9rem;
  gap: 10px;
  text-align: center;
  padding: 16px;
}

.stream-overlay.hidden { display: none; }

.stream-overlay .icon {
  font-size: 2rem;
  opacity: 0.5;
}

/* Log viewer */
.log-viewer {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  height: 180px;
  overflow-y: auto;
  font-family: "Consolas", "Monaco", monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-muted);
  -webkit-overflow-scrolling: touch;
}

.log-viewer .log-line { white-space: pre-wrap; word-break: break-all; }
.log-viewer .log-line.error { color: var(--red); }
.log-viewer .log-line.warn { color: var(--yellow); }

/* Audit table */
.audit-table {
  width: 100%;
  font-size: 0.78rem;
  border-collapse: collapse;
}

.audit-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.audit-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}

.audit-table tr:last-child td { border-bottom: none; }

.audit-scroll {
  max-height: 200px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Agent info */
.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  font-size: 0.85rem;
}

.info-grid .key { color: var(--text-muted); }
.info-grid .val { font-weight: 500; font-variant-numeric: tabular-nums; }

/* Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Responsive stream card */
@media (max-width: 600px) {
  .content { padding: 10px; }
  .header { padding: 10px 12px; }
  .header-left h1 { font-size: 0.9rem; }
  .log-viewer { height: 140px; }
}
