/* ============================================================
   PrairieOps — layout.css
   Sidebar, topbar, tab navigation, main content layout
   ============================================================ */

/* ── App Shell ──────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
  background: var(--bg-app);
}

/* ── Phase 4: bottom-nav slide transitions (Style 3) ─────────── */
/* During a nav transition both old + new view-panels stay visible  */
/* and are absolute-positioned so they overlap. Container clips.    */
#page-content.nav-transitioning {
  position: relative;
  overflow: hidden;
}
#page-content.nav-transitioning .view-panel {
  position: absolute;
  inset: 0;
}
@keyframes navOutShortLeft  { from { transform: translateX(0);    opacity: 1; } to { transform: translateX(-25%); opacity: 0; } }
@keyframes navOutShortRight { from { transform: translateX(0);    opacity: 1; } to { transform: translateX(25%);  opacity: 0; } }
@keyframes navInShortRight  { from { transform: translateX(25%);  opacity: 0; } to { transform: translateX(0);    opacity: 1; } }
@keyframes navInShortLeft   { from { transform: translateX(-25%); opacity: 0; } to { transform: translateX(0);    opacity: 1; } }

.view-panel.nav-leaving.go-left   { animation: navOutShortLeft  0.24s ease-out forwards; }
.view-panel.nav-leaving.go-right  { animation: navOutShortRight 0.24s ease-out forwards; }
.view-panel.nav-entering.go-left  { animation: navInShortRight  0.24s ease-out forwards; }
.view-panel.nav-entering.go-right { animation: navInShortLeft   0.24s ease-out forwards; }

/* Board tab switches reuse the same in-slide animation — only the         */
/* entering panel slides (old panel hides instantly underneath).           */
.board-panel.nav-entering.go-left  { animation: navInShortRight 0.24s ease-out; }
.board-panel.nav-entering.go-right { animation: navInShortLeft  0.24s ease-out; }

/* Hide dashboard until logged in */
#dashboard { display: none; }
#login-screen {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  touch-action: none; /* prevents iOS momentum scroll */
}

/* ── Sidebar ────────────────────────────────────────────────── */
#sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: -webkit-fill-available; /* iOS Safari: excludes browser chrome */
  position: sticky;
  top: 0;
  overflow: hidden; /* sidebar itself never scrolls — only .sidebar-nav does */
  z-index: var(--z-sticky);
  transition: width var(--transition-base), transform var(--transition-base);
}

.sidebar-logo {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo .logo-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 6px 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-section-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 12px 14px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 36px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.nav-item.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--brand);
}

.nav-item.locked {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-item .nav-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active .nav-icon { opacity: 1; }

.nav-item .nav-label { flex: 1; }

.nav-item .nav-badge {
  background: var(--brand);
  color: #111;
  font-size: 9px;
  font-weight: 800;
  padding: 0;
  border-radius: 50%;
  min-width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.nav-item .lock-icon {
  font-size: 10px;
  color: var(--text-muted);
}

.sidebar-user {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: var(--bg-surface);
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; overflow: hidden; }

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: capitalize;
}

#btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
#btn-logout:hover,
#btn-logout:active {
  border-color: var(--text-muted);
  color: var(--text-secondary);
}

/* ── Main Content Area ──────────────────────────────────────── */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: hidden;
}

/* ── Topbar ─────────────────────────────────────────────────── */
#topbar {
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  flex-shrink: 0;
}

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

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

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

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

/* Mobile menu toggle */
#btn-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
}
#btn-menu-toggle:hover { color: var(--text-primary); }

/* Notification bell */
.notif-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}
.notif-btn:hover { color: var(--text-primary); }

.notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  width: 16px; height: 16px;
  background: var(--urgent);
  color: #fff;
  font-size: 9px;
  font-weight: var(--weight-bold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-surface);
}

/* ── Page Content ───────────────────────────────────────────── */
#page-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ── Board Tabs — flat underline style ──────────────────────── */
.board-tabs {
  display: flex;
  gap: 0;
  justify-content: center;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0;
  margin-bottom: 16px;
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.board-tabs::-webkit-scrollbar { display: none; }

.board-tab {
  flex: 1 1 0;
  max-width: 200px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  text-align: center;
  white-space: nowrap;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.01em;
}

@media (max-width: 639px) {
  .board-tab { font-size: 13px; padding: 10px 14px; }
}

.board-tab:hover { color: var(--text-secondary); }

.board-tab.active {
  color: var(--text-primary);
  font-weight: 600;
}
/* border-bottom colors removed — theme-v2 indicator handles active state */

/* ── Board Panel ────────────────────────────────────────────── */
.board-panel { display: none; }
/* Phase 4: dropped the prior `animation: fadeIn` on .active.            */
/* The directional slide (.nav-entering.go-left/right) handles entry,    */
/* and the lingering fadeIn was retriggering after the slide finished —  */
/* visible as a "flash / shimmer" mid-transition.                         */
.board-panel.active { display: block; }

/* ── Section headers ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.section-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ── Responsive: mobile sidebar ─────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    height: 100%; /* use bottom:0 to define height — avoids 100vh iOS chrome issue */
    transform: translateX(-100%);
    z-index: var(--z-overlay);
    width: 280px;
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  #btn-menu-toggle { display: flex; }

  #page-content { padding: 12px; }

  .board-tabs { border-radius: 0; }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: calc(var(--z-overlay) - 1);
  }
  .sidebar-overlay.active { display: block; }
}

@media (min-width: 769px) {
  .sidebar-overlay { display: none !important; }
}
