/* ============================================================
   ClinicFlow Pro — css/layout.css
   Phase 1: Foundation
   App Shell Layout: Sidebar + Topbar + Content + Bottom Nav
   Desktop: sidebar right (260px) + content left
   Mobile: drawer + bottom navigation
   ============================================================ */

/* ============================================================
   LOGIN PAGE LAYOUT
   ============================================================ */

#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Decorative background circles */
#login-page::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: var(--primary-light);
  opacity: 0.06;
  top: -200px;
  right: -150px;
  pointer-events: none;
}
#login-page::after {
  content: '';
  position: absolute;
  width: 350px;
  height: 350px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.05;
  bottom: -100px;
  left: -100px;
  pointer-events: none;
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.4s ease forwards;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon img {
  width: 70px;
  height: 70px;
  border-radius: 10px;
}


.login-logo .logo-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 32px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.login-logo h1 {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-logo p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.login-footer {
  text-align: center;
  margin-top: 32px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  opacity: 0.7;
}

/* ============================================================
   APP SHELL — MAIN LAYOUT
   ============================================================ */

#app-shell {
  display: block;
  min-height: 100vh;
  background: var(--bg-main);
}

/* ============================================================
   DEMO BANNER
   ============================================================ */

#demo-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: calc(var(--z-topbar) + 10);
  padding: 8px 20px;
  text-align: center;
  font-size: var(--font-size-sm);
  font-weight: 600;
  background-color: #fef3c7;
  color: #92400e;
  border-bottom: 2px solid #fcd34d;
}

/* When demo banner is visible, push everything down */
body.has-demo-banner #topbar {
  top: 38px;
}
body.has-demo-banner #sidebar {
  top: 38px;
  height: calc(100vh - 38px);
}
body.has-demo-banner #main-content {
  margin-top: calc(var(--topbar-height) + 38px);
}

/* ============================================================
   TOPBAR
   ============================================================ */

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: var(--sidebar-width);   /* RTL: sidebar is on right */
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

#page-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

#menu-toggle {
  display: none;  /* Hidden on desktop, shown on mobile */
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-sm);
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  border: 1px solid var(--border);
  font-size: 20px;
  color: var(--text-primary);
  transition: background var(--transition);
}
#menu-toggle:hover {
  background: var(--border);
}

/* ============================================================
   SIDEBAR
   ============================================================ */

#sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: -4px 0 16px rgba(0,0,0,0.15);
  transition: transform var(--transition-slow);
}

/* Sidebar Logo Area */
.sidebar-logo {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--sidebar-border);
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-logo .logo-mark {
  /* width: 38px;
  height: 38px; */
  width: 60px;
  height: 45px;
  /* background: linear-gradient(135deg, var(--primary-light), var(--accent)); */
  /* border-radius: 10px; */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-logo .logo-text strong {
  font-size: var(--font-size-md);
  font-weight: 800;
  color: var(--sidebar-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logo .logo-text small {
  font-size: 11px;
  color: var(--sidebar-text);
  opacity: 0.6;
  white-space: nowrap;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  color: var(--sidebar-text);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
  opacity: 0.85;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  opacity: 1;
}

.sidebar-nav a.active {
  background: var(--sidebar-active);
  opacity: 1;
  font-weight: 700;
}

.sidebar-nav a .nav-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.sidebar-nav a .nav-label {
  flex: 1;
}

/* Sidebar separator */
.sidebar-sep {
  height: 1px;
  background: var(--sidebar-border);
  margin: 8px 14px;
}

/* Sidebar Section Label */
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-text);
  opacity: 0.4;
  padding: 8px 14px 4px;
}

/* Sidebar User Section (bottom) */
.sidebar-user {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user .user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user .user-info strong {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-info small {
  font-size: 11px;
  color: var(--sidebar-text);
  opacity: 0.6;
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */

#main-content {
  margin-right: var(--sidebar-width);   /* RTL: sidebar is on right */
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
  padding: var(--content-padding);
  background: var(--bg-main);
}

/* ============================================================
   PAGE SECTIONS
   ============================================================ */

.page {
  display: none;
  animation: fadeInUp 0.25s ease forwards;
}

.page.active {
  display: block;
}

/* Page header (title + actions row) */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-header h2 {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.page-header .page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Page toolbar (search + filter + export) */
.page-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-toolbar .search-input-wrap {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  position: relative;
}

.page-toolbar .search-input-wrap .search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  font-size: 16px;
}

.page-toolbar .search-input-wrap input {
  width: 100%;
  padding: 9px 38px 9px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.page-toolbar .search-input-wrap input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(var(--input-focus), 0.12);
  outline: none;
}

.page-toolbar .search-input-wrap input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

/* ============================================================
   STAT CARDS GRID (Dashboard)
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

/* ============================================================
   DASHBOARD GRID AREAS
   ============================================================ */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 24px;
}

.dashboard-grid .col-full {
  grid-column: 1 / -1;
}

/* ============================================================
   MOBILE OVERLAY (when sidebar drawer open)
   ============================================================ */

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  z-index: var(--z-overlay);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

#sidebar-overlay.active {
  display: block;
  animation: fadeIn 0.2s ease forwards;
}

/* ============================================================
   MOBILE BOTTOM NAVIGATION
   ============================================================ */

#bottom-nav {
  display: none;  /* Hidden on desktop */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottomnav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: var(--z-topbar);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  align-items: center;
  justify-content: space-around;
}

#bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 16px;
  color: var(--text-secondary);
  opacity: 0.6;
  font-size: 10px;
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  min-width: 60px;
  transition: color var(--transition), opacity var(--transition);
}

#bottom-nav button .bnav-icon {
  font-size: 22px;
  line-height: 1;
}

#bottom-nav button span {
  font-size: 10px;
}

#bottom-nav button.active {
  color: var(--primary-light);
  opacity: 1;
  font-weight: 700;
}

#bottom-nav button:active {
  transform: scale(0.92);
}

/* ============================================================
   LOADING OVERLAY (full screen)
   ============================================================ */

#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

#loading-overlay .loading-logo {
  font-size: 48px;
  animation: bounceIn 0.5s ease forwards;
}

#loading-overlay p {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

#loading-overlay img {
  width: 80px;
  height: 80px;
  border-radius: 10px;
}

/* ============================================================
   SECTION HEADERS (inside pages)
   ============================================================ */

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

.section-header h3 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
}

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