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

[dir='rtl'] .app-shell {
  direction: rtl;
}

.sidebar {
  width: 260px;
  background: var(--color-bg-dark);
  color: var(--color-text-inverted);
  padding: 1.5rem 1rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}
.sidebar-brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: linear-gradient(135deg, #10b981, #047857);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 24px rgba(16,185,129,.25);
  font-weight: 900;
  font-size: 16px;
  flex: 0 0 auto;
}
.sidebar-brand-text {
  font-weight: 900;
  font-size: 24px;
  color: #fff;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  color: rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.9375rem;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
  text-decoration: none;
}

.sidebar-link.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-primary);
}

.sidebar-link-icon {
  font-size: 1.125rem;
  width: 22px;
  text-align: center;
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  overflow-x: auto;
}

.topbar {
  background: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border);
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text);
  margin-inline-start: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-inline-start: auto;
}

.locale-switcher {
  display: inline-flex;
  gap: 2px;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 3px;
  font-size: 0.8125rem;
}
.locale-switcher a {
  padding: 4px 12px;
  border-radius: 999px;
  color: #475569;
  font-weight: 700;
  text-decoration: none;
  transition: all .2s ease;
}
.locale-switcher a:hover {
  color: #047857;
}
.locale-switcher a.current {
  background: #10b981;
  color: #ffffff;
  font-weight: 700;
}

.page-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0 0 0.25rem;
}

.page-header .subtitle {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

.topbar-hamburger { display: none; background: transparent; border: 0; font-size: 22px; cursor: pointer; padding: 4px 8px; color: inherit; }

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

  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: 260px;
    max-width: 80vw;
    height: 100vh;
    padding: 1.5rem 1rem;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 50;
  }
  [dir='rtl'] .sidebar { transform: translateX(100%); }
  .sidebar.is-open { transform: translateX(0); }
  [dir='rtl'] .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 40;
  }
  .page-container {
    padding: 1rem;
  }
}
.sidebar-brand-logo {
  height: 36px;
  width: auto;
  display: block;
  object-fit: contain;
  max-width: 100%;
}

/* Topbar brand link + home button (dashboard layout) */
.topbar-brand { display: inline-flex; align-items: center; text-decoration: none; margin-inline-end: 4px; }
.topbar-brand-text { font-weight: 800; color: var(--color-primary, #10b981); font-size: 18px; }
.topbar-home-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 8px; background: #10b981; color: #fff; text-decoration: none; font-weight: 600; font-size: 14px; transition: background .12s; }
.topbar-home-btn:hover { background: #0ea372; color: #fff; }

/* Mobile-only logout button — sits in .topbar-actions next to LocaleSwitcher.
   On desktop the canonical place is still the Sidebar footer button; this is
   purely a viewport ≤768px affordance so users don't have to open the drawer
   and scroll past 12 nav links to reach signOut. */
.topbar-logout-btn {
  display: none;
}
@media (max-width: 768px) {
  .topbar-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--color-primary, #047857);
    padding: 6px;
    border-radius: 8px;
    transition: background 0.12s;
  }
  .topbar-logout-btn:hover {
    background: rgba(16, 185, 129, 0.10);
  }
}
