/* ═══════════════════════════════════════════
   LAYOUT.CSS — Collapsible Rail Sidebar, Topbar, Layout Shell
   ═══════════════════════════════════════════ */

/* ── App Layout Shell ── */
#app {
  display: flex;
  min-height: 100vh;
  position: relative;
}

#main {
  margin-left: var(--sidebar-width-expanded);
  width: calc(100% - var(--sidebar-width-expanded));
  flex: 1;
  min-height: 100vh;
  background: var(--surface-0);
  transition: margin-left var(--transition-med), width var(--transition-med);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* When sidebar is collapsed */
#app.sidebar-collapsed #main {
  margin-left: var(--sidebar-width-collapsed);
  width: calc(100% - var(--sidebar-width-collapsed));
}

/* ── Topbar (Sticky header inside #main) ── */
.topbar {
  height: 64px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-toggle-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.sidebar-toggle-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ── Collapsible Sidebar ── */
#sidebar {
  width: var(--sidebar-width-expanded);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: width var(--transition-med);
  overflow: hidden;
}

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

/* ── Sidebar Logo Area ── */
.sidebar-logo {
  height: 64px;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--sidebar-border);
  overflow: hidden;
  flex-shrink: 0;
}

.logo-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.logo-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.logo-icon img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

.logo-text {
  font-family: var(--font-heading);
  color: var(--sidebar-active);
  line-height: 1.2;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.logo-title {
  font-size: 15px;
  font-weight: 700;
}

.logo-subtitle-text {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

.logo-text span {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--brand-secondary);
  opacity: 0.85;
}

#app.sidebar-collapsed .logo-text {
  opacity: 0;
  pointer-events: none;
}

/* ── Navigation Area ── */
.nav-section {
  padding: 1.25rem 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.4);
  padding: 0.75rem 1.25rem 0.5rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity var(--transition-fast);
}

#app.sidebar-collapsed .nav-label {
  opacity: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition-fast), background var(--transition-fast), border var(--transition-fast);
  border-left: 3px solid transparent;
  white-space: nowrap;
}

.nav-item:hover {
  color: var(--sidebar-active);
  background: var(--sidebar-hover);
  text-decoration: none;
}

.nav-item.active {
  color: var(--sidebar-active);
  border-left-color: var(--brand-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  opacity: 0.65;
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
  fill: currentColor;
}

.nav-item:hover svg,
.nav-item.active svg {
  opacity: 1;
}

#app.sidebar-collapsed .nav-item span {
  display: none;
}

#app.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0.75rem 0;
  border-left-width: 0;
  border-right: 3px solid transparent;
}

#app.sidebar-collapsed .nav-item.active {
  border-right-color: var(--brand-primary);
}

/* ── Sidebar Footer & User Chip ── */
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--btn-radius);
  transition: background var(--transition-fast);
  text-decoration: none;
  color: var(--sidebar-text);
}

.user-chip:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-active);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity var(--transition-fast);
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-active);
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-email {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  font-family: var(--font-mono);
  text-overflow: ellipsis;
  overflow: hidden;
}

#app.sidebar-collapsed .user-info {
  display: none;
}

#app.sidebar-collapsed .user-chip {
  justify-content: center;
  padding: 0.5rem 0;
}

/* ── Main Scrollable Page Area ── */
.page-content-wrapper {
  padding: 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ── Page Header ── */
.page-header {
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.page-header-title {
  display: flex;
  flex-direction: column;
}

.page-header h1 {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-header p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.breadcrumb {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.breadcrumb-separator {
  color: var(--text-muted);
  opacity: 0.5;
}

/* ── Content grids ── */
.col-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.col-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

.col-sidebar {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
}

@media (max-width: 850px) {
  .col-2, .col-3, .col-sidebar {
    grid-template-columns: 1fr;
  }
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 1rem;
}

/* ── Premium Neumorphic Day/Night Theme Switch ── */
.theme-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  padding: 4px;
}

.theme-switch-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 140px;
  height: 38px;
  border-radius: 19px;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-switch-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  z-index: 2;
  transition: color 0.3s ease;
  pointer-events: none;
  font-family: var(--font-heading);
}

.theme-switch-label.label-left {
  color: var(--brand-primary);
}

.theme-switch-label.label-right {
  color: var(--text-muted);
}

.theme-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-1);
  box-shadow: 0 3px 8px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
}

.theme-switch-thumb svg {
  position: absolute;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.theme-switch-thumb .sun-icon {
  opacity: 1;
  transform: rotate(0);
  color: #ff9f0a;
}

.theme-switch-thumb .moon-icon {
  opacity: 0;
  transform: rotate(-45deg);
  color: #9898ed;
}

[data-theme="dark"] .theme-switch-track {
  background: #0f1016;
  border-color: rgba(255,255,255,0.06);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.4);
}

[data-theme="dark"] .theme-switch-thumb {
  transform: translateX(104px);
  background: #1e1f29;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
}

[data-theme="dark"] .theme-switch-thumb .sun-icon {
  opacity: 0;
  transform: rotate(45deg);
}

[data-theme="dark"] .theme-switch-thumb .moon-icon {
  opacity: 1;
  transform: rotate(0);
  color: #5e5ce6;
}

[data-theme="dark"] .theme-switch-label.label-left {
  color: var(--text-muted);
}

[data-theme="dark"] .theme-switch-label.label-right {
  color: #5e5ce6;
}

.theme-switch:focus-visible {
  outline: none;
}
.theme-switch:focus-visible .theme-switch-track {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* ── Topbar Menu Dropdown & Support Modal ── */
.topbar-menu-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.topbar-menu-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.topbar-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 200px;
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.topbar-menu-dropdown.show {
  display: flex;
}
.topbar-menu-dropdown .dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.topbar-menu-dropdown .dropdown-item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.topbar-menu-dropdown .dropdown-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}
.topbar-menu-dropdown .dropdown-item:hover svg {
  color: var(--brand-primary);
}

