/* ============================================================
   Sidebar + Category Tree Styles (Phase 4)
   Phase 6.5: Brand color theming aligned with Flutter UX/UI
   ============================================================ */

/* --- Navbar brand color (Phase 6.5) --- */
.o-navbar-brand {
  background-color: var(--kon-brand-color, #cf0015);
}

/* --- Layout wrapper --- */
.o-layout {
  min-height: 100vh;
}
@media (min-width: 768px) {
  .o-layout {
    min-height: 100vh;
  }
}

.o-layout-main {
  flex-grow: 1;
  min-width: 0; /* prevent flex child overflow */
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

/* --- Desktop sidebar (>= 1200px): persistent mini sidebar --- */
@media (min-width: 1200px) {
  .o-sidebar {
    width: 60px;
    min-width: 60px;
    overflow: hidden;
    transition: width 0.2s ease, min-width 0.2s ease;
    border-right: 1px solid var(--bs-border-color, #dee2e6);
    background: #fff;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 0.5rem 0;
  }
  .o-sidebar:hover,
  .o-sidebar.o-sidebar--pinned {
    width: 240px;
    min-width: 240px;
  }

  /* --- Icon rail: visible in mini mode only --- */
  .o-sidebar .o-sidebar-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0;
    gap: 1.25rem;
  }
  .o-sidebar:hover .o-sidebar-rail,
  .o-sidebar.o-sidebar--pinned .o-sidebar-rail {
    display: none;
  }

  /* Rail icons */
  .o-sidebar-rail-icon {
    color: var(--bs-secondary, #6c757d);
    opacity: 0.5;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .o-sidebar-rail-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0.375rem;
    cursor: pointer;
    color: var(--bs-secondary, #6c757d);
    border-radius: 0.375rem;
  }
  .o-sidebar-rail-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--bs-body-color, #212529);
  }

  /* --- Collapse header: visible in expanded mode only --- */
  .o-sidebar .o-sidebar-head {
    display: none;
    padding: 0.25rem 0.5rem;
  }
  .o-sidebar:hover .o-sidebar-head,
  .o-sidebar.o-sidebar--pinned .o-sidebar-head {
    display: flex;
    justify-content: flex-end;
  }

  /* --- Three-zone body: hidden in mini mode, flex column on expand --- */
  .o-sidebar .o-sidebar-body {
    display: none;
    flex-direction: column;
    flex: 1 1 auto;
    overflow: hidden;
    min-height: 0;
  }
  .o-sidebar:hover .o-sidebar-body,
  .o-sidebar.o-sidebar--pinned .o-sidebar-body {
    display: flex;
  }

  /* Desktop sidebar needs flex layout for three-zone to work */
  .o-sidebar {
    display: flex;
    flex-direction: column;
  }
  .o-sidebar .o-sidebar-rail { flex: 0 0 auto; }
  .o-sidebar .o-sidebar-head { flex: 0 0 auto; }

  /* Collapsed children in expanded mode */
  .o-sidebar:hover .m-cat-children--collapsed,
  .o-sidebar.o-sidebar--pinned .m-cat-children--collapsed {
    display: none;
  }
}

/* Remove default Bootstrap padding from mobile offcanvas body */
#sidebarNav .offcanvas-body {
  padding: 0;
}

/* Rail/head not needed outside desktop */
.o-sidebar-rail,
.o-sidebar-head {
  display: none;
}

/* --- FAB (floating action button) --- */
.a-sidebar-fab {
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 1040;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--kon-brand-color, #cf0015);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.a-sidebar-fab:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  transform: scale(1.05);
}
.a-sidebar-fab:active {
  transform: scale(0.98);
}

/* --- Back-to-category floating button (post detail only) --- */
.a-back-fab {
  position: fixed;
  bottom: calc(1.25rem + 48px + 0.75rem);
  left: 1.25rem;
  z-index: 1040;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--kon-brand-color, #cf0015);
  background: #fff;
  color: var(--kon-brand-color, #cf0015);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.a-back-fab:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: scale(1.05);
  color: var(--kon-brand-color, #cf0015);
}
.a-back-fab:active {
  transform: scale(0.98);
}

/* --- Custom sidebar overlay (replaces Bootstrap backdrop for Unpoly compat) --- */
.o-sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
}

/* --- Category tree --- */
.o-cat-tree {
  padding: 0;
}
.o-cat-tree-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.o-cat-tree-empty {
  padding: 0.5rem;
}

/* --- Category node --- */
.m-cat-node {
  list-style: none;
}

/* Parent category rows: grey background, top border divider */
.o-cat-tree-list > .m-cat-node > .m-cat-node-row {
  background: #f0f0f0;
  border-top: 1px solid #ccc;
}

/* All category rows: shared layout — 4px left border reserved for selection indicator */
.m-cat-node-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  border-left: 4px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-cat-node-row:hover {
  background: rgba(0, 0, 0, 0.05);
}
.m-cat-node-full {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Category children: flush-left, white background, no borders --- */
.m-cat-children {
  padding-left: 0;
  list-style: none;
  margin: 0;
}
.m-cat-children .m-cat-node-row {
  background: #fff;
}
.m-cat-children--collapsed {
  display: none;
}

/* --- Count badge --- */
.a-cat-count {
  font-size: 0.7rem;
  background: var(--bs-secondary-bg, #e9ecef);
  color: var(--bs-secondary, #6c757d);
  flex-shrink: 0;
}

/* --- Sidebar section divider (replaces <hr> elements) --- */
.m-sidebar-section {
  border-top: 1px solid #ccc;
}

/* --- Sidebar nav (profile + logout) --- */
.m-sidebar-nav {
  padding: 0;
}
.m-sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-left: 4px solid transparent;
  text-decoration: none;
  color: var(--bs-body-color, #212529);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: inherit;
}
.m-sidebar-nav-link:hover {
  background: rgba(0, 0, 0, 0.05);
  text-decoration: none;
  color: var(--kon-brand-color, #cf0015);
}
.m-sidebar-nav-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

/* --- Selected category (Phase 5 → Phase 6.5 Flutter alignment) --- */
/* Colorize the reserved left border; preserves parent grey / child white background */
.m-cat-node-row--selected {
  border-left-color: var(--kon-brand-color, #cf0015);
}
.m-cat-node-row--selected .m-cat-node-link {
  color: var(--kon-brand-color, #cf0015);
}

/* --- Category link in sidebar (Phase 5 → Phase 6.5 Flutter alignment) --- */
.m-cat-node-link {
  font-family: 'BasicGothicWebPro', sans-serif;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--bs-body-color, #212529);
  text-decoration: none;
}
.m-cat-children .m-cat-node-link {
  font-weight: 300;
  font-size: 0.85rem;
}
.m-cat-node-link:hover {
  color: var(--kon-brand-color, #cf0015);
  text-decoration: none;
}

/* --- Breadcrumb (Phase 5) --- */
.m-breadcrumb {
  font-size: 0.875rem;
}
.m-breadcrumb .breadcrumb-item a {
  color: var(--bs-secondary, #6c757d);
  text-decoration: none;
}
.m-breadcrumb .breadcrumb-item a:hover {
  color: var(--kon-brand-color, #cf0015);
}

/* === Three-zone sidebar layout (Phase 4b) === */

/* Scrollable middle zone */
.o-sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

/* Pinned footer zone */
.o-sidebar-footer {
  flex: 0 0 auto;
  border-top: 1px solid #ccc;
}

/* Mobile offcanvas: override Bootstrap default overflow-y for flex layout */
#sidebarNav .offcanvas-body.o-sidebar-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

