/* ============================================================
   GEADEPLOY V2 — Shell Layout
   Sidebar + Topbar + iframe container
   ============================================================ */

html, body {
  height: 100%;
  overflow: hidden;
}

/* ── Layout Grid ── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar content";
  height: 100vh;
  width: 100vw;
  transition: grid-template-columns var(--transition-slow);
}

#app.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) 1fr;
}

/* ── Topbar ── */
#topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
  z-index: 100;
}

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

.topbar-breadcrumb {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-breadcrumb .current {
  color: var(--text-primary);
  font-weight: 600;
}
.topbar-breadcrumb .sep {
  color: var(--text-tertiary);
  font-size: 10px;
}

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

.topbar-icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--border-radius);
  transition: all var(--transition-fast);
}
.topbar-icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.topbar-user:hover {
  background: var(--bg-tertiary);
}
.topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gea-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  color: var(--text-on-blue);
}
.topbar-username {
  font-size: 13px;
  color: var(--text-primary);
}

/* ── Sidebar ── */
#sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-primary);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border-primary);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  background: var(--gea-blue);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.sidebar-logo-text span {
  color: var(--gea-blue-light);
}

.sidebar-collapse-btn {
  margin-left: auto;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--border-radius);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Sidebar sections */
.sidebar-section {
  padding: 12px 8px 4px;
}
.sidebar-section-label {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  color: var(--text-tertiary);
  padding: 0 8px 6px;
  white-space: nowrap;
  overflow: hidden;
}

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--border-radius);
  cursor: pointer;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
}
.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--gea-blue-subtle);
  color: var(--gea-blue-light);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--gea-blue);
  border-radius: 1px;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-icon svg {
  width: 18px;
  height: 18px;
}

.nav-label {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 2px;
  background: var(--gea-blue-subtle);
  color: var(--gea-blue-light);
}

/* Collapsed state */
.sidebar-collapsed #sidebar .nav-label,
.sidebar-collapsed #sidebar .nav-badge,
.sidebar-collapsed #sidebar .sidebar-section-label,
.sidebar-collapsed #sidebar .sidebar-logo-text,
.sidebar-collapsed #sidebar .sidebar-collapse-btn {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity var(--transition-fast);
}

.sidebar-collapsed #sidebar .nav-item {
  justify-content: center;
  padding: 10px 0;
}

.sidebar-collapsed #sidebar .sidebar-header {
  justify-content: center;
  padding: 0;
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding: 8px;
  border-top: 1px solid var(--border-primary);
}

/* ── Content Area (iframe) ── */
#content {
  grid-area: content;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
}

#module-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg-primary);
}

/* Loading overlay */
#loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 50;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}
#loading-overlay.hidden {
  opacity: 0;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-primary);
  border-top-color: var(--gea-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
