/* ── App Shell ── */
.app-shell {
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  transition: width 0.2s ease;
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar:hover {
  width: var(--sidebar-width-expanded);
}

/* ── Sidebar Logo ── */
.sidebar-logo {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
}
.sidebar-logo-img {
  width: 100%;
  max-width: 180px;
  height: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
  transition: max-width 0.2s ease;
}
.sidebar:not(:hover) .sidebar-logo-img {
  max-width: 32px;
}
.sidebar-logo-icon {
  width: 24px;
  height: 24px;
  min-width: 24px;
  background: var(--accent-primary);
  border-radius: var(--radius-sm);
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar-logo-text {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.sidebar:hover .sidebar-logo-text { opacity: 1; }

/* ── Sidebar Section Labels ── */
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 12px 16px 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.sidebar:hover .sidebar-section-label { opacity: 1; }

/* ── Sidebar Navigation Items ── */
.sidebar-nav {
  padding: 8px 0;
  flex-shrink: 0;
  overflow-y: auto;
  flex: 1;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: rgba(255,255,255,0.6);
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.sidebar-item svg {
  width: 20px;
  height: 20px;
  min-width: 20px;
  flex-shrink: 0;
}
.sidebar-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar-item.active {
  color: #fff;
  background: var(--sidebar-hover);
}

/* ── Sidebar Labels (shown only when expanded) ── */
.sidebar-label {
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}
.sidebar:hover .sidebar-label { opacity: 1; }
.sidebar-label-always { opacity: 1 !important; }

/* ── Accordion Nav Group ── */
.sidebar-nav-group {
  overflow: hidden;
}

/* Expandable nav item with chevron */
.sidebar-item-expandable {
  display: flex;
  align-items: center;
  width: 100%;
}
.sidebar-item-chevron {
  margin-left: auto;
  transition: transform 0.2s ease, opacity 0.15s ease;
  opacity: 0;
  color: rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.sidebar-item-chevron svg {
  width: 12px;
  height: 12px;
  min-width: 12px;
}
.sidebar:hover .sidebar-item-chevron { opacity: 1; }
.sidebar-item-chevron.open {
  transform: rotate(180deg);
}

/* Sub-items container */
.sidebar-sub {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.15s ease;
  background: rgba(0,0,0,0.15);
  opacity: 0;
}
.sidebar:hover .sidebar-sub {
  opacity: 1;
}

/* Sub-item styling */
.sidebar-sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 48px;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: color 0.1s, background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.sidebar-sub-item:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.05);
}
.sidebar-sub-item.active {
  color: #fff;
  font-weight: 500;
}

/* Language sub-items (not clickable, info only) */
.sidebar-sub-item.info {
  cursor: default;
  font-size: 11px;
}
.sidebar-sub-item.info:hover {
  background: transparent;
  color: rgba(255,255,255,0.5);
}
.sidebar-sub-item .lang-short {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.6;
  min-width: 20px;
}

/* ── Sidebar Bottom (Settings, User) ── */
.sidebar-bottom {
  margin-top: auto;
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

/* Bottom icons row: visible in collapsed state */
.sidebar-bottom-icons {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Expanded settings area — controlled by JS click, not hover */
.sidebar-settings-expanded {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ── Settings inside Sidebar ── */
.sidebar-settings-section {
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-settings-section:last-child { border-bottom: none; }

.sidebar-settings-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.35);
  margin-bottom: 6px;
  white-space: nowrap;
}

.sidebar-settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}
.sidebar-settings-row-label {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
}

.sidebar-settings-color-input {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  background: transparent;
}
.sidebar-settings-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.sidebar-settings-color-input::-webkit-color-swatch { border: none; border-radius: 1px; }
.sidebar-settings-color-input::-moz-color-swatch { border: none; border-radius: 1px; }

.sidebar-dark-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.sidebar-dark-toggle:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.sidebar-lang-select {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  outline: none;
}
.sidebar-lang-select option {
  background: #1a1a1a;
  color: #fff;
}

.sidebar-user-info {
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-meta {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
  white-space: nowrap;
}

.sidebar-logout-btn {
  width: 100%;
  padding: 8px 16px;
  text-align: left;
  color: #e57373;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
  white-space: nowrap;
}
.sidebar-logout-btn:hover {
  background: rgba(229,115,115,0.1);
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  display: none;
}
.sidebar-overlay.visible { display: block; }

/* ── Body ── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: 0;
  flex: 1;
  overflow: auto;
  padding: var(--content-padding);
  min-height: 100vh;
  transition: margin-left 0.2s ease;
}
.main-content-inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
}

/* ── Bottom Nav (mobile) ── */
.bottom-nav {
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  display: none;
  justify-content: space-around;
  padding: var(--space-sm) 0 12px;
  flex-shrink: 0;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
}
.bottom-nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: rgba(255,255,255,0.5);
  padding: var(--space-xs) var(--space-md);
  cursor: pointer;
}
.bottom-nav-btn.active { color: #fff; }
.bottom-nav-btn span { font-size: 9px; font-weight: 600; }

/* ── Mobile Menu Button ── */
.mobile-menu-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  background: var(--sidebar-bg);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 8px;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 95;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ── Grid helpers (8px-aligned gaps) ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md); }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--space-sm); }

/* ── Responsive: Mobile ── */
@media (max-width: 767px) {
  .sidebar {
    width: var(--sidebar-width-expanded);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar:hover {
    width: var(--sidebar-width-expanded);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  /* Force all labels/sections visible in mobile overlay mode */
  .sidebar.open .sidebar-label,
  .sidebar.open .sidebar-section-label,
  .sidebar.open .sidebar-logo-text,
  .sidebar.open .sidebar-item-chevron,
  .sidebar.open .sidebar-sub {
    opacity: 1;
  }

  .mobile-menu-btn { display: flex; }

  .main-content {
    margin-left: 0;
    padding: var(--content-padding-mobile);
    padding-top: 56px;
    padding-bottom: 72px;
  }

  .bottom-nav { display: flex; }

  .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; gap: var(--space-sm); }
  .grid-6 { grid-template-columns: 1fr 1fr; gap: var(--space-sm); }
}

/* ── Tablet breakpoint ── */
@media (min-width: 768px) and (max-width: 1024px) {
  .main-content { padding: var(--space-lg); }
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
}

/* ── Legacy Settings Dropdown (keep for any remaining references) ── */
.settings-dropdown { display: none; }
.settings-trigger { display: none; }
