/* === CSS Custom Properties (Dark Theme) === */
:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-tertiary: #242836;
  --bg-hover: #2a2f3e;
  --bg-card: #1e2230;

  --text-primary: #e4e6ed;
  --text-secondary: #9ca0ad;
  --text-muted: #6b7084;

  --border-color: #2d3148;
  --border-light: #383d54;

  --accent: #6c5ce7;
  --accent-hover: #7f71f0;
  --accent-subtle: #6c5ce720;

  --magic-glow: #f39c12;
  --magic-subtle: #f39c1218;

  --danger: #e74c3c;
  --danger-hover: #c0392b;
  --success: #2ecc71;
  --warning: #f39c12;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);

  --sidebar-width: 240px;
  --topbar-height: 56px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --transition: 150ms ease;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

/* === Layout === */
.app-layout {
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
  padding-top: var(--topbar-height);
}

.main-content {
  flex: 1;
  padding: 24px 32px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* === Top Bar === */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  z-index: 100;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  white-space: nowrap;
}

.logo:hover { color: var(--accent); }

.logo-icon {
  font-size: 1.3rem;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
}

.logo-icon svg { width: 20px; height: 20px; }

.search-container {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.search-container input {
  width: 100%;
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition);
}

.search-container input:focus { border-color: var(--accent); }

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-top: 4px;
  max-height: 400px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.top-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: all var(--transition);
}

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

.nav-link svg { width: 14px; height: 14px; flex-shrink: 0; }

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 16px 0;
  overflow-y: auto;
  height: calc(100vh - var(--topbar-height));
  position: sticky;
  top: var(--topbar-height);
  flex-shrink: 0;
}

.sidebar-header {
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 8px;
}

.world-name {
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.world-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav-section { margin-bottom: 4px; }

.nav-section-label {
  padding: 12px 16px 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all var(--transition);
  border-left: 2px solid transparent;
}

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

.sidebar-link.active {
  background: var(--accent-subtle);
  color: var(--accent);
  border-left-color: var(--accent);
}

.sidebar-icon {
  width: 18px;
  text-align: center;
  font-size: 0.8rem;
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-icon svg { width: 16px; height: 16px; }

.sidebar-count {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-link.active .sidebar-count {
  background: var(--accent)30;
  color: var(--accent);
}

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

.page-header h1 { margin: 0; }
.page-header h1 svg { vertical-align: -3px; }

.subtitle {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 0.9rem;
}

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

/* === Breadcrumbs === */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--text-primary); }
.breadcrumbs .sep { opacity: 0.4; }

/* === Section Title === */
.section-title {
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

/* === Utilities === */
.text-muted { color: var(--text-muted); font-size: 0.8rem; }
.mb-4 { margin-bottom: 24px; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .page-header { flex-direction: column; }
  .top-nav { display: none; }
  .search-container { max-width: 100%; }
}

@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .main-content { padding: 16px 20px; }
}
