/* =========================================================
   SAMVIDHAN SARAL — LAYOUT CSS
   App shell, header, bottom nav, drawer, page structure.
   Mobile-first.
   ========================================================= */

/* --------------------------------------------------
   APP SHELL
   The outer frame for all public pages
-------------------------------------------------- */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport height for mobile */
  background: var(--color-bg);
  position: relative;
}

/* Main content area, pushed below header, above bottom nav */
.app-main {
  flex: 1;
  padding-top: var(--header-height);
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Page padding within main */
.page-content {
  padding-block: var(--space-5);
}

/* --------------------------------------------------
   SITE HEADER
   Fixed top, contains logo + nav trigger + search
-------------------------------------------------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-nav);
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding-inline: var(--space-4);
  gap: var(--space-3);
  box-shadow: var(--shadow-sm);
  padding-top: var(--safe-top);
}

.site-header__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}

.site-header__logo-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.site-header__logo-mark svg {
  width: 18px;
  height: 18px;
}

.site-header__brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.site-header__name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-header__tagline {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  line-height: 1.2;
  white-space: nowrap;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.header-btn {
  width: var(--touch-min);
  height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.header-btn:hover,
.header-btn:active {
  background: var(--color-bg);
  color: var(--color-primary);
}

.header-btn svg {
  width: 20px;
  height: 20px;
}

/* Desktop: show text nav, hide bottom nav */
@media (min-width: 768px) {
  .site-header {
    padding-inline: var(--space-6);
  }
}

/* --------------------------------------------------
   BOTTOM NAVIGATION
   Mobile: primary navigation. Hidden on desktop.
-------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-nav);
  height: var(--bottom-nav-height);
  padding-bottom: var(--safe-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: stretch;
  box-shadow: 0 -2px 12px rgba(28,43,74,0.08);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding-block: var(--space-2);
  color: var(--color-text-tertiary);
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.bottom-nav__item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.bottom-nav__label {
  font-size: 10px;
  font-weight: var(--weight-medium);
  letter-spacing: 0.01em;
  line-height: 1;
}

.bottom-nav__item.is-active {
  color: var(--color-accent);
}

.bottom-nav__item.is-active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 2px;
  background: var(--color-accent);
  border-radius: 0 0 var(--radius-full) var(--radius-full);
}

/* Hide bottom nav on desktop — use top nav instead */
@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }
  .app-main {
    padding-bottom: var(--safe-bottom, 0px);
  }
}

/* --------------------------------------------------
   DESKTOP TOP NAV LINKS (hidden on mobile)
-------------------------------------------------- */
.desktop-nav {
  display: none;
}

@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
  }

  .desktop-nav__link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast);
  }

  .desktop-nav__link:hover,
  .desktop-nav__link.is-active {
    background: var(--color-bg);
    color: var(--color-primary);
  }

  .desktop-nav__link.is-active {
    color: var(--color-accent);
  }
}

/* --------------------------------------------------
   OVERLAY (for drawers / modals)
-------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 26, 46, 0.55);
  z-index: var(--z-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-drawer) var(--ease-out);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* --------------------------------------------------
   DRAWER (side sheet, mobile search / menu)
-------------------------------------------------- */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(var(--drawer-width), 90vw);
  background: var(--color-surface);
  z-index: var(--z-drawer);
  transform: translateX(100%);
  transition: transform var(--duration-drawer) var(--ease-out);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

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

.drawer--left {
  right: auto;
  left: 0;
  transform: translateX(-100%);
}

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

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.drawer__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
}

.drawer__close {
  width: var(--touch-min);
  height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  transition: background var(--transition-fast);
}

.drawer__close:hover {
  background: var(--color-bg);
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-4);
}

/* --------------------------------------------------
   BOTTOM SHEET (modal-style sheet from bottom)
-------------------------------------------------- */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: var(--z-modal);
  transform: translateY(100%);
  transition: transform var(--duration-drawer) var(--ease-out);
  padding-bottom: calc(var(--space-6) + var(--safe-bottom));
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 32px rgba(28,43,74,0.16);
}

.bottom-sheet.is-open {
  transform: translateY(0);
}

.bottom-sheet__handle {
  width: 36px;
  height: 4px;
  background: var(--color-border-strong);
  border-radius: var(--radius-full);
  margin: var(--space-3) auto var(--space-2);
  flex-shrink: 0;
}

.bottom-sheet__header {
  padding: var(--space-3) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.bottom-sheet__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
}

.bottom-sheet__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-4) var(--space-5);
}

/* --------------------------------------------------
   SECTION HEADER (within page)
-------------------------------------------------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
}

.section-link {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-accent);
}

/* --------------------------------------------------
   PAGE HERO (top area of content pages)
-------------------------------------------------- */
.page-hero {
  background: linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  padding: var(--space-8) var(--space-4) var(--space-6);
  position: relative;
  overflow: hidden;
}

.page-hero::after {
  content: '';
  position: absolute;
  bottom: -30px;
  left: -10%;
  right: -10%;
  height: 60px;
  background: var(--color-bg);
  border-radius: 50%;
}

.page-hero__title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-display);
  color: var(--color-text-on-dark);
  margin-bottom: var(--space-2);
}

.page-hero__sub {
  font-size: var(--text-base);
  color: rgba(240,237,232,0.75);
  line-height: var(--leading-snug);
}

/* --------------------------------------------------
   EMPTY STATE
-------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-6);
  text-align: center;
  gap: var(--space-3);
}

.empty-state__icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xl);
  background: var(--color-bg-alt);
  color: var(--color-text-tertiary);
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
}

.empty-state__desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  max-width: 280px;
  line-height: var(--leading-normal);
}

/* --------------------------------------------------
   FOOTER (minimal, above bottom-nav)
-------------------------------------------------- */
.site-footer {
  display: none; /* hidden on mobile, bottom-nav takes over */
  background: var(--color-primary-dark);
  color: var(--color-text-on-dark);
  padding: var(--space-8) var(--space-4);
  text-align: center;
}

@media (min-width: 768px) {
  .site-footer {
    display: block;
  }
}

.site-footer__brand {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-2);
}

.site-footer__tagline {
  font-size: var(--text-sm);
  color: rgba(240,237,232,0.6);
  margin-bottom: var(--space-6);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.site-footer__links a {
  font-size: var(--text-sm);
  color: rgba(240,237,232,0.7);
  transition: color var(--transition-fast);
}

.site-footer__links a:hover {
  color: var(--color-accent-light);
}

.site-footer__copy {
  font-size: var(--text-xs);
  color: rgba(240,237,232,0.4);
}
