/* ============================================================
   ClinicaSaaS — Main Stylesheet
   ============================================================ */

:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 60px;
  --primary: #2563EB;
  --primary-light: #EFF6FF;
  --sidebar-bg: #1E293B;
  --sidebar-text: #CBD5E1;
  --sidebar-active: #2563EB;
  --sidebar-hover: rgba(255,255,255,0.07);
  --border-radius: 12px;
  --transition: 0.2s ease;
}

/* ---- Reset / Base ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, -apple-system, sans-serif; background: #F1F5F9; }

/* ---- Layout ---------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  transition: width var(--transition);
  z-index: 1040;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .nav-link span { display: none; }
.sidebar.collapsed .nav-link { justify-content: center; }

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  min-height: var(--topbar-height);
  display: flex; align-items: center;
  white-space: nowrap;
}

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0.75rem 0; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 0.75rem;
  color: var(--sidebar-text);
  padding: 0.65rem 1rem;
  border-radius: 8px;
  margin: 2px 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.sidebar-nav .nav-link i { font-size: 1.1rem; flex-shrink: 0; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: #fff; }

.main-content {
  margin-left: var(--sidebar-width);
  display: flex; flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.main-content.expanded { margin-left: var(--sidebar-collapsed-width); }

.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #E2E8F0;
  position: sticky; top: 0; z-index: 1030;
}

.page-content { flex: 1; }

/* ---- Cards ---------------------------------------------- */
.card { border-radius: var(--border-radius) !important; }
.card-header { border-bottom: 1px solid #F1F5F9 !important; }

/* ---- Icon Circle ---------------------------------------- */
.icon-circle {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar-circle {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}

/* ---- Auth Layout ---------------------------------------- */
.auth-body { background: linear-gradient(135deg, #EFF6FF 0%, #F8FAFC 100%); min-height: 100vh; }
.auth-container {
  display: flex;
  min-height: 100vh;
}
.auth-banner {
  width: 42%;
  background: linear-gradient(160deg, #2563EB 0%, #1D4ED8 60%, #1E40AF 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 3rem;
}
.badge-feature {
  background: rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 1rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  color: #fff;
  width: 100px;
  font-size: 0.78rem;
}
.auth-card-wrapper {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
.auth-card {
  background: #fff;
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

/* ---- Divider -------------------------------------------- */
.divider { position: relative; text-align: center; }
.divider::before, .divider::after {
  content: ''; position: absolute; top: 50%;
  width: calc(50% - 60px);
  border-top: 1px solid #E2E8F0;
}
.divider::before { left: 0; }
.divider::after { right: 0; }
.divider-text { display: inline-block; padding: 0 0.5rem; }

/* ---- OAuth buttons -------------------------------------- */
.oauth-btn { font-size: 0.875rem; }

/* ---- Tables --------------------------------------------- */
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; color: #64748B; }
.table td { font-size: 0.875rem; }

/* ---- Badges / Status ------------------------------------ */
.status-badge { font-size: 0.78rem; padding: 0.3em 0.7em; border-radius: 999px; font-weight: 500; }

/* ---- Dark mode ------------------------------------------ */
[data-bs-theme="dark"] body { background: #0F172A; }
[data-bs-theme="dark"] .topbar,
[data-bs-theme="dark"] .card { background: #1E293B !important; border-color: #334155 !important; }
[data-bs-theme="dark"] .bg-light { background: #334155 !important; }
[data-bs-theme="dark"] .text-muted { color: #94A3B8 !important; }

/* ---- Responsive ----------------------------------------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
}

/* ---- FullCalendar custom -------------------------------- */
.fc-daygrid-event { border-radius: 6px !important; }
.fc-toolbar-chunk .btn { border-radius: 8px !important; }

/* ---- Scheduler page full-height ----------------------- */
.page-content:has(#calendar) { display: flex; flex-direction: column; }
.page-content:has(#calendar) > div { flex: 1; }
.sched-wrap { flex: 1 !important; }

/* ---- Scrollbar ------------------------------------------ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb { background: #475569; }

/* ---- Animations ----------------------------------------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.page-content > * { animation: fadeIn 0.25s ease; }
