/**
 * Bazyaft Visual Design Library — Responsive Styles
 * Mobile-first breakpoints with RTL-safe handling
 */

/* ═══════════════════════════════════════════════════════════
   PROTOTYPE SHELL LAYOUT (The main viewer chrome)
════════════════════════════════════════════════════════════ */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-app);
}

/* Left sidebar: navigation tree */
.shell-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-normal);
  z-index: var(--z-sticky);
}
.shell-sidebar.collapsed { width: 0; overflow: hidden; }

/* Main content area */
.shell-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Top toolbar of the shell */
.shell-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--color-neutral-900);
  color: white;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 52px;
}
.shell-toolbar-brand {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-base);
  color: var(--color-primary-400);
  flex-shrink: 0;
}
.shell-toolbar-controls {
  display: flex; align-items: center; gap: var(--space-2);
  margin-inline-start: auto;
  flex-wrap: wrap;
}

/* Frame area that shows the prototype page */
.shell-frame-wrapper {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-4);
  background: #1e2a3a;
  position: relative;
}

.shell-frame {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.05);
  transition: width var(--transition-normal), height var(--transition-normal);
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

/* Device size modes */
.shell-frame.mobile  { width: 390px; height: 844px; border-radius: 40px; }
.shell-frame.tablet  { width: 768px; height: 668px; }
.shell-frame.desktop { width: 100%; height: 100%; border-radius: var(--radius-sm); }

.shell-frame-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  scroll-behavior: smooth;
}

/* Device notch (mobile mode) */
.shell-frame.mobile .device-notch {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: var(--bg-surface);
  flex-shrink: 0;
}
.device-notch { display: none; }
.notch-pill {
  width: 120px; height: 32px;
  background: var(--color-neutral-900);
  border-radius: var(--radius-full);
}

/* ═══════════════════════════════════════════════════════════
   SHELL SIDEBAR NAV TREE
════════════════════════════════════════════════════════════ */
.sidebar-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%; padding: 8px 12px;
  font-family: var(--font-family-fa); font-size: var(--font-size-sm);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  color: var(--text-main); background: var(--bg-surface-subtle);
  direction: rtl;
}
.sidebar-search input:focus { outline: none; border-color: var(--color-primary-700); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--space-2) 0; }

.nav-domain-group { }
.nav-domain-toggle {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%; padding: var(--space-2) var(--space-4);
  background: none; border: none; cursor: pointer;
  font-family: var(--font-family-fa); font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold); color: var(--text-main);
  text-align: start;
  transition: background var(--transition-fast);
}
.nav-domain-toggle:hover { background: var(--bg-surface-subtle); }
.nav-domain-icon { font-size: 1rem; flex-shrink: 0; }
.nav-domain-label { flex: 1; }
.nav-domain-count {
  background: var(--bg-surface-hover); color: var(--text-subtle);
  border-radius: var(--radius-full); padding: 1px 6px; font-size: 0.65rem;
}
.nav-chevron { transition: transform var(--transition-fast); font-size: 0.75rem; }
.nav-domain-group.open .nav-chevron { transform: rotate(180deg); }

.nav-screen-list { display: none; padding-inline-start: var(--space-4); }
.nav-domain-group.open .nav-screen-list { display: block; }

.nav-screen-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 6px var(--space-4) 6px var(--space-3);
  font-size: var(--font-size-xs); color: var(--text-muted);
  cursor: pointer; border-radius: var(--radius-sm); margin: 1px 4px;
  transition: all var(--transition-fast);
  text-align: start; border: none; background: none;
  font-family: var(--font-family-fa); width: calc(100% - 8px);
}
.nav-screen-item:hover { background: var(--bg-surface-subtle); color: var(--text-main); }
.nav-screen-item.active {
  background: var(--color-primary-50); color: var(--color-primary-700);
  font-weight: var(--font-weight-semibold);
}
.nav-screen-id { font-size: 0.6rem; color: var(--text-subtle); flex-shrink: 0; font-weight: var(--font-weight-bold); min-width: 48px; }
.nav-screen-name { flex: 1; }
.nav-screen-v1-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-primary-500); flex-shrink: 0; }
.nav-screen-future-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-neutral-300); flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════
   SHELL TOOLBAR CONTROLS
════════════════════════════════════════════════════════════ */
.toolbar-btn {
  display: flex; align-items: center; gap: var(--space-1);
  padding: 5px 10px; border-radius: var(--radius-sm);
  font-family: var(--font-family-fa); font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium); cursor: pointer;
  border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.8); transition: all var(--transition-fast);
  white-space: nowrap;
}
.toolbar-btn:hover { background: rgba(255,255,255,0.15); color: white; }
.toolbar-btn.active { background: var(--color-primary-700); color: white; border-color: var(--color-primary-600); }

.toolbar-select {
  padding: 5px 10px; border-radius: var(--radius-sm);
  font-family: var(--font-family-fa); font-size: var(--font-size-xs);
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8); cursor: pointer;
  direction: rtl;
}
.toolbar-select:focus { outline: none; border-color: var(--color-primary-500); }
.toolbar-select option { background: var(--color-neutral-900); color: white; }

.toolbar-divider { width: 1px; height: 24px; background: rgba(255,255,255,0.15); flex-shrink: 0; }

/* Demo banner inside toolbar */
.toolbar-demo-label {
  font-size: 0.65rem; font-weight: 800; letter-spacing: 0.08em;
  color: #fbbf24; padding: 2px 8px; border-radius: var(--radius-full);
  border: 1px solid #fbbf24; white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN / DESKTOP PANEL LAYOUT (Sidebar + Main)
════════════════════════════════════════════════════════════ */
.panel-layout {
  display: flex; height: 100%;
}
.panel-sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--color-neutral-900);
  color: white; display: flex; flex-direction: column;
  overflow-y: auto;
}
.panel-sidebar-header {
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.panel-sidebar-brand { font-weight: 800; font-size: var(--font-size-lg); color: var(--color-primary-400); }
.panel-sidebar-role { font-size: var(--font-size-xs); color: rgba(255,255,255,0.4); margin-top: 2px; }
.panel-nav { padding: var(--space-3) 0; flex: 1; }
.panel-nav-section-title { padding: var(--space-2) var(--space-4); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: rgba(255,255,255,0.3); font-weight: 700; }
.panel-nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-4); font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium); color: rgba(255,255,255,0.6);
  cursor: pointer; border: none; background: none;
  font-family: var(--font-family-fa); width: 100%; text-align: start;
  transition: all var(--transition-fast); border-radius: 0;
}
.panel-nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.panel-nav-item.active { background: rgba(16,185,129,0.15); color: var(--color-primary-400); border-right: 3px solid var(--color-primary-500); }
.panel-nav-item .icon { width: 20px; text-align: center; flex-shrink: 0; }

.panel-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.panel-topbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
  background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0; min-height: 60px;
}
.panel-topbar-title { font-weight: var(--font-weight-semibold); font-size: var(--font-size-lg); }
.panel-content { flex: 1; overflow-y: auto; padding: var(--space-6); }

/* ═══════════════════════════════════════════════════════════
   MOBILE APP LAYOUT
════════════════════════════════════════════════════════════ */
.mobile-layout {
  display: flex; flex-direction: column; height: 100%;
  background: var(--bg-app);
}
.mobile-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: var(--space-4);
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

/* ═══════════════════════════════════════════════════════════
   GRID LAYOUTS FOR DASHBOARD
════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .panel-topbar-title { font-size: var(--font-size-base); }
  .panel-content { padding: var(--space-4); }
  .shell-frame.tablet { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════
   PRINT / EXPORT
════════════════════════════════════════════════════════════ */
@media print {
  .shell-sidebar, .shell-toolbar, .bottom-nav, .demo-banner, .app-bar { display: none !important; }
  .shell-frame { box-shadow: none !important; border-radius: 0 !important; width: 100% !important; height: auto !important; }
  .shell-frame-wrapper { padding: 0 !important; background: white !important; }
  .shell-frame-content { overflow: visible !important; }
}
