/* ==========================================================
   SolarPro Design System - Layout
   App shell: sidebar + topbar + main content
   ========================================================== */

/* ── Body ── */
body {
  background-color: var(--bg-primary);
  font-family: var(--font-sans);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
}

/* ── App Layout Grid ── */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
  width: 100%;
}

/* ── Sidebar ── */
.sidebar {
  grid-area: sidebar;
  width: 260px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: width var(--transition-base);
  overflow: hidden;
}

.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed ~ .topbar,
.sidebar.collapsed ~ .main-content {
  margin-left: 72px;
}

.app-layout:has(.sidebar.collapsed) {
  grid-template-columns: 72px 1fr;
}

/* ── Sidebar Logo ── */
.sidebar-logo {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  background: var(--solar-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar.collapsed .sidebar-logo-text {
  display: none;
}

/* ── Sidebar Toggle ── */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  margin-left: auto;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* ── Sidebar Navigation ── */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav-section {
  margin-bottom: 8px;
}

.sidebar-nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding: 8px 12px 4px;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-nav-section-title {
  display: none;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 450;
  white-space: nowrap;
  transition: all var(--transition-fast);
  position: relative;
  cursor: pointer;
}

.sidebar-nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 500;
}

.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  background: var(--accent-blue);
}

.sidebar-nav-item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.sidebar-nav-item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-nav-item-label {
  display: none;
}

.sidebar-nav-item-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--accent-blue);
  color: #fff;
  min-width: 20px;
  text-align: center;
}

.sidebar.collapsed .sidebar-nav-item-badge {
  display: none;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border-default);
  flex-shrink: 0;
}

/* ── Topbar ── */
.topbar {
  grid-area: topbar;
  height: 56px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-search {
  position: relative;
  width: 320px;
}

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 14px;
  pointer-events: none;
}

.topbar-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  transition: all var(--transition-fast);
}

.topbar-search input::placeholder {
  color: var(--text-placeholder);
}

.topbar-search input:focus {
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-glow-blue);
  background: var(--bg-secondary);
}

.topbar-search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  position: relative;
  transition: all var(--transition-fast);
}

.topbar-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.topbar-btn-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
  border: 2px solid var(--bg-secondary);
}

/* ── Topbar User / Avatar Dropdown ── */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.topbar-user:hover {
  background: var(--bg-card-hover);
}

.topbar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-tertiary);
}

.topbar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.topbar-user-role {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ── Main Content ── */
.main-content {
  grid-area: main;
  padding: 32px;
  max-width: 1400px;
  width: 100%;
  overflow-y: auto;
  min-height: calc(100vh - 56px);
}

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

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

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb-item::after {
  content: '/';
  color: var(--text-tertiary);
  margin-left: 2px;
}

.breadcrumb-item:last-child::after {
  display: none;
}

.breadcrumb-item a {
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.breadcrumb-item a:hover {
  color: var(--text-primary);
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Sidebar Mobile Overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
}

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

/* ── Mobile Sidebar Toggle (visible only on mobile) ── */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}
