/* Sidebar + topbar layout adapted from GenericTirewebChatbot */

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  flex: 0 0 280px;
  background: #f7f7f7;
  border-right: 1px solid var(--border-200);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-200);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.sidebar-brand .logo-badge {
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}

.sidebar-brand h1 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-900);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.sidebar-brand p {
  font-size: 12px;
  color: var(--text-600);
  margin: 0;
}

.sidebar-nav {
  padding: 10px 10px 14px 10px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.nav-locked .sidebar-nav {
  display: none;
}

.nav-section-title {
  padding: 10px 10px 6px 10px;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-600);
  font-weight: 700;
  letter-spacing: 0.7px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin: 2px 0;
  color: var(--text-800);
  text-decoration: none;
  font-size: 13px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-left-color 0.15s;
}

.nav-item:hover {
  background: #eceff3;
  border-left-color: color-mix(in srgb, var(--brand-800) 55%, #ffffff);
}

.nav-item.active {
  background: #ffe9df;
  border-left-color: #ff8a5c;
  color: var(--text-900);
}

.nav-item--danger {
  color: var(--danger-600);
  background: transparent;
  border-left-color: transparent;
}

.nav-item--danger.active {
  background: transparent;
  border-left-color: transparent;
  color: var(--danger-700);
}

.nav-item--danger:hover {
  background: transparent;
  border-left-color: transparent;
  color: var(--danger-700);
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.nav-item--hidden {
  display: none !important;
}

.nav-divider {
  height: 1px;
  background: var(--border-200);
  margin: 10px 8px;
}

/* Main */
.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-200);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 0 18px;
  gap: 10px;
}

.topbar-title {
  min-width: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn {
  display: none;
}

@media (max-width: 768px) {
  .icon-btn {
    display: inline-flex;
  }
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-200);
  background: var(--surface);
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.icon-btn:hover {
  background: var(--surface-100);
}

/* Backdrop for mobile drawer */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 999;
}

.page {
  padding: 18px;
  flex: 1 1 auto;
  min-width: 0;
  width: min(80rem, 100%);
  margin-inline: auto;
}

/* Mobile drawer */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    max-width: 85vw;
    z-index: 1000;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow-lg);
    border-right: 1px solid var(--border-200);
  }

  .layout.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .layout.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .main {
    width: 100%;
  }

  .topbar {
    padding: 0 14px;
  }

  .page {
    padding: 14px;
  }
}

@media (max-width: 900px) {
  .topbar-actions {
    gap: 8px;
  }
}
