:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --secondary: #0d9488;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --dark: #0f172a;
  --light: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text-primary: #1e293b;
  --text-muted: #64748b;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: #f1f5f9;
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Container */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
}

.container-narrow {
  max-width: 580px;
}

/* Header */
header.app-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--dark);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 1.25rem;
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.logo-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--dark);
}

.card-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

/* Grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

/* Formulários */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--dark);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-color: #fff;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-control.is-invalid {
  border-color: var(--danger);
  background-color: #fef2f2;
}

.form-control.is-valid {
  border-color: var(--success);
  background-color: #f0fdf4;
}

.form-text {
  font-size: 0.8rem;
  margin-top: 0.35rem;
  color: var(--text-muted);
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease-in-out;
  touch-action: manipulation;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #e2e8f0;
  color: var(--dark);
}
.btn-secondary:hover {
  background-color: #cbd5e1;
}

.btn-success {
  background-color: var(--success);
  color: white;
}
.btn-success:hover {
  background-color: #15803d;
}

.btn-warning {
  background-color: var(--warning);
  color: white;
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 1rem 1.5rem;
  font-size: 1.15rem;
}

/* Câmera e Scanner Facial */
.camera-container {
  position: relative;
  width: 100%;
  max-width: 360px;
  height: 440px;
  margin: 0 auto 1.25rem auto;
  border-radius: 20px;
  overflow: hidden;
  background-color: #000;
  box-shadow: var(--shadow-lg);
}

.camera-container video,
.camera-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Guia Elíptico Vertical para enquadramento facial biométrico (Estilo Banco/Gov) */
.face-guide-overlay {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 290px;
  border: 3.5px dashed rgba(255, 255, 255, 0.75);
  border-radius: 50% / 60%;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.6);
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 10;
}

.face-guide-overlay.detected {
  border-color: #22c55e;
  border-style: solid;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.5), 0 0 25px rgba(34, 197, 94, 0.65);
}

.face-guide-overlay.searching {
  border-color: #38bdf8;
  animation: pulseElipse 1.8s infinite;
}

@keyframes pulseElipse {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.85; }
  50% { transform: translate(-50%, -50%) scale(1.02); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0.85; }
}

.camera-status-badge {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  color: white;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  backdrop-filter: blur(6px);
  z-index: 15;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* QR Code Display */
.qr-box {
  background: white;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s;
}

.qr-box:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.qr-canvas-holder {
  background: #fff;
  padding: 8px;
  border-radius: 8px;
  margin: 0.75rem 0;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Alertas */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-info {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.alert-success {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.alert-warning {
  background-color: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.alert-danger {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* Preview de Arquivos */
.preview-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.preview-thumb {
  width: 90px;
  height: 90px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid var(--border);
}

/* Painel de TV / Chamada da Sala de Espera */
.tv-painel-wrapper {
  background: linear-gradient(135deg, #091a28, #0f2b46);
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2rem;
}

.tv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}

.tv-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.tv-clock {
  font-size: 2.5rem;
  font-weight: 700;
  font-family: monospace;
  color: #38bdf8;
}

.tv-main-call {
  background: rgba(255, 255, 255, 0.05);
  border: 3px solid #38bdf8;
  border-radius: 24px;
  padding: 3rem;
  text-align: center;
  margin-bottom: 2.5rem;
  box-shadow: 0 0 50px rgba(56, 189, 248, 0.25);
  animation: callGlow 2s infinite alternate;
}

@keyframes callGlow {
  0% { box-shadow: 0 0 30px rgba(56, 189, 248, 0.2); }
  100% { box-shadow: 0 0 60px rgba(56, 189, 248, 0.5); }
}

.tv-call-title {
  font-size: 1.8rem;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
}

.tv-call-name {
  font-size: 4rem;
  font-weight: 900;
  color: #ffffff;
  margin-bottom: 1rem;
  line-height: 1.1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.tv-call-balcao {
  display: inline-block;
  background: #0284c7;
  color: white;
  padding: 0.75rem 2.5rem;
  font-size: 2.5rem;
  font-weight: 800;
  border-radius: 16px;
  letter-spacing: 1px;
}

.tv-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.tv-history-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tv-history-name {
  font-size: 1.3rem;
  font-weight: 600;
  color: #e2e8f0;
}

.tv-history-balcao {
  font-size: 1.2rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  padding: 0.35rem 0.85rem;
  border-radius: 8px;
}

/* Balcão de Atendimento Styles */
.balcao-badge {
  font-size: 1.5rem;
  font-weight: 700;
  padding: 0.5rem 1.25rem;
  background: #e0f2fe;
  color: var(--primary);
  border-radius: 12px;
  display: inline-block;
}

.timer-box {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: monospace;
  color: var(--dark);
}

/* Footer */
footer.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  background: white;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Responsividade Mobile */
@media (max-width: 768px) {
  .tv-call-name { font-size: 2.5rem; }
  .tv-call-balcao { font-size: 1.75rem; padding: 0.5rem 1.5rem; }
  .tv-header h1 { font-size: 1.5rem; }
  .tv-clock { font-size: 1.75rem; }
}
