/* ================================================================
   DESIGN SYSTEM - Portal de Suporte Dr. Fagner Andrade
   Baseado nos HTMLs aprovados: Prontuários, Ferramentas Clínicas,
   Página de Seleção e Formulário Nutricional/Esportivo
   ================================================================ */

/* === VARIÁVEIS === */
:root {
  --bg: #e2e8f0;
  --card-bg: #ffffff;
  --input-bg: #f8fafc;
  --accent: #0f766e;
  --accent-dark: #0b3552;
  --ink: #0f172a;
  --muted: #334155;
  --muted2: #475569;
  --muted-light: #64748b;
  --line: #cbd5e1;
  --line-soft: rgba(15,23,42,.06);
  --focus: #0ea5e9;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --accent-green: #0f766e;
  --accent-blue: #0ea5e9;
  --radius: 16px;
  --shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Open Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100%;
}
img { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === TIPOGRAFIA === */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 8px;
  font-weight: 700;
  color: var(--accent-dark);
  line-height: 1.2;
}
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 12px; }
.text-muted { color: var(--muted-light); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-upper { text-transform: uppercase; letter-spacing: 0.03em; }

/* === GRIDS === */
.grid { display: grid; gap: 20px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

/* === CARDS E SEÇÕES (padrão prontuário/ferramentas) === */
section, .card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 30px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.6);
  animation: slideUp 0.6s ease-out;
}
section h2, .card-header h3 {
  margin: 0;
  padding: 20px 28px;
  background: linear-gradient(to bottom, #f8fafc, #ffffff);
  border-bottom: 1px solid var(--line);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.card-header {
  padding: 20px 28px;
  background: linear-gradient(to bottom, #f8fafc, #ffffff);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-header .icon {
  font-size: 20px;
  color: var(--accent);
}
.card-body {
  padding: 24px 28px;
}

/* === FORMULÁRIOS (padrão prontuário) === */
label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.01em;
}
label span {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.8rem;
  margin-left: 4px;
}
input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--focus);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(14,165,233,0.15);
}
textarea { min-height: 80px; resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: rgba(15,23,42,.4); }
.form-group { margin-bottom: 20px; }
.form-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 4px;
  display: none;
}
.is-invalid { border-color: var(--danger) !important; }

/* === BOTÕES (padrão prontuário/ferramentas: pill 24px) === */
button, .btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-bg);
  color: var(--muted);
  padding: 10px 20px;
  border-radius: 24px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
  text-decoration: none;
}
button:hover, .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.08);
  color: var(--ink);
  border-color: var(--accent);
}
.btn-primary, button.primary-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover, button.primary-btn:hover {
  background: var(--accent-dark);
  color: #fff;
  border-color: var(--accent-dark);
}
.btn-danger, button.danger-btn {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover, button.danger-btn:hover {
  background: rgba(239,68,68,0.2);
}
.btn-ghost, button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  box-shadow: none;
}
.btn-ghost:hover, button.ghost:hover {
  background: rgba(15,118,110,0.08);
  color: var(--accent);
}
.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}
.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 24px;
}

/* === BADGES === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-success { background: rgba(16,185,129,0.1); color: #059669; }
.badge-warning { background: rgba(245,158,11,0.1); color: #d97706; }
.badge-danger { background: rgba(239,68,68,0.1); color: #dc2626; }
.badge-info { background: rgba(14,165,233,0.1); color: #0284c7; }
.badge-accent { background: rgba(15,118,110,0.1); color: var(--accent); }

/* === TABELAS (padrão ferramentas clínicas) === */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.data-table th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--accent-dark);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}
.data-table tr:hover { background: #f8fafc; }

/* === ABAS / TABS (padrão ferramentas clínicas) === */
.tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: #fff;
  padding: 0 28px;
  flex-wrap: wrap;
}
.tabs::before,
.tabs::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 20px 28px;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 0;
  box-shadow: none;
}
.tab:hover {
  color: var(--accent);
  background: transparent;
  transform: none;
  box-shadow: none;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}
.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease-out;
}
.tab-pane.active { display: block; }

/* === MODAL === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.active { display: flex; }
.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.6);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn 0.25s ease-out;
}
.modal-header {
  padding: 20px 28px;
  background: linear-gradient(to bottom, #f8fafc, #ffffff);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--muted-light);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  box-shadow: none;
}
.modal-close:hover {
  color: var(--danger);
  background: rgba(239,68,68,0.08);
  transform: none;
  box-shadow: none;
}
.modal-body { padding: 24px 28px; }
.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* === TOAST (padrão ferramentas) === */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #1e293b;
  color: #fff;
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.25s;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.toast.show { opacity: 1; }
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  box-shadow: none;
}
.toast-close:hover {
  color: #fff;
  transform: none;
  box-shadow: none;
}

/* === DROPDOWN === */
.dropdown {
  position: relative;
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 25px rgba(0,0,0,0.12);
  min-width: 200px;
  z-index: 100;
  display: none;
  overflow: hidden;
}
.dropdown.active .dropdown-menu { display: block; }
.dropdown-item {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}
.dropdown-item:hover {
  background: #f8fafc;
  text-decoration: none;
}
.dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted-light);
}
.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}
.empty-state h3 {
  color: var(--muted);
  font-size: 1.1rem;
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 0.9rem;
}

/* === LOADING === */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* === PAGINATION === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px;
}
.pagination button, .pagination .page-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
}
.pagination button.active, .pagination .page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* === ALERTS === */
.alert {
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 0.9rem;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-warning { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* === FOOTER (padrão prontuário/ferramentas) === */
.footer {
  text-align: center;
  padding: 30px 20px;
  color: var(--muted-light);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
  margin-top: 40px;
  background: #fff;
  border-radius: var(--radius);
}
.footer p { margin: 0; }
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* === ANIMAÇÕES === */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* === RESPONSIVIDADE === */
@media (max-width: 900px) {
  .g-2, .g-3, .g-4 { grid-template-columns: 1fr; }
  .tabs {
    overflow-x: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }
  .tab {
    padding: 14px 20px;
    font-size: 13px;
    white-space: nowrap;
  }
}
@media (max-width: 480px) {
  section h2, .card-header h3 { padding: 16px 20px; font-size: 1rem; }
  .card-body { padding: 16px 20px; }
  .modal-header, .modal-body, .modal-footer { padding-left: 20px; padding-right: 20px; }
}
