/* ======================================================
   CS INÁ ROSA BORGES — Sistema de Fila Virtual
   Estilo mobile-first, azul/verde SUS
   ====================================================== */

:root {
  --primary:       #1565C0;
  --primary-light: #1976D2;
  --primary-dark:  #0D47A1;
  --secondary:     #2E7D32;
  --secondary-light:#388E3C;

  --priority-1:    #C62828;
  --priority-2:    #E65100;
  --priority-n:    #1565C0;

  --bg:            #F0F4F8;
  --surface:       #FFFFFF;
  --surface-2:     #F5F7FA;
  --border:        #DDE3EA;

  --text:          #1A2332;
  --text-muted:    #6B7A8D;

  --success:       #2E7D32;
  --danger:        #C62828;
  --warning:       #E65100;

  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg:     0 6px 24px rgba(0,0,0,0.15);

  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ---- Typography ---- */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem;   font-weight: 600; }

/* ---- SVG Icons ---- */
svg[aria-hidden="true"] {
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
}
.header-logo svg { width: 1.6rem; height: 1.6rem; }
.logo-icon svg   { width: 3rem;   height: 3rem; }
.empty-panel svg { width: 3rem;   height: 3rem; opacity: 0.6; }

/* ---- Layout ---- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ---- Header ---- */
.app-header {
  background: var(--primary);
  color: white;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow);
}
.app-header .header-logo {
  font-size: 1.5rem;
}
.app-header .header-title {
  flex: 1;
}
.app-header .header-title h1 {
  font-size: 1.1rem;
  font-weight: 700;
}
.app-header .header-title p {
  font-size: 0.78rem;
  opacity: 0.85;
}
.app-header .header-badge {
  background: rgba(255,255,255,0.2);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.card-header h2 {
  color: var(--primary);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary   { background: var(--primary);   color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-danger    { background: var(--danger);    color: white; }
.btn-warning   { background: var(--warning);   color: white; }
.btn-outline   { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-sm        { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-lg        { padding: 0.9rem 1.75rem; font-size: 1.05rem; }
.btn-block     { width: 100%; justify-content: center; }

.btn-primary:hover:not(:disabled)   { filter: brightness(1.1); }
.btn-secondary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-danger:hover:not(:disabled)    { filter: brightness(1.1); }
.btn-warning:hover:not(:disabled)   { filter: brightness(1.1); }

/* ---- Forms ---- */
.form-group {
  margin-bottom: 1rem;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
}
.form-row {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr 1fr;
}

/* ---- Priority Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-P1 { background: var(--priority-1); color: white; }
.badge-P2 { background: var(--priority-2); color: white; }
.badge-N  { background: var(--priority-n); color: white; }
.badge-tag {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ---- Patient Card in Queue ---- */
.patient-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  transition: box-shadow 0.15s;
}
.patient-card:hover { box-shadow: var(--shadow); }
.patient-card.priority-1 { border-left: 4px solid var(--priority-1); }
.patient-card.priority-2 { border-left: 4px solid var(--priority-2); }
.patient-card.priority-n { border-left: 4px solid var(--priority-n); }

.patient-ticket {
  font-size: 1rem;
  font-weight: 800;
  min-width: 70px;
  text-align: center;
}
.patient-info {
  flex: 1;
  min-width: 0;
}
.patient-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.patient-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.1rem;
}
.patient-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* ---- Current Patient Panel ---- */
.current-patient {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.current-patient h3 {
  opacity: 0.85;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}
.current-patient .ticket-big {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1;
}
.current-patient .patient-big-name {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}
.current-patient .patient-detail {
  font-size: 0.85rem;
  opacity: 0.85;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.current-patient .action-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.current-patient .btn-outline {
  border-color: rgba(255,255,255,0.6);
  color: white;
}
.current-patient .btn-outline:hover { background: rgba(255,255,255,0.15); }
.empty-panel {
  text-align: center;
  padding: 2rem;
  color: rgba(255,255,255,0.7);
}
.empty-panel p { font-size: 0.9rem; margin-top: 0.5rem; }

/* ---- Queue List ---- */
.queue-list {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 2px;
}
.queue-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.queue-count {
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--primary);
  color: white;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

/* ---- Page Grid ---- */
.page-grid {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}
@media (min-width: 768px) {
  .page-grid-2 { grid-template-columns: 1fr 1fr; }
  .page-grid-aside { grid-template-columns: 380px 1fr; }
}

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo .logo-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}
.login-logo h1 {
  font-size: 1.1rem;
  color: var(--primary);
  font-weight: 700;
}
.login-logo p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ---- Notification Toast ---- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
}
.toast {
  background: var(--text);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  animation: slideIn 0.25s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
  animation: popIn 0.2s ease;
}
.modal h2 { margin-bottom: 1rem; color: var(--primary); }
.modal-footer { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ---- Display Page ---- */
.display-page {
  background: #0A1628;
  color: white;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
}
.display-header {
  background: linear-gradient(135deg, #1565C0, #0D47A1);
  padding: 1.5rem 2rem;
  text-align: center;
  border-bottom: 3px solid #42A5F5;
}
.display-header .ubs-name {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.display-header .ubs-sub {
  font-size: 0.95rem;
  opacity: 0.8;
  margin-top: 0.25rem;
}
.display-header .time-display {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 0.75rem;
  color: #90CAF9;
}
.display-main {
  flex: 1;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.display-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #78909C;
  margin-bottom: 1rem;
  font-weight: 600;
}
.call-current {
  background: linear-gradient(135deg, #1565C0 0%, #0D47A1 100%);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  border: 2px solid #42A5F5;
  box-shadow: 0 0 40px rgba(66,165,245,0.3);
  animation: pulse-glow 2s ease-in-out infinite;
}
.call-current .call-ticket {
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  text-shadow: 0 0 20px rgba(255,255,255,0.3);
}
.call-current .call-name {
  font-size: 2rem;
  font-weight: 600;
  margin-top: 0.5rem;
  opacity: 0.95;
}
.call-current .call-location {
  font-size: 1.1rem;
  color: #90CAF9;
  margin-top: 0.5rem;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 30px rgba(66,165,245,0.3); }
  50%       { box-shadow: 0 0 60px rgba(66,165,245,0.6); }
}
.calls-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.call-item {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  align-items: center;
  gap: 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.call-item .item-ticket {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.call-item .item-name { font-size: 1rem; font-weight: 500; }
.call-item .item-location { font-size: 0.85rem; color: #90CAF9; }
.call-item .item-time { font-size: 0.8rem; color: #546E7A; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

/* ---- Utility ---- */
.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ---- Scrollable queue list ---- */
.queue-scroll {
  max-height: 500px;
  overflow-y: auto;
}

/* ---- History ---- */
.history-item {
  display: flex;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.history-item:last-child { border-bottom: none; }
.history-time { color: var(--text-muted); min-width: 55px; }
.history-ticket { font-weight: 700; min-width: 70px; }
.history-name { flex: 1; }
.history-local { color: var(--text-muted); }

/* ---- Status chip ---- */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-online { background: #E8F5E9; color: #2E7D32; }
.status-offline { background: #FAFAFA; color: #9E9E9E; }

/* ---- Section tabs (doctor) ---- */
.section-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.tab-btn {
  flex: 1;
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
