/* ============================================================
   RESTHOUSE MANAGER — LAYOUT
   Sidebar (right for RTL) + header + content
   Mirrors Flutter's DesktopAppShell
   ============================================================ */

/* ── App Shell ────────────────────────────────────────────── */
#app {
  min-height: 100vh;
}

/* Auth pages fill the entire viewport */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 50%, var(--color-primary-light) 100%);
}

/* ── Main App Layout (Sidebar + Content) ──────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: row;
  direction: rtl;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--color-card);
  border-left: 1px solid var(--color-border);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 0;
  left: auto;
  top: 0;
  bottom: 0;
  z-index: 200;
  transition: transform var(--transition), background-color var(--transition);
  overflow-y: auto;
  transform: translateX(0);
}

/* Sidebar — Logo Header */
.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 44px;
  height: 44px;
  background: rgba(15, 52, 81, 0.12);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo-icon svg {
  color: var(--color-primary);
}

.sidebar-logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-logo-text {
  flex: 1;
  min-width: 0;
}

.sidebar-logo-text h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logo-text p {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.dev-badge {
  background: var(--color-warning);
  color: #1a1a1a;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* Sidebar — Tenant Card */
.sidebar-tenant {
  /* margin: 0 16px 0; */
  padding: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.sidebar-tenant-avatar {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-tenant-avatar svg {
  color: #fff;
}

.sidebar-tenant-info h4 {
  font-size: 0.825rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-tenant-info p {
  font-size: 0.7rem;
  color: var(--color-text-secondary);
}

/* Sidebar — Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  width: 100%;
  background: none;
  text-align: start;
}

.sidebar-nav-item:hover {
  background: rgba(15, 52, 81, 0.07);
  color: var(--color-primary);
}

.sidebar-nav-item.active {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
}

.sidebar-nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-nav-item span {
  flex: 1;
}

/* Sidebar — Footer (Theme toggle) */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-footer .footer-label {
  flex: 1;
  font-size: 0.825rem;
  font-weight: 600;
}

/* ── Top Header ───────────────────────────────────────────── */
.header {
  height: var(--header-height);
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background-color var(--transition);
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Hamburger (mobile) */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  transition: background var(--transition);
}

.hamburger-btn:hover {
  background: var(--color-surface);
}

.hamburger-btn svg {
  width: 22px;
  height: 22px;
}

/* ── Main Content Area ────────────────────────────────────── */
.main-content {
  flex: 1;
  /* Sidebar is fixed on the right, reserve space via margin-right */
  margin-right: var(--sidebar-width);
  margin-left: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: margin var(--transition);
  direction: rtl;
}

.page-body {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
  margin-inline: auto;
}

/* Responsive max widths */
.content-wrapper {
  max-width: 1100px;
  margin-inline: auto;
}

.content-wrapper-narrow {
  max-width: 800px;
  margin-inline: auto;
}

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

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {

  /* On mobile: sidebar is off-screen to the right by default */
  .sidebar {
    transform: translateX(100%);
    /* hidden: slid off to the right */
    transition: transform 0.3s ease;
  }

  /* When hamburger opens sidebar: slide in from right */
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .main-content {
    margin-right: 0;
    margin-left: 0;
  }

  .hamburger-btn {
    display: flex;
  }

  .sidebar-overlay.show {
    display: block;
  }

  .page-body {
    padding: 16px;
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ── Subscription Banner ──────────────────────────────────── */
.subscription-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: rgba(255, 193, 7, 0.12);
  border-bottom: 1px solid rgba(255, 193, 7, 0.4);
  font-size: 0.875rem;
  font-weight: 600;
  color: #92640f;
}

[data-theme="dark"] .subscription-banner {
  color: #FFC107;
}

.subscription-banner svg {
  color: var(--color-warning);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.subscription-banner a {
  color: var(--color-primary);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* ── Page Section Heading ─────────────────────────────────── */
.page-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--color-text-primary);
}

/* ── Offline Banner ───────────────────────────────────────── */
.offline-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 24px;
  background: rgba(220, 53, 69, 0.1);
  border-bottom: 1px solid rgba(220, 53, 69, 0.3);
  font-size: 0.825rem;
  color: var(--color-danger);
  font-weight: 600;
}