/* ==========================================================================
   ELO - DESIGN SYSTEM SOBERANO & ESTILOS GLOBAIS (v1.1.0)
   Cylinder Ecosystem · IRIA SUMMIT® Nursing & Inclusive Care
   ========================================================================== */

:root {
  --bg-main: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #17223b;
  --bg-subtle: #1e293b;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(56, 189, 248, 0.3);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-blue: #0284c7;
  --accent-cyan: #38bdf8;
  --accent-indigo: #6366f1;
  --accent-green: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 10% 5%, rgba(2, 132, 199, 0.15) 0%, transparent 45%),
    radial-gradient(circle at 90% 90%, rgba(99, 102, 241, 0.12) 0%, transparent 45%);
  background-attachment: fixed;
}

/* ================= TOPBAR & NAVIGATION ================= */
.elo-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: rgba(9, 13, 22, 0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.elo-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.elo-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
}

.elo-brand h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.elo-brand p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.elo-nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.nav-link-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-glow);
  transform: translateY(-1px);
}

.nav-link-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border-color: rgba(56, 189, 248, 0.4);
}

/* ================= SELETOR DE SECÇÕES PRINCIPAIS (TABS) ================= */
.elo-tabs-bar {
  display: flex;
  gap: 8px;
  background: rgba(17, 24, 39, 0.7);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  overflow-x: auto;
}

.elo-tab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.elo-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.elo-tab-btn.active {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.25) 0%, rgba(99, 102, 241, 0.2) 100%);
  color: #fff;
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ================= CONTAINER PRINCIPAL ================= */
.elo-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= AUTH & SOVEREIGN STATUS BANNER ================= */
.auth-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.auth-status-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.connected {
  background: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
}

.status-dot.disconnected {
  background: var(--accent-rose);
  box-shadow: 0 0 8px var(--accent-rose);
}

.user-profile-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--accent-cyan);
}

.user-meta {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
}

.user-meta small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ================= UTENTE ATIVO BANNER ================= */
.patient-banner {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.12) 0%, rgba(99, 102, 241, 0.08) 100%);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.patient-info h2 {
  font-size: 1.35rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.patient-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.tag-example {
  background: rgba(245, 158, 11, 0.18);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.4);
  font-weight: 700;
}

.tag-alert {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.35);
}

.patient-vitals {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.vital-item {
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.vital-item b {
  color: var(--accent-cyan);
}

.patient-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ================= OS TRÊS PILARES DA CENTRAL DO AGENTE ================= */
.workflow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
}

.step-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.step-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.step-card.step-a::before { background: linear-gradient(90deg, #38bdf8, #818cf8); }
.step-card.step-b::before { background: linear-gradient(90deg, #10b981, #34d399); }
.step-card.step-c::before { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.step-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

.step-a .step-number { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }
.step-b .step-number { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.step-c .step-number { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }

.step-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.step-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.step-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ================= SECÇÃO: FUNDAMENTOS TEÓRICOS ================= */
.theory-header {
  margin-bottom: 24px;
}

.theory-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.theory-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

.theory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}

.theory-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all 0.2s ease;
}

.theory-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
}

.theory-card-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.theory-card h3 {
  font-size: 1.15rem;
  margin-bottom: 10px;
  color: #fff;
}

.theory-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 14px;
}

.theory-card ul {
  padding-left: 20px;
  font-size: 0.84rem;
  color: #cbd5e1;
  line-height: 1.6;
}

.theory-card li {
  margin-bottom: 6px;
}

/* ================= SECÇÃO: MINI-CURSO GUIADO ================= */
.course-disclaimer {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 0.84rem;
  color: #fcd34d;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.5;
}

.course-modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
}

.course-module-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.module-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.module-badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
}

.module-duration {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.course-module-card h3 {
  font-size: 1.15rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.module-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.module-points {
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 0.82rem;
  margin-bottom: 16px;
}

.module-points p {
  margin-bottom: 8px;
  color: #e2e8f0;
}

.module-points p:last-child {
  margin-bottom: 0;
}

.module-checklist {
  border-top: 1px dashed var(--border-color);
  padding-top: 14px;
}

.module-checklist h4 {
  font-size: 0.82rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #cbd5e1;
  margin-bottom: 6px;
  cursor: pointer;
}

.checklist-item input[type="checkbox"] {
  accent-color: var(--accent-green);
  cursor: pointer;
}

/* ================= BOTÕES & FORMS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-glow);
}

.btn-success {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  filter: brightness(1.1);
}

.btn-warning {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: none !important;
}

/* ================= RESULTADOS & OUTPUT BOXES ================= */
.output-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  min-height: 180px;
  max-height: 380px;
  overflow-y: auto;
  font-size: 0.85rem;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  margin: 12px 0 6px;
  color: var(--accent-cyan);
}

.markdown-body ul {
  padding-left: 20px;
  margin: 8px 0;
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent-cyan);
  padding-left: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin: 10px 0;
}

.gemini-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(56, 189, 248, 0.1);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.sync-success-box {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-md);
  padding: 16px;
}

.sync-success-box h4 {
  color: var(--accent-green);
  margin-bottom: 8px;
}

.sync-success-box code {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  color: #34d399;
  font-family: var(--font-mono);
}

/* ================= FORM CONTROLS ================= */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

textarea.form-control {
  resize: vertical;
  min-height: 90px;
}

/* ================= MODAL DE CONFIGURAÇÃO ================= */
dialog {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 540px;
  width: 90%;
  margin: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ================= SPINNER ================= */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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

/* ================= RESPONSIVIDADE ================= */
@media (max-width: 768px) {
  .elo-navbar {
    padding: 12px 16px;
    flex-direction: column;
    gap: 12px;
  }
  .workflow-grid, .theory-grid, .course-modules-grid {
    grid-template-columns: 1fr;
  }
  .auth-bar, .patient-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}
