/* ==========================================================================
   Aarambh Early Years - Responsive Application Shell & Navigation
   Pre-Primary School Management UI Foundation
   ========================================================================== */

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

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  background-color: var(--color-canvas);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: var(--line-height-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ==========================================================================
   1. DEVICE SIMULATOR TOOLBAR (Top fixed switcher)
   ========================================================================== */
.viewport-simulator-bar {
  background-color: #1E293B;
  color: #F8FAFC;
  padding: var(--space-2) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  font-family: var(--font-family-base);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.simulator-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--font-weight-bold);
  color: #F8FAFC;
}

.simulator-title-pill {
  background-color: var(--color-primary-500);
  color: white;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--font-weight-extrabold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.simulator-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.simulator-btn {
  background-color: rgba(255, 255, 255, 0.1);
  color: #CBD5E1;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--duration-fast);
}

.simulator-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.simulator-btn.is-active {
  background-color: var(--color-primary-500);
  color: white;
  border-color: var(--color-primary-500);
}

/* Simulator Frame Wrap */
.simulator-frame-wrapper {
  transition: all var(--duration-normal) var(--ease-spring);
  margin: 0 auto;
  min-height: calc(100vh - 44px);
  background-color: var(--color-canvas);
}

.simulator-frame-wrapper.mode-tablet {
  max-width: 768px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  margin: 20px auto;
  border-radius: var(--radius-2xl);
  overflow: hidden;
}

.simulator-frame-wrapper.mode-mobile {
  max-width: 412px;
  box-shadow: 0 0 45px rgba(0, 0, 0, 0.25);
  border: 4px solid #334155;
  margin: 24px auto;
  border-radius: 40px;
  overflow: hidden;
}


/* ==========================================================================
   2. APP SHELL LAYOUT (Desktop, Tablet, Mobile)
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  background-color: var(--color-canvas);
  position: relative;
}

/* ==========================================================================
   3. DESKTOP SIDEBAR NAVIGATION
   ========================================================================== */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: var(--z-sticky);
  transition: width var(--duration-normal) var(--ease-smooth);
  flex-shrink: 0;
}

.sidebar-header {
  padding: var(--space-5) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--color-border-subtle);
}

.school-logo-crest {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #FF8A65 0%, #E76F51 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(231, 111, 81, 0.35);
  flex-shrink: 0;
}

.school-info-wrap {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.school-name {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-extrabold);
  color: var(--color-text-primary);
  line-height: var(--line-height-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.school-tagline {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: var(--font-weight-semibold);
  margin-top: 2px;
}

.academic-session-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  background-color: var(--color-pastel-amber-bg);
  color: var(--color-pastel-amber-text);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-top: 4px;
  width: fit-content;
}

/* Navigation Items in Sidebar */
.sidebar-nav {
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.nav-section-title {
  font-size: 11px;
  font-weight: var(--font-weight-extrabold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-subtle);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  transition: all var(--duration-fast) var(--ease-smooth);
  cursor: pointer;
  border: 1px solid transparent;
  min-height: var(--touch-target-md);
}

.nav-item-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav-item:hover {
  background-color: #FFF6F3;
  color: var(--color-primary-600);
}

.nav-item.is-active {
  background-color: var(--color-primary-50);
  color: var(--color-primary-600);
  border-color: rgba(231, 111, 81, 0.2);
}

.nav-item.is-active .nav-icon {
  color: var(--color-primary-500);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--color-border-subtle);
  background-color: #FCFBF9;
}

.user-profile-widget {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background-color var(--duration-fast);
}

.user-profile-widget:hover {
  background-color: var(--color-canvas);
}

.user-profile-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar-pill {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--color-pastel-purple-bg);
  color: var(--color-pastel-purple-text);
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  border: 1.5px solid var(--color-pastel-purple-border);
}

.user-name-role {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  line-height: var(--line-height-snug);
}

.user-role {
  font-size: 11px;
  color: var(--color-text-muted);
}


/* ==========================================================================
   4. MAIN VIEWPORT & TOP HEADER
   ========================================================================== */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

.app-header {
  height: var(--header-height);
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: var(--z-header);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.mobile-menu-trigger {
  display: none;
}

.header-school-mobile {
  display: none;
}

.header-page-title-wrap {
  display: flex;
  flex-direction: column;
}

.header-page-title {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-extrabold);
  color: var(--color-text-primary);
  line-height: var(--line-height-tight);
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-search {
  width: 240px;
}

.notification-btn {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--color-primary-500);
  border: 2px solid var(--color-surface);
}


/* ==========================================================================
   5. CONTENT CANVAS & RESPONSIVE GRIDS
   ========================================================================== */
.app-content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* Stats / Metrics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

/* Two-column Content Grid */
.dashboard-content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

/* Component Library Grid */
.components-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}


/* ==========================================================================
   6. MOBILE BOTTOM NAVIGATION (Ergonomic Thumb-Target Navigation)
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--color-border);
  z-index: var(--z-bottom-nav);
  padding: 0 var(--space-2);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 16px rgba(30, 41, 59, 0.05);
}

.bottom-nav-items {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 100%;
  align-items: center;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  min-height: var(--touch-target-md);
  cursor: pointer;
  transition: all var(--duration-fast);
  border-radius: var(--radius-md);
  padding: 4px 0;
}

.bottom-nav-item:active {
  transform: scale(0.92);
}

.bottom-nav-item.is-active {
  color: var(--color-primary-600);
}

.bottom-nav-item.is-active .bottom-nav-icon-wrap {
  background-color: var(--color-primary-50);
  color: var(--color-primary-600);
  transform: translateY(-2px);
}

.bottom-nav-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
}


/* ==========================================================================
   7. OFF-CANVAS MOBILE DRAWER
   ========================================================================== */
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: var(--z-drawer);
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 290px;
  background-color: var(--color-surface);
  box-shadow: var(--shadow-xl);
  z-index: calc(var(--z-drawer) + 1);
  transform: translateX(-100%);
  transition: transform var(--duration-normal) var(--ease-spring);
  display: flex;
  flex-direction: column;
}

.mobile-drawer.is-open {
  transform: translateX(0);
}

.mobile-drawer-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}


/* ==========================================================================
   8. RESPONSIVE MEDIA QUERIES (Desktop, Tablet, Mobile)
   ========================================================================== */

/* Tablet (768px - 1023px) */
@media (max-width: 1023px) {
  .app-sidebar {
    width: var(--sidebar-collapsed);
  }

  .school-info-wrap,
  .sidebar-nav .nav-item-text,
  .sidebar-nav .badge,
  .nav-section-title,
  .user-name-role,
  .academic-session-pill {
    display: none;
  }

  .sidebar-header {
    justify-content: center;
    padding: var(--space-4) var(--space-2);
  }

  .nav-item {
    justify-content: center;
    padding: var(--space-3);
  }

  .user-profile-widget {
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-content-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
  }

  .viewport-simulator-bar {
    display: none;
  }

  .app-sidebar {
    display: none;
  }

  .mobile-menu-trigger {
    display: inline-flex;
  }

  .header-school-mobile {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .header-page-title-wrap {
    display: none;
  }

  .header-search {
    display: none;
  }

  .app-header {
    padding: 0 var(--space-4);
  }

  .app-content {
    padding: var(--space-4);
    /* Space for mobile bottom bar */
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-6));
  }

  .mobile-bottom-nav {
    display: block;
    width: 100%;
    left: 0;
    right: 0;
  }

  .bottom-nav-items {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    width: 100%;
  }

  .bottom-nav-item {
    font-size: 10px;
    padding: 2px 0;
    min-width: 0;
  }

  .bottom-nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .dashboard-content-grid {
    grid-template-columns: 1fr;
  }

  .components-grid {
    grid-template-columns: 1fr;
  }
}

