/* Complexo de Saúde Prof. Severino Lopes — Admin Panel */

:root {
  --primary: #17a98e;
  --primary-dark: #128a73;
  --primary-light: #e6f5f2;
  --secondary: #1e3872;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --background: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.14);
  --sidebar-width: 252px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--background);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--secondary);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0,0,0,0.14);
}

.logo {
  padding: 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
}

.logo-icon { flex-shrink: 0; }

.logo-text h1 {
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.logo-text span {
  font-size: 10.5px;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 500;
}

.nav {
  padding: 10px 8px;
  flex: 1;
  overflow-y: auto;
}

.nav-section {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 14px 12px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: rgba(255,255,255,0.62);
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 2px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.14s, color 0.14s;
  cursor: pointer;
}

.nav-icon { flex-shrink: 0; opacity: 0.7; transition: opacity 0.14s; }

.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item:hover .nav-icon { opacity: 1; }

.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 14px 8px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.sidebar-footer .nav-item { color: rgba(255,255,255,0.5); }

/* ── Main Layout ─────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  background: var(--surface);
  padding: 0 28px;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

#user-name {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 12px;
  background: var(--success-bg);
  color: var(--success);
  border-radius: 20px;
  border: 1px solid rgba(22,163,74,0.18);
}

.status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
}

.content {
  padding: 26px 28px;
  flex: 1;
}

.page { display: none; }
.page.active { display: block; }

/* ── Stat Cards ──────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s, transform 0.18s;
}

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

.stat-icon {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 10px;
  color: var(--primary);
  flex-shrink: 0;
}

.stat-info { display: flex; flex-direction: column; gap: 3px; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Cards & Sections ────────────────────────────── */
.card, .section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card h3, .section h3 {
  margin-bottom: 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Tables ──────────────────────────────────────── */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

table { width: 100%; border-collapse: collapse; }

th, td { padding: 11px 15px; text-align: left; }

th {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  font-size: 13.5px;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* ── Forms ───────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

input, select, textarea {
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23,169,142,0.11);
}

input::placeholder, textarea::placeholder { color: var(--text-light); }

input:disabled {
  background: var(--surface-alt);
  cursor: not-allowed;
  color: var(--text-muted);
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.14s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-alt); border-color: #cbd5e1; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 6px 10px; font-size: 12.5px; }

.btn:disabled { opacity: 0.52; cursor: not-allowed; pointer-events: none; }

/* ── Chips ───────────────────────────────────────── */
.chips-container {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.chip {
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.12s;
  font-weight: 500;
}

.chip:hover { border-color: var(--primary); color: var(--primary); }

.chip.selected {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
}

/* ── Page Actions ────────────────────────────────── */
.page-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.page-actions input,
.page-actions select {
  min-width: 180px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: #f0f9ff; color: #0284c7; }

/* ── Modal ───────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.48);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(2px);
}

.modal.active { display: flex; }

.modal-content {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.12s;
}

.modal-close:hover { background: var(--surface-alt); color: var(--text); }

.modal-body { padding: 22px; }

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-alt);
  border-radius: 0 0 14px 14px;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 70px; }
  .logo-text, .nav-label, .nav-section { display: none; }
  .logo { justify-content: center; padding: 18px 10px; }
  .nav-item { justify-content: center; padding: 12px 10px; gap: 0; }
  .nav-icon { opacity: 0.75; }
  .sidebar-footer .nav-label { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 18px 14px; }
  .header { padding: 0 16px; }
}
