@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===========================
   CSS Custom Properties
   =========================== */
:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #d1fae5;
  --primary-muted: #ecfdf5;
  --accent-blue: #3b82f6;
  --accent-blue-light: #eff6ff;
  --accent-orange: #f59e0b;
  --accent-orange-light: #fffbeb;
  --bg-page: #f4f6f8;
  --bg-card: #ffffff;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --sidebar-w: 260px;
  --topbar-h: 72px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ===========================
   Auth Page
   =========================== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(ellipse at top right, #d1fae5 0%, transparent 60%),
    radial-gradient(ellipse at bottom left, #ecfdf5 0%, transparent 60%),
    #f9fafb;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  border: 1px solid var(--border);
  animation: slideUp 0.4s ease-out;
}

.logo-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.logo-section h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.75rem;
}

.logo-section h1 span { color: var(--primary); }

.auth-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-header h2 { font-size: 1.4rem; font-weight: 600; }
.auth-header p { color: var(--text-muted); margin-top: 0.35rem; font-size: 0.95rem; }

/* Inputs */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"] {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  outline: none;
  transition: var(--transition);
  font-size: 0.95rem;
  font-family: inherit;
  background: white;
  width: 100%;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.btn {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1.5px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-family: inherit;
}

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

.btn-primary:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===========================
   Dashboard Layout
   =========================== */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

/* ===========================
   Sidebar
   =========================== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: white;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 0 0.75rem;
  margin-bottom: 2.5rem;
}

.sidebar-logo strong { color: var(--primary); }

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-muted);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition);
}

.nav-item:hover {
  background: var(--bg-page);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* Sidebar Footer */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-light);
}

.btn-logout {
  flex-shrink: 0;
  padding: 0.5rem;
  border-radius: 8px;
  color: var(--text-muted);
  transition: var(--transition);
  cursor: pointer;
  background: none;
  border: none;
  display: flex;
}

.btn-logout:hover {
  background: #fee2e2;
  color: #ef4444;
}

/* ===========================
   Main Content
   =========================== */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
}

.hamburger {
  display: none;
  padding: 0.4rem;
  border-radius: 8px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-muted);
  transition: var(--transition);
  flex-shrink: 0;
}

.hamburger:hover { background: var(--bg-page); color: var(--text-main); }

.topbar-title { flex: 1; }
.topbar-title h1 { font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.topbar-title p { font-size: 0.85rem; color: var(--text-muted); }

/* ===========================
   Stats Cards
   =========================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  padding: 1.75rem;
  align-items: start;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: var(--transition);
  animation: slideUp 0.4s ease-out;
}

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

/* Wide card: full row */
.stat-card-wide {
  grid-column: 1 / -1;
  flex-direction: column;
  gap: 1.25rem;
}

.stat-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-green { background: var(--primary-light); color: var(--primary-dark); }
.stat-icon-blue  { background: var(--accent-blue-light); color: var(--accent-blue); }
.stat-icon-orange { background: var(--accent-orange-light); color: var(--accent-orange); }

.stat-card-body { flex: 1; }
.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-number { display: block; }

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 0.35rem;
}

/* Retorno List */
.retorno-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.retorno-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  transition: var(--transition);
  color: var(--text-main);
  text-decoration: none;
}

.retorno-item:hover {
  border-color: var(--primary);
  background: var(--primary-muted);
  color: var(--primary-dark);
}

.retorno-item svg { margin-left: auto; color: var(--text-light); }

.retorno-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-orange-light);
  color: var(--accent-orange);
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.retorno-name { font-weight: 500; font-size: 0.9rem; }

.retorno-empty {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Loading shimmer */
.loading-shimmer {
  display: inline-block;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
  height: 1.8rem;
  width: 60px;
}

.loading-shimmer.wide { width: 200px; height: 42px; }

.loading-row {
  padding: 0.5rem 0;
}

/* Mobile Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ===========================
   Animations
   =========================== */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .hamburger { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    z-index: 200;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  .sidebar-overlay { display: none; }
  .sidebar-overlay.active { display: block; }

  .main-content { width: 100%; }

  .topbar { padding: 1rem; }

  .stats-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1rem;
  }

  .stat-card-wide { grid-column: 1; }

  #novo-paciente-top-btn { display: none; }
}

@media (max-width: 480px) {
  .auth-card { padding: 1.75rem 1.25rem; }
}

/* ===========================
   Page Headers & Actions
   =========================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 0 1.75rem;
  margin-top: 1.75rem;
}

.search-container {
  display: flex;
  align-items: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 1rem;
  width: 100%;
  max-width: 400px;
  transition: var(--transition);
}

.search-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-container input {
  border: none;
  background: none;
  padding: 0.75rem 0.5rem;
  width: 100%;
  font-size: 0.9rem;
  box-shadow: none;
}

.search-container svg {
  color: var(--text-light);
}

/* ===========================
   Tab Navigation
   =========================== */
.tabs-container {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  padding: 0 1.75rem;
}

.tab-btn {
  padding: 0.75rem 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

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

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-out;
  padding: 0 1.75rem 2rem;
}

.tab-content.active {
  display: block;
}

/* ===========================
   Form Layout & Fields
   =========================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.full-width {
  grid-column: 1 / -1;
}

/* Checkbox Groups (Multi-choice) */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
}

.option-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.option-item:hover {
  background: var(--bg-page);
  border-color: var(--primary);
}

.option-item.selected {
  background: var(--primary-muted);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Read Only / Calculated Fields */
input:read-only {
  background-color: var(--bg-page);
  color: var(--text-muted);
  cursor: default;
}

.imc-display {
  padding: 1rem;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
}

.imc-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
}

/* ===========================
   Table Styles (Listing)
   =========================== */
.data-table-container {
  padding: 0 1.75rem;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table th {
  background: var(--bg-page);
  padding: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 1rem;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

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

.data-table tr:hover td {
  background: var(--bg-page);
  cursor: pointer;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 1rem;
  color: var(--text-light);
}

/* Form Helper Text */
.form-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--primary-dark);
}


/* Responsive Forms */
@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ===========================
   Modal Styles
   =========================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  padding: 1rem;
}

.modal-overlay.active {
  display: flex !important;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 600px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  color: var(--text-light);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* ===========================
   Profile Sections
   =========================== */
.profile-section {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.profile-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.profile-section-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.profile-section-title svg {
  color: var(--primary);
}

/* Chart Container */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
  margin-bottom: 1.5rem;
}

.chart-empty {
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.95rem;
  flex-direction: column;
  gap: 1rem;
}

/* Info Row for Summary */
.info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.info-item {
  flex: 1;
  min-width: 150px;
  padding: 1rem;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.info-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.info-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}
