/* ==========================================================================
   TovTalk Adaptive Layout
   Navigation Rail (desktop 768+) / Bottom Nav (mobile <768)
   Uses CSS custom properties from tokens.css
   ========================================================================== */

/* --- Adaptive Shell ----------------------------------------------------- */
.adaptive-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-primary);
}

/* --- Navigation Rail ---------------------------------------------------- */
.nav-rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rail-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) 0;
  z-index: 100;
}

/* RTL: flip rail to right side */
[dir="rtl"] .nav-rail {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border);
}

/* --- Rail Items --------------------------------------------------------- */
.rail-logo {
  padding-top: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.rail-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.rail-items-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.rail-item {
  width: var(--min-touch);
  height: var(--min-touch);
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
  position: relative;
  color: var(--text-secondary);
  background: none;
  border: none;
  padding: 0;
  font-size: var(--icon-md);
}

.rail-item:hover {
  background: var(--overlay-light);
  color: var(--text-primary);
}

.rail-item-active {
  color: var(--text-primary);
}

.rail-divider {
  width: 32px;
  height: 1px;
  background: var(--border);
  margin: var(--space-xs) 0;
}

.rail-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--error);
  color: white;
  font-size: var(--text-label-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.rail-tooltip {
  display: none;
}

/* --- Bottom Navigation -------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--space-sm);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Bottom Nav Items --------------------------------------------------- */
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  cursor: pointer;
  position: relative;
  color: var(--text-secondary);
  transition: color var(--duration-fast) var(--ease-standard);
  background: none;
  border: none;
  padding: 0;
  font-size: var(--icon-md);
}

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

.bottom-nav-upload {
  width: var(--video-action-btn);
  height: var(--video-action-btn);
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  border-radius: var(--radius-full);
  color: white;
  display: grid;
  place-items: center;
}

/* --- Content Area ------------------------------------------------------- */
.adaptive-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--screen-padding);
}

/* --- Content Containers ------------------------------------------------- */
/* Narrow centered content for forms/settings (use inside screens) */
.content-centered {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: var(--screen-padding);
}

/* Narrower for settings-type screens */
.content-narrow {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.content-full {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 0 !important;
  overflow: hidden;
}

/* --- Split Views (wide desktop) ----------------------------------------- */
.split-home {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: 100%;
}

.split-post {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: 100%;
}

.split-chat {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100%;
}

/* ==========================================================================
   Breakpoints
   ========================================================================== */

/* --- Mobile: bottom nav, no rail --------------------------------------- */
@media (max-width: 767px) {
  .nav-rail {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  .adaptive-content {
    margin-left: 0;
    padding-bottom: var(--bottom-nav-height);
  }

  /* No split views on mobile */
  .split-home,
  .split-post,
  .split-chat {
    display: block;
  }
}

/* --- Desktop: rail, no bottom nav -------------------------------------- */
@media (min-width: 768px) {
  .nav-rail {
    display: flex;
  }

  .bottom-nav {
    display: none;
  }

  .adaptive-content {
    margin-left: var(--rail-width);
  }

  /* RTL: flip content margin */
  [dir="rtl"] .adaptive-content {
    margin-left: 0;
    margin-right: var(--rail-width);
  }

  /* Chat split available at tablet+ */
  .split-chat {
    display: grid;
  }
}

/* --- Wide desktop: split views for home/post --------------------------- */
@media (min-width: 1200px) {
  .split-home,
  .split-post {
    display: grid;
  }
}
