/* ==========================================================================
   LUUNA DESIGN SYSTEM — 4-Layout Portable Application Shell (v1.0.0-draft)
   Supports: studio (default), rail, dock, theater + mobile drawer (<= 768px)
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  width: 100%;
  height: 100vh;
  background: var(--bg-obsidian);
}

.sidebar {
  background: var(--bg-carbon);
  border-right: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  padding: 18px 12px 14px;
  gap: 10px;
  z-index: 20;
}

.sidebar .nav-menu { flex: 1; min-height: 0; overflow-y: auto; }
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-hairline);
}

.main-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-obsidian);
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--bg-glass);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-bottom: 1px solid var(--border-hairline);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.view-panel { padding: 28px 32px 64px; }

/* Desktop 4-Layout Engine */
@media (min-width: 769px) {
  html[data-layout="rail"] .app-shell { grid-template-columns: 64px 1fr; }
  html[data-layout="rail"] .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 64px;
    padding: 16px 8px 14px;
    align-items: center;
    z-index: 65;
    transition: width 0.2s var(--ease-rail), background 0.2s ease, box-shadow 0.2s ease;
  }
  html[data-layout="rail"] .sidebar:hover {
    width: 220px;
    align-items: stretch;
    padding: 16px 12px 14px;
    background: var(--bg-elevated);
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.35);
  }
  html[data-layout="rail"] .brand-title,
  html[data-layout="rail"] .brand-product-sub,
  html[data-layout="rail"] .sidebar-footer,
  html[data-layout="rail"] .nav-item span:not(.nav-count) { display: none; }
  html[data-layout="rail"] .sidebar:hover .brand-title,
  html[data-layout="rail"] .sidebar:hover .brand-product-sub,
  html[data-layout="rail"] .sidebar:hover .nav-item span:not(.nav-count) { display: inline; }
  html[data-layout="rail"] .nav-item { width: 44px; height: 40px; justify-content: center; padding: 0; }
  html[data-layout="rail"] .sidebar:hover .nav-item { width: 100%; height: auto; justify-content: flex-start; padding: 8px 11px; }
  html[data-layout="rail"] .main-content { grid-column: 2; }

  html[data-layout="dock"] .app-shell { grid-template-columns: 1fr; }
  html[data-layout="dock"] .sidebar {
    position: fixed;
    left: 50%; bottom: 16px;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 48px);
    height: 52px;
    flex-direction: row;
    align-items: center;
    padding: 6px 12px;
    gap: 5px;
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    background: var(--bg-elevated);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.42);
    z-index: 60;
  }
  html[data-layout="dock"] .brand-title,
  html[data-layout="dock"] .brand-product-sub,
  html[data-layout="dock"] .sidebar-footer,
  html[data-layout="dock"] .nav-item span:not(.nav-count) { display: none; }
  html[data-layout="dock"] .nav-menu { flex-direction: row; align-items: center; gap: 4px; overflow: visible; }
  html[data-layout="dock"] .nav-divider { width: 1px; height: 18px; margin: 0 4px; }
  html[data-layout="dock"] .nav-item { width: 38px; height: 38px; justify-content: center; padding: 0; }
  html[data-layout="dock"] .main-content { padding-bottom: 84px; }

  html[data-layout="theater"] .app-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  html[data-layout="theater"] .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 10px 20px;
    border-right: none;
    border-bottom: 1px solid var(--border-hairline);
  }
  html[data-layout="theater"] .sidebar-footer { display: none; }
  html[data-layout="theater"] .nav-menu { flex-direction: row; align-items: center; gap: 2px; overflow-x: auto; }
  html[data-layout="theater"] .nav-divider { width: 1px; height: 16px; margin: 0 6px; }
  html[data-layout="theater"] .nav-item { width: auto; height: 34px; padding: 0 10px; gap: 6px; font-size: 12.5px; border-radius: 6px; white-space: nowrap; }
  html[data-layout="theater"] .nav-item.active { background: transparent; box-shadow: inset 0 -2px 0 var(--accent-primary); }
}

/* Mobile Responsive Shell */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.22s var(--ease-spring);
    z-index: 200;
  }
  .sidebar.is-open { transform: translateX(0); }
  .topbar { padding: 12px 16px; }
  .view-panel { padding: 18px 16px 48px; }
}
