/* ============================================================
   BAN YARO — Layout
   App Shell: Mobile Bottom-Nav + Desktop Sidebar
   Mobile-first mit einer einzigen Media Query für Desktop
   ============================================================ */

/* ------------------------------------------------------------
   1. APP SHELL
   ------------------------------------------------------------ */
#app {
  display:    flex;
  flex-direction: column;
  min-height: 100dvh; /* dvh: berücksichtigt mobile Browser-Chrome */
}

/* Content-Bereich: füllt den Raum zwischen Header und Bottom-Nav */
#page-content {
  flex:         1;
  overflow-y:   auto;
  overflow-x:   hidden;
  padding-bottom: calc(var(--nav-bottom-height) + var(--safe-bottom));
}

/* Desktop: Sidebar-Layout */
@media (min-width: 768px) {
  #app {
    flex-direction: row;
  }
  #page-content {
    padding-bottom: 0;
    padding-left:   var(--nav-sidebar-width);
  }
}

/* ------------------------------------------------------------
   2. HEADER (Mobile)
   ------------------------------------------------------------ */
#app-header {
  position:    sticky;
  top:         0;
  z-index:     100;
  height:      calc(var(--header-height) + var(--safe-top));
  padding-top: var(--safe-top);
  background:  var(--c-surface);
  border-bottom: 1px solid var(--c-border-light);
  display:     flex;
  align-items: center;
  padding-left:  var(--space-4);
  padding-right: var(--space-4);
  gap:           var(--space-3);
  box-shadow:    var(--shadow-xs);
}

.header-title {
  font-size:   var(--text-lg);
  font-weight: var(--weight-bold);
  color:       var(--c-text);
  flex:        1;
}

.header-back {
  display:         flex;
  align-items:     center;
  justify-content: center;
  width:           40px;
  height:          40px;
  border-radius:   var(--radius-md);
  color:           var(--c-text-secondary);
  cursor:          pointer;
  transition:      background var(--transition-fast);
  font-size:       20px;
  flex-shrink:     0;
}
.header-back:hover { background: var(--c-surface-2); }

/* Auf Desktop keinen mobilen Header zeigen */
@media (min-width: 768px) {
  #app-header { display: none; }
}

/* ------------------------------------------------------------
   3. BOTTOM NAVIGATION (Mobile)
   ------------------------------------------------------------ */
#bottom-nav {
  position:    fixed;
  bottom:      0;
  left:        0;
  right:       0;
  z-index:     300;
  height:      calc(var(--nav-bottom-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background:  var(--c-surface);
  border-top:  1px solid var(--c-border-light);
  display:     flex;
  align-items: stretch;
  box-shadow:  0 -2px 12px rgba(42, 31, 20, 0.08);
}

.nav-item {
  flex:            1;
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  justify-content: center;
  gap:             3px;
  cursor:          pointer;
  color:           var(--c-text-muted);
  transition:      color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  touch-action:    manipulation;
  position:        relative;
  padding:         var(--space-2) var(--space-1);
}

.nav-item:hover  { color: var(--c-text-secondary); }
.nav-item.active { color: var(--c-primary); }

/* Aktiv-Indikator oben */
.nav-item.active::before {
  content:       '';
  position:      absolute;
  top:           0;
  left:          50%;
  transform:     translateX(-50%);
  width:         32px;
  height:        3px;
  background:    var(--c-primary);
  border-radius: 0 0 var(--radius-full) var(--radius-full);
}

.nav-item-icon {
  font-size:  22px;
  line-height: 1;
  position:   relative;
}

/* Ungelesen-Badge auf Nav-Icon */
.nav-badge {
  position:      absolute;
  top:           -4px;
  right:         -6px;
  background:    var(--c-danger);
  color:         #fff;
  font-size:     9px;
  font-weight:   var(--weight-bold);
  min-width:     16px;
  height:        16px;
  border-radius: var(--radius-full);
  display:       flex;
  align-items:   center;
  justify-content: center;
  padding:       0 3px;
  border:        2px solid var(--c-surface);
}

.nav-item-label {
  font-size:   9px;
  font-weight: var(--weight-semibold);
  line-height: 1;
}

/* Mittlerer + Button: kein Label, größer */
.nav-item-center .nav-item-icon {
  width:         50px;
  height:        50px;
  background:    var(--c-primary);
  color:         #fff;
  border-radius: var(--radius-full);
  font-size:     26px;
  display:       flex;
  align-items:   center;
  justify-content: center;
  box-shadow:    var(--shadow-md);
  transition:    transform var(--transition-fast),
                 box-shadow var(--transition-fast);
  margin-top:    -12px; /* ragt über die Nav hinaus */
}
.nav-item-center:active .nav-item-icon {
  transform:  scale(0.93);
  box-shadow: var(--shadow-sm);
}
.nav-item-center.active::before { display: none; }
.nav-item-center .nav-item-label { display: none; }

/* Desktop: Bottom Nav ausblenden */
@media (min-width: 768px) {
  #bottom-nav { display: none; }
}

/* ------------------------------------------------------------
   4. SIDEBAR NAVIGATION (Desktop)
   ------------------------------------------------------------ */
#sidebar {
  display:        none;
  position:       fixed;
  top:            0;
  left:           0;
  bottom:         0;
  width:          var(--nav-sidebar-width);
  z-index:        300;
  background:     var(--c-surface);
  border-right:   1px solid var(--c-border-light);
  flex-direction: column;
  overflow-y:     auto;
  box-shadow:     var(--shadow-sm);
}

@media (min-width: 768px) {
  #sidebar { display: flex; }
}

.sidebar-logo {
  padding:      var(--space-6) var(--space-5);
  display:      flex;
  align-items:  center;
  gap:          var(--space-3);
  border-bottom: 1px solid var(--c-border-light);
  flex-shrink:  0;
}
.sidebar-logo-img {
  width:         36px;
  height:        36px;
  border-radius: var(--radius-full);
  object-fit:    cover;
}
.sidebar-logo-text {
  font-size:   var(--text-lg);
  font-weight: var(--weight-bold);
  color:       var(--c-text);
}

.sidebar-add {
  padding:    var(--space-4) var(--space-4) var(--space-2);
  flex-shrink: 0;
}

.sidebar-nav {
  flex:       1;
  padding:    var(--space-2) var(--space-2) var(--space-4);
  display:    flex;
  flex-direction: column;
  gap:        var(--space-1);
}

.sidebar-section-label {
  font-size:      var(--text-xs);
  font-weight:    var(--weight-semibold);
  color:          var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding:        var(--space-3) var(--space-3) var(--space-1);
  margin-top:     var(--space-2);
}

.sidebar-item {
  display:       flex;
  align-items:   center;
  gap:           var(--space-3);
  padding:       var(--space-3);
  border-radius: var(--radius-md);
  cursor:        pointer;
  color:         var(--c-text-secondary);
  font-size:     var(--text-sm);
  font-weight:   var(--weight-medium);
  transition:    background var(--transition-fast),
                 color      var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.sidebar-item:hover {
  background: var(--c-bg);
  color:      var(--c-text);
}
.sidebar-item.active {
  background: var(--c-primary-subtle);
  color:      var(--c-primary-dark);
  font-weight: var(--weight-semibold);
}
.sidebar-item-icon {
  font-size:   18px;
  width:       24px;
  text-align:  center;
  flex-shrink: 0;
}
.sidebar-item-badge {
  margin-left:   auto;
  background:    var(--c-danger);
  color:         #fff;
  font-size:     var(--text-xs);
  font-weight:   var(--weight-bold);
  min-width:     20px;
  height:        20px;
  border-radius: var(--radius-full);
  display:       flex;
  align-items:   center;
  justify-content: center;
  padding:       0 var(--space-1);
}

.sidebar-footer {
  padding:    var(--space-4) var(--space-2);
  border-top: 1px solid var(--c-border-light);
  flex-shrink: 0;
}

/* ------------------------------------------------------------
   5. PAGE WRAPPER (inneres Layout der Seiten)
   ------------------------------------------------------------ */
.page {
  display:        none;
  flex-direction: column;
  min-height:     100%;
}
.page.active { display: flex; }

/* Scrollbarer Seiteninhalt */
.page-body {
  flex:       1;
  padding:    var(--space-4);
  display:    flex;
  flex-direction: column;
  gap:        var(--space-4);
}

/* Volle Breite mit seitlichem Limit für Desktop */
.page-container {
  width:      100%;
  max-width:  680px;
  margin:     0 auto;
}

/* Wide-Layout für Karte und ähnliches */
.page-container-wide {
  width:     100%;
  max-width: 1040px;
  margin:    0 auto;
}

/* Karte nimmt vollen Platz ein */
.page-fullscreen {
  position: absolute;
  inset:    0;
  padding:  0;
}

/* ------------------------------------------------------------
   6. PULL-TO-REFRESH INDIKATOR
   ------------------------------------------------------------ */
.ptr-indicator {
  display:         flex;
  justify-content: center;
  align-items:     center;
  height:          48px;
  color:           var(--c-text-muted);
  font-size:       var(--text-sm);
  gap:             var(--space-2);
  overflow:        hidden;
  max-height:      0;
  transition:      max-height var(--transition-normal);
}
.ptr-indicator.visible { max-height: 48px; }

/* ------------------------------------------------------------
   7. RESPONSIVE GRID
   ------------------------------------------------------------ */
.grid-2 {
  display:               grid;
  grid-template-columns: 1fr 1fr;
  gap:                   var(--space-3);
}
.grid-3 {
  display:               grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap:                   var(--space-3);
}

@media (max-width: 400px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
