/**
 * client/assets/css/layout.css
 *
 * Structural shell for the app frame: sidebar, header, bottom nav.
 * Phase 3 ships the markup contract and positioning only — real nav
 * items are populated per-module starting Phase 4 without altering
 * this shell's markup contract (rule: later phases are additive).
 */

.ant-app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--color-bg-app);
}

.ant-app-shell__content-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ant-app-shell__content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max-width);
  padding: var(--content-pad);
  padding-bottom: var(--space-6);
}

/* ----------------------------------------------------------------
 * Sidebar (Admin Panel, desktop/tablet — UI/UX §2.4)
 * Sticky in place, but sized by its own content (min-height still
 * fills the viewport on short pages) instead of being a fixed 100vh
 * box with an independently scrolling nav list. One scroll surface
 * for the whole frame: a wheel gesture over the sidebar scrolls the
 * document, so ant-app-shell__content lifts with it. align-self keeps
 * the flex child from stretching to the full page height, which would
 * leave the sticky column no room to move.
 * ---------------------------------------------------------------- */
.ant-sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  height: auto;
  align-self: flex-start;
  width: var(--sidebar-width, 256px);
  flex-shrink: 0;
  background: var(--gradient-sidebar);
  color: var(--color-neutral-white);
  display: flex;
  flex-direction: column;
  padding: var(--space-5) var(--space-3);
  gap: var(--space-3);
  z-index: 50;
  overflow: visible;
}
.ant-sidebar.is-collapsed {
  width: 78px;
  padding-left: var(--space-2);
  padding-right: var(--space-2);
}
/* Collapsed state (desktop toggle, assets/js/nav.js) previously only
   shrank the column width without hiding any labels — the brand name
   and every nav-item's text kept rendering inside a 78px column,
   wrapping/overflowing and breaking icon alignment. Mirror the same
   label-hiding + centering the tablet breakpoint below already does
   for its own narrow state. */
.ant-sidebar.is-collapsed .ant-sidebar__brand {
  justify-content: center;
  gap: 0;
  padding-left: 0;
  padding-right: 0;
}
.ant-sidebar.is-collapsed .ant-sidebar__brand img,
.ant-sidebar.is-collapsed .ant-sidebar__brand > span {
  display: none;
}
.ant-sidebar.is-collapsed .ant-sidebar__brand .ant-btn {
  margin-left: 0 !important;
}
.ant-sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-2) var(--space-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 44px;
}
.ant-sidebar__brand img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
}
.ant-sidebar__brand > span {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.ant-sidebar__brand .ant-btn {
  color: rgba(255, 255, 255, 0.7);
}
.ant-sidebar__brand .ant-btn:hover {
  color: var(--color-neutral-white);
  background: rgba(255, 255, 255, 0.1);
}
.ant-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 0 0 auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: var(--space-3);
}
.ant-sidebar__nav::-webkit-scrollbar {
  display: none;
  width: 0;
}
.ant-sidebar__nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px 14px;
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease;
}
.ant-sidebar__nav-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex: 0 0 auto;
  opacity: 0.9;
}
.ant-sidebar__nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-neutral-white);
}
.ant-sidebar__nav-item.is-active {
  background: linear-gradient(135deg, rgba(46, 82, 184, 0.95), rgba(30, 58, 138, 0.85));
  color: var(--color-neutral-white);
  box-shadow: 0 2px 10px rgba(5, 11, 31, 0.35);
}
.ant-sidebar__nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  background: var(--color-primary-300);
}
.ant-sidebar.is-collapsed .ant-sidebar__nav-item {
  padding-left: 10px;
  padding-right: 10px;
  justify-content: center;
}
.ant-sidebar.is-collapsed .ant-sidebar__nav-item i { opacity: 1; }
.ant-sidebar.is-collapsed .ant-sidebar__nav-item span { display: none; }

/* Hover tooltip for collapsed nav items — the label text is hidden
   above, so the item's aria-label (set in components/layout/
   sidebar.php, also read by screen readers for the same reason) is
   surfaced visually on hover/focus instead. */
.ant-sidebar.is-collapsed .ant-sidebar__nav-item {
  position: relative;
}
.ant-sidebar.is-collapsed .ant-sidebar__nav-item::after {
  content: attr(aria-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: var(--color-neutral-900, #111827);
  color: var(--color-neutral-white, #fff);
  padding: 6px 10px;
  border-radius: var(--radius-md, 6px);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 60;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.ant-sidebar.is-collapsed .ant-sidebar__nav-item:hover::after,
.ant-sidebar.is-collapsed .ant-sidebar__nav-item:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

@media (max-width: 1023px) {
  .ant-sidebar:not(.is-force-open) {
    width: 78px;
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }
  .ant-sidebar:not(.is-force-open) .ant-sidebar__brand > span,
  .ant-sidebar:not(.is-force-open) .ant-sidebar__nav-item span,
  .ant-sidebar:not(.is-force-open) .ant-sidebar__brand .ant-btn { display: none; }
  .ant-sidebar:not(.is-force-open) .ant-sidebar__nav-item {
    padding-left: 10px;
    padding-right: 10px;
    justify-content: center;
  }
}
@media (max-width: 639px) {
  .ant-sidebar { display: none; }
}

/* ----------------------------------------------------------------
 * Header (top bar — shows current page title + user menu)
 * Sticky so search + primary actions stay reachable while lists scroll.
 * ---------------------------------------------------------------- */
.ant-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 14px var(--content-pad);
  background: color-mix(in srgb, var(--color-bg-surface) 86%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border-soft);
}
.ant-header__title {
  font-family: var(--font-heading);
  font-size: var(--font-size-h4);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ant-header__actions { display: flex; align-items: center; gap: var(--space-2); }

/* ----------------------------------------------------------------
 * Bottom nav (mobile — Admin Panel + Driver App, UI/UX §2.4)
 * ---------------------------------------------------------------- */
.ant-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: color-mix(in srgb, var(--color-bg-surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--color-border-soft);
  align-items: center;
  justify-content: space-around;
  z-index: 900;
  padding: 0 var(--space-2);
}
@media (max-width: 639px) {
  .ant-bottom-nav { display: flex; }
  .ant-app-shell__content { padding-bottom: calc(64px + var(--space-6)); }
}

/* Delta — the Driver App has no desktop sidebar equivalent (its pages
   never include sidebar.php, only driver_header.php + this bottom
   nav), so hiding it above 639px left a driver on a tablet/desktop
   browser with no navigation at all. The Admin Panel variant is
   unaffected — it keeps the sidebar as its desktop navigation and
   this bottom nav stays mobile-only for it. ant-driver-shell already
   carries an unconditional padding-bottom that clears a fixed bottom
   nav at any width, so no layout shift here. */
.ant-bottom-nav--driver { display: flex; }
.ant-bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  flex: 1;
  padding: 4px 0;
  border-radius: var(--radius-md);
  max-width: 96px;
}
.ant-bottom-nav__item i { font-size: 20px; transition: transform 0.15s ease; }
.ant-bottom-nav__item:active i { transform: scale(0.92); }
.ant-bottom-nav__item.is-active {
  color: var(--color-primary-600);
  font-weight: 600;
}
.ant-bottom-nav__item--fab {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--color-primary-600), var(--color-primary-500));
  color: var(--color-neutral-white);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -28px;
  box-shadow: 0 6px 16px rgba(30, 58, 138, 0.4);
  flex: 0 0 auto;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ant-bottom-nav__item--fab:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(30, 58, 138, 0.45); cursor: pointer; }

/* "More" slide-up sheet */
.ant-more-sheet {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 950;
}
.ant-more-sheet.is-open { display: block; }
.ant-more-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 18, 40, 0.5);
  backdrop-filter: blur(2px);
}
.ant-more-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--color-bg-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-5);
  box-shadow: 0 -8px 32px rgba(14, 24, 48, 0.16);
  animation: ant-sheet-up 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes ant-sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.ant-more-sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-border);
  margin: 0 auto var(--space-4);
}
.ant-more-sheet__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  color: var(--color-text-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--color-neutral-100);
}
.ant-more-sheet__item i { font-size: var(--icon-size-nav); color: var(--color-primary-500); width: var(--icon-size-nav); }

/* ----------------------------------------------------------------
 * Wide-screen behavior (UI/UX §2.5): extra space goes to margins,
 * or a secondary right-rail slot pages can opt into.
 * ---------------------------------------------------------------- */
.ant-right-rail {
  display: none;
  width: 320px;
  flex-shrink: 0;
  border-left: 1px solid var(--color-border);
  padding: var(--space-5);
}
@media (min-width: 1440px) {
  .ant-right-rail.is-enabled { display: block; }
}
