/* ==========================================================================
   MINEGUARD AI — APPLICATION SHELL & RESPONSIVE LAYOUT
   Grounded in Apple Human Interface Guidelines (macOS & iOS Multi-Screen)
   Liquid Glass Navigation • Grouped Content Layer • Safe Areas • Touch Targets
   ========================================================================== */

/* Modular View Stylesheets */
@import url('views/overview.css');
@import url('views/flood.css');
@import url('views/heat.css');
@import url('views/forecast.css');
@import url('views/map.css');
@import url('views/alerts.css');
@import url('views/recommendations.css');
@import url('views/esg.css');

/* ─── 1. ROOT APP WRAPPER ─────────────────────────────────────────────────── */
#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--system-canvas);
  color: var(--label-primary);
}

/* ─── 2. TOP COMMAND HEADER (Apple Liquid Glass Functional Layer) ────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  background: var(--liquid-glass-bg);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border-bottom: 0.5px solid var(--liquid-glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-logo-img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  object-fit: cover;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #ffffff;
}

.brand-tagline {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--label-secondary);
  display: none;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* Concession Selector (Apple Pop-up Button Style) */
.site-selector {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 0.5px solid var(--separator);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  max-width: 150px;
  height: 34px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.site-selector:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.12);
}

.threat-indicator-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
}

/* ─── 3. MAIN WORKSPACE BODY ──────────────────────────────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Sidebar Navigation (Hidden on Mobile, macOS Sidebar on Desktop) */
.app-sidebar {
  display: none;
}

/* Main Dynamic Content Outlet */
.app-main {
  flex: 1;
  padding: 1rem;
  padding-bottom: 84px; /* Clearance for iOS bottom tab bar */
  overflow-y: auto;
  max-width: 100%;
}

/* ─── 4. MOBILE BOTTOM TAB BAR (iOS Human Interface Guidelines) ───────────── */
.mobile-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(22, 22, 24, 0.88);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border-top: 0.5px solid var(--liquid-glass-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  padding: 0 0.5rem;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-item-mobile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--label-secondary);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 500;
  min-width: 48px;
  min-height: 44px; /* Apple minimum touch target 44pt */
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.nav-item-mobile svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: transform var(--transition-fast);
}

.nav-item-mobile.active {
  color: var(--accent);
}

.nav-item-mobile.active svg {
  color: var(--accent);
}

/* ─── 5. TABLET ADAPTATIONS (min-width: 640px) ────────────────────────────── */
@media (min-width: 640px) {
  .app-header {
    height: 60px;
    padding: 0 1.5rem;
  }
  
  .brand-tagline {
    display: block;
  }

  .site-selector {
    max-width: 220px;
    font-size: 0.85rem;
  }

  .app-main {
    padding: 1.5rem;
    padding-bottom: 88px;
  }
}

/* ─── 6. DESKTOP COCKPIT & SIDEBAR (min-width: 1024px) ───────────────────── */
@media (min-width: 1024px) {
  .mobile-nav-bar {
    display: none;
  }

  .app-sidebar {
    display: flex;
    flex-direction: column;
    width: 240px;
    background: #161618;
    border-right: 0.5px solid var(--separator);
    padding: 1.25rem 0.65rem;
    gap: 0.25rem;
    flex-shrink: 0;
  }

  .sidebar-section-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--label-tertiary);
    padding: 0.65rem 0.75rem 0.25rem;
  }

  .nav-item-desktop {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--label-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.88rem;
    transition: background var(--transition-fast), color var(--transition-fast);
  }

  .nav-item-desktop svg {
    width: 18px;
    height: 18px;
    color: var(--label-secondary);
    transition: color var(--transition-fast);
  }

  .nav-item-desktop:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
  }

  .nav-item-desktop:hover svg {
    color: #ffffff;
  }

  .nav-item-desktop.active {
    background: var(--accent-tint);
    color: var(--accent);
    font-weight: 600;
  }

  .nav-item-desktop.active svg {
    color: var(--accent);
  }

  .app-main {
    padding: 2rem;
    padding-bottom: 2rem;
  }
}

/* ─── 7. MODAL SHEET SYSTEM (Apple Sheets & Dialogs) ──────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--liquid-glass-dim);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #242426;
  border: 0.5px solid var(--separator);
  border-radius: var(--radius-xl);
  max-width: 580px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-sheet);
  transform: scale(0.96) translateY(12px);
  transition: transform var(--transition-smooth);
}

.modal-backdrop.open .modal-content {
  transform: scale(1) translateY(0);
}

/* Grabber for mobile sheet presentation */
.sheet-grabber {
  width: 36px;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2.5px;
  margin: 0.25rem auto 1rem;
  display: block;
}

@media (min-width: 640px) {
  .sheet-grabber {
    display: none;
  }
}
