* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 24px;
  background: #f4f6f8;
  color: #151515;
  line-height: 1.5;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
}

/* Header & Nav in same row */
.app-header {
  background: #ffffff;
  padding: 14px 24px;
  border-radius: 8px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

/* Brand area with Esri Developer logo and Calcite Design System subheader */
.brand {
  display: flex;
  align-items: center;
}

.brand-link {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: opacity 0.15s ease;
}

.brand-link:hover {
  opacity: 0.85;
}

.esri-logo {
  height: 24px;
  width: auto;
  display: block;
}

.app-brand-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--calcite-color-brand, #0079c1);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  line-height: 1;
}

.app-subheader {
  font-size: 11px;
  font-weight: 400;
  color: var(--calcite-color-text-3, #6a6a6a);
  line-height: 1.2;
}

/* Navigation - clean text styling (no background buttons) */
.app-nav > ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.nav-link {
  color: #444444;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 4px;
  transition: color 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  text-align: left;
}

.nav-link:hover {
  color: #0079c1;
  background: transparent;
}

/* Active nav option: pure text with subtle bottom indicator line */
.nav-link.active {
  color: #0079c1;
  font-weight: 600;
  background: transparent;
  border-bottom-color: #0079c1;
}

.nav-link calcite-icon {
  color: inherit;
  transition: transform 0.2s ease;
}

/* Navigation Dropdown */
.nav-item-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.dropdown-toggle {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  color: #444444;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
}

.dropdown-toggle:hover {
  color: #0079c1;
  background: transparent;
}

.dropdown-toggle.active {
  color: #0079c1;
  font-weight: 600;
  border-bottom-color: #0079c1;
}

.nav-item-dropdown.open .dropdown-toggle calcite-icon {
  transform: rotate(180deg);
}

/* The dropdown menu ONLY opens when .open is present on .nav-item-dropdown */
.dropdown-menu,
.nav-item-dropdown:not(.open) .dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: #ffffff;
  border: 1px solid #dce2e8;
  border-radius: 6px;
  padding: 6px;
  margin: 0;
  list-style: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  display: none !important;
  flex-direction: column;
  gap: 2px;
  z-index: 1000;
}

.nav-item-dropdown.open .dropdown-menu {
  display: flex !important;
}

/* Dropdown items: clean left-aligned text links with equal padding */
.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: none;
  color: #333333;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s ease;
  cursor: pointer;
}

.dropdown-item-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.dropdown-item:hover {
  color: #0079c1;
  text-decoration: underline;
  background: transparent;
}

.dropdown-item calcite-icon {
  color: inherit;
  flex-shrink: 0;
}

/* Selected example in dropdown: distinguished by brand color, font-weight, and checkmark */
.dropdown-item.active {
  color: #0079c1;
  font-weight: 600;
  background: transparent;
}

.selected-indicator {
  display: none;
  color: #0079c1;
  margin-left: auto;
  flex-shrink: 0;
}

.dropdown-item.active .selected-indicator {
  display: inline-flex;
}

/* Main Content Area */
main#app {
  min-height: 500px;
  position: relative;
}

/* Accommodate ArcGIS Calcite Shell and full-viewport examples */
main#app:has(calcite-shell),
main#app:has(.content-panel) {
  min-height: calc(100vh - 140px);
}

calcite-shell {
  position: relative;
  min-height: calc(100vh - 140px);
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

#mapEl {
  width: 100%;
  height: 100%;
  min-height: 500px;
}

/* Learner Layout */
/* Component Pills Navigation */
.component-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 4px 0;
}

.pill-btn {
  background: #ffffff;
  color: #333333;
  border: 1px solid #dcdcdc;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pill-btn:hover {
  border-color: #0079c1;
  color: #0079c1;
  background: #f0f7fc;
}

.pill-btn.active {
  background: #0079c1;
  color: #ffffff;
  border-color: #0079c1;
  box-shadow: 0 2px 4px rgba(0, 121, 193, 0.25);
}

/* Two-Column Split Layout for Learner */
.learner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 24px;
}

@media (max-width: 960px) {
  .learner-grid {
    grid-template-columns: 1fr;
  }
}

.learner-column {
  background: #ffffff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
}

.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e1e6eb;
}

.column-header h3 {
  margin: 0;
  font-size: 16px;
  color: #1e1e1e;
  display: flex;
  align-items: center;
  gap: 8px;
}

.component-tag {
  background: #e8f5ff;
  color: #0079c1;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

/* Live Component Stage */
.live-stage {
  flex: 1;
  background: #fbfbfb;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  padding: 24px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  overflow: auto;
}

/* Code Viewer & Copy */
.code-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.code-view {
  flex: 1;
  margin: 0;
  padding: 16px;
  background: #1e1e1e;
  color: #d4d4d4;
  border-radius: 6px;
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-y: auto;
  min-height: 280px;
  max-height: 480px;
}

.copy-btn {
  background: #28a745;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s ease;
}

.copy-btn:hover {
  background: #218838;
}

.copy-btn.copied {
  background: #0079c1;
}

/* Component Catalog Grid */
.catalog-section {
  background: #ffffff;
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.catalog-section h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: #1e1e1e;
  border-bottom: 2px solid #e1e6eb;
  padding-bottom: 10px;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.catalog-card {
  background: #fbfbfb;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.catalog-card:hover {
  border-color: #0079c1;
  background: #f0f7fc;
  transform: translateY(-1px);
}

.catalog-card.active {
  border-color: #0079c1;
  background: #e8f5ff;
  box-shadow: 0 0 0 1px #0079c1;
}

.catalog-card-title {
  font-weight: 600;
  font-size: 14px;
  color: #151515;
}

.catalog-card-desc {
  font-size: 12px;
  color: #666666;
  line-height: 1.4;
}

/* Working Canvas (Open Canvas for User) */
.working-canvas {
  background: #ffffff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.working-header {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 2px solid #e1e6eb;
}

.working-header h2 {
  margin: 0 0 6px 0;
  font-size: 22px;
  color: #151515;
}

.working-header p {
  margin: 0;
  color: #666666;
  font-size: 14px;
}

.canvas-workspace {
  background: #fafbfc;
  border: 2px dashed #d0d7de;
  border-radius: 8px;
  padding: 32px 24px;
  min-height: 400px;
}

.empty-state {
  text-align: center;
  max-width: 480px;
  margin: 40px auto;
  color: #555555;
}

.empty-state h3 {
  margin: 12px 0 8px 0;
  color: #1e1e1e;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

.empty-state code {
  background: #eef1f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #0079c1;
}
