/* =======================================================================
   layout.css — App Shell, Sidebar, Header, Content Grid, Responsive
   Advanced Solar Load Calculator — Production CSS Architecture
   ======================================================================= */

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

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  transition: width var(--transition-slow);
  shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .brand-name,
.sidebar.collapsed .brand-sub,
.sidebar.collapsed .sidebar-footer-text {
  display: none;
}

/* Sidebar brand area */
.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(to bottom left, var(--accent), var(--solar-2));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-accent);
  flex-shrink: 0;
  position: relative;
  font-size: 1.1rem;
}

.brand-icon::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--emerald);
  border: 2px solid var(--bg-2);
}

.brand-name {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
}

/* Sidebar navigation */
.sidebar-nav {
  flex: 1;
  padding: var(--sp-2);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

/* Navigation items */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-lg);
  color: var(--text-3);
  transition: all var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
  position: relative;
  white-space: nowrap;
}

.nav-item:hover {
  background: rgba(30, 41, 59, 0.4);
  color: var(--text-2);
}

.nav-item.active {
  background: linear-gradient(to left, rgba(255,106,0,0.2), rgba(245,158,11,0.1));
  color: var(--accent-2);
  border: 1px solid rgba(255,106,0,0.3);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.5rem;
  background: linear-gradient(to bottom, var(--accent), var(--solar-2));
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-item.active .nav-icon {
  color: var(--accent);
}

.nav-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar toggle button */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-lg);
  color: var(--text-3);
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--fs-base);
  transition: all var(--transition-fast);
  gap: var(--sp-3);
}

.sidebar-toggle:hover {
  background: rgba(30, 41, 59, 0.4);
  color: var(--text-2);
}

/* Sidebar footer */
.sidebar-footer {
  padding: var(--sp-2);
  border-top: 1px solid var(--border);
}

.sidebar-footer-text {
  font-size: var(--fs-xs);
  color: var(--text-4);
  line-height: var(--lh-relaxed);
  padding: var(--sp-2) var(--sp-3);
}

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

/* ── Header ────────────────────────────────────────────────────────── */
.header {
  height: var(--header-height);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 26, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-4);
  gap: var(--sp-4);
  z-index: var(--z-header);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.brand-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}

.brand-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.header-project {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.header-status {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.status-loads,
.status-mode {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.status-live {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 6px;
  font-size: var(--fs-xs);
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.2);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-family: var(--fs-xs);
}

/* ── Content area ──────────────────────────────────────────────────── */
.content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── View wrapper ──────────────────────────────────────────────────── */
.view {
  padding: var(--sp-6);
  max-width: var(--max-content);
  margin: 0 auto;
  animation: fadeIn 0.25s ease;
}

.view-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.view-header h2 {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text);
}

.view-subtitle {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 2px;
}

.view-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

.view-content {
  margin-top: var(--sp-4);
}

/* ── Empty state ───────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
  color: var(--text-3);
  gap: var(--sp-3);
}

.empty-state svg {
  width: 3rem;
  height: 3rem;
  color: var(--text-4);
}

/* ── Placeholder panel ─────────────────────────────────────────────── */
.placeholder-panel {
  padding: var(--sp-8);
  text-align: center;
  color: var(--text-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.placeholder-panel p {
  margin-bottom: var(--sp-2);
}

/* ── View-specific wrappers ─────────────────────────────────────────── */
.dashboard-view,
.inventory-view,
.schedule-view,
.analysis-view,
.reports-view,
.library-view,
.settings-view,
.assumptions-view,
.validation-view,
.documentation-view,
.tests-view {
  /* All views share the .view base; these selectors enable view-specific
     overrides if needed in the future */
}

/* ── Responsive Layout ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-sidebar);
    transform: translateX(0);
    transition: transform var(--transition-slow);
  }
  .sidebar.collapsed {
    transform: translateX(100%);
    width: var(--sidebar-width);
  }
  .main-area {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .view {
    padding: var(--sp-4);
  }
  .view-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-status {
    display: none;
  }
}

@media (max-width: 480px) {
  .view {
    padding: var(--sp-3);
  }
}
