/* ══════════════════════════════════════════════════════
   Laravel Cheat Sheet — Design System
   ══════════════════════════════════════════════════════ */

/* ─── TOKENS ──────────────────────────────────────────── */
:root {
  --bg:           #f8fafc;
  --bg-surface:   #ffffff;
  --bg-raised:    #f1f5f9;
  --bg-hover:     #e8edf3;
  --border:       #e2e8f0;
  --border-soft:  #f1f5f9;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --text-subtle:  #94a3b8;
  --accent:       #ef4444;
  --accent-light: #fff1f1;
  --accent-dark:  #dc2626;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:    0 8px 30px rgba(0,0,0,.12);
  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --sidebar-w:    272px;
  --sidebar-w-sm: 64px;
  --topbar-h:     60px;
  --diff-beginner:     #10b981;
  --diff-intermediate: #f59e0b;
  --diff-advanced:     #ef4444;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="dark"] {
  --bg:          #0d1117;
  --bg-surface:  #161b22;
  --bg-raised:   #1c2128;
  --bg-hover:    #262d36;
  --border:      #30363d;
  --border-soft: #21262d;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --text-subtle: #6e7681;
  --accent:      #f87171;
  --accent-light:#2d1515;
  --shadow-sm:   0 1px 2px rgba(0,0,0,.3);
  --shadow-md:   0 4px 12px rgba(0,0,0,.4);
  --shadow-lg:   0 8px 30px rgba(0,0,0,.5);
}

/* ─── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

/* ─── LAYOUT ──────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width .2s ease, min-width .2s ease;
  overflow: hidden;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar.collapsed {
  width: var(--sidebar-w-sm);
  min-width: var(--sidebar-w-sm);
}

/* Sidebar header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-soft);
  height: var(--topbar-h);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.logo-icon { font-size: 22px; flex-shrink: 0; }

.logo-text {
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--text);
  white-space: nowrap;
  opacity: 1;
  transition: opacity .15s;
}

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

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: background .15s, color .15s, transform .2s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg-raised); color: var(--text); }
.collapsed .sidebar-toggle { transform: rotate(180deg); }

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-divider { height: 1px; background: var(--border-soft); margin: 8px 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  color: var(--text-muted);
  transition: background .12s, color .12s;
  white-space: nowrap;
  overflow: hidden;
  font-size: .85rem;
}

.nav-item:hover { background: var(--bg-raised); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }

.nav-icon { font-size: 1.1rem; flex-shrink: 0; width: 22px; text-align: center; }

.nav-label {
  flex: 1;
  opacity: 1;
  transition: opacity .12s;
  overflow: hidden;
  text-overflow: ellipsis;
}
.collapsed .nav-label { opacity: 0; width: 0; }

.nav-count {
  font-size: .72rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--text-subtle);
  flex-shrink: 0;
  opacity: 1;
  transition: opacity .12s;
}
.collapsed .nav-count { opacity: 0; width: 0; padding: 0; }

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

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 100%;
  font-size: .85rem;
  transition: background .12s;
  white-space: nowrap;
  overflow: hidden;
}
.theme-toggle:hover { background: var(--bg-raised); }

.theme-icon-light, .theme-icon-dark { font-size: 1rem; flex-shrink: 0; }
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="dark"]  .theme-icon-light { display: none; }

.theme-label {
  opacity: 1;
  transition: opacity .12s;
}
.collapsed .theme-label { opacity: 0; width: 0; }

/* ─── MAIN ────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Top bar */
.top-bar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  flex: 1;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
}

/* Search bar (trigger) */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color .15s, box-shadow .15s;
  min-width: 220px;
  user-select: none;
}
.search-bar:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

.search-placeholder { flex: 1; font-size: .85rem; }

.search-kbd {
  font-family: var(--font-mono);
  font-size: .7rem;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-subtle);
}

/* Main content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ─── PAGE HEADER ─────────────────────────────────────── */
.page-header { margin-bottom: 32px; }
.page-title  { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: .9rem; color: var(--text-muted); margin-top: 6px; }

/* ─── CATEGORY SECTION ────────────────────────────────── */
.category-section { margin-bottom: 52px; }

.category-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--cat-color, var(--accent));
}

.category-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-icon { font-size: 1.4rem; }

.category-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.category-badge {
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--cat-color, var(--accent));
  color: #fff;
}

.category-desc {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── FEATURES GRID ───────────────────────────────────── */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

/* ─── FEATURE CARD ────────────────────────────────────── */
.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: border-color .15s, box-shadow .15s;
}
.feature-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.feature-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  animation: pulse-highlight 2.5s ease-out forwards;
}

@keyframes pulse-highlight {
  0%   { box-shadow: 0 0 0 4px var(--accent-light); }
  100% { box-shadow: var(--shadow-sm); border-color: var(--border); }
}

.feature-header { margin-bottom: 10px; }

.feature-name {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.feature-meta { display: flex; flex-wrap: wrap; gap: 6px; }

/* ─── BADGES ──────────────────────────────────────────── */
.badge {
  font-size: .68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.badge-beginner     { background: #d1fae5; color: #065f46; }
.badge-intermediate { background: #fef3c7; color: #92400e; }
.badge-advanced     { background: #fee2e2; color: #991b1b; }

[data-theme="dark"] .badge-beginner     { background: #052e16; color: #6ee7b7; }
[data-theme="dark"] .badge-intermediate { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .badge-advanced     { background: #450a0a; color: #fca5a5; }

.badge-type {
  background: var(--bg-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-version {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid currentColor;
  border-opacity: .3;
}

/* ─── FEATURE DESCRIPTION ─────────────────────────────── */
.feature-desc {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 12px;
}

/* ─── TAGS ────────────────────────────────────────────── */
.feature-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}

.tag {
  font-size: .68rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--tag-color) 15%, transparent);
  color: var(--tag-color);
  border: 1px solid color-mix(in srgb, var(--tag-color) 30%, transparent);
}

/* ─── CODE BLOCKS ─────────────────────────────────────── */
.code-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  overflow: hidden;
}

.code-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: .8rem;
  color: var(--text-muted);
  background: var(--bg-raised);
  user-select: none;
  list-style: none;
  transition: background .12s;
}
.code-summary:hover { background: var(--bg-hover); }
.code-summary::-webkit-details-marker { display: none; }

.code-lang {
  font-family: var(--font-mono);
  font-size: .65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.lang-php   { background: #4f46e5; color: #fff; }
.lang-blade { background: #ef4444; color: #fff; }
.lang-shell { background: #16a34a; color: #fff; }
.lang-env   { background: #d97706; color: #fff; }
.lang-json  { background: #0ea5e9; color: #fff; }

.code-desc {
  font-size: .78rem;
  color: var(--text-muted);
  padding: 8px 12px 0;
  background: var(--bg-surface);
}

.code-pre {
  margin: 0;
  padding: 14px 16px;
  background: var(--bg-raised);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .78rem;
  line-height: 1.7;
  color: var(--text);
  scrollbar-width: thin;
}

/* ─── GLOSSARY ────────────────────────────────────────── */
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.glossary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: border-color .15s;
}
.glossary-card:hover { border-color: var(--accent); }

.glossary-term {
  font-size: .95rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.glossary-def {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* ─── SEARCH OVERLAY ──────────────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}

.search-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.search-modal {
  width: 660px;
  max-width: calc(100vw - 40px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(-10px);
  transition: transform .15s;
}

.search-overlay.open .search-modal { transform: translateY(0); }

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.search-icon { color: var(--text-muted); flex-shrink: 0; }

.search-input {
  flex: 1;
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text);
  outline: none;
}
.search-input::placeholder { color: var(--text-subtle); }

.search-close {
  font-family: var(--font-mono);
  font-size: .7rem;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-raised);
  color: var(--text-subtle);
  cursor: pointer;
}

.search-results {
  max-height: 480px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.search-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-subtle);
  text-align: center;
  gap: 8px;
}

.search-empty-icon { font-size: 2rem; }
.search-empty-hint { font-size: .8rem; }

.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  transition: background .1s;
}
.search-result-item:hover,
.search-result-item.focused { background: var(--bg-raised); }
.search-result-item:last-child { border-bottom: none; }

.result-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 2px; }

.result-body { flex: 1; min-width: 0; }

.result-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.result-name mark {
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 2px;
}

.result-desc {
  font-size: .77rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-meta {
  display: flex;
  gap: 6px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.result-category-tag {
  font-size: .65rem;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--bg-hover);
  color: var(--text-subtle);
}

/* ─── SEARCH SECTIONS ─────────────────────────────────── */
.search-section-header {
  padding: 8px 20px 4px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-subtle);
  background: var(--bg-raised);
}

/* ─── SIDEBAR OVERLAY (mobile) ────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}

/* ─── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    min-width: var(--sidebar-w) !important;
    transition: transform .25s ease;
    z-index: 100;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

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

  .mobile-menu-btn { display: flex; }
  .sidebar-toggle  { display: none; }
  .collapsed .nav-label, .collapsed .nav-count { opacity: 1; width: auto; }

  .main-content { padding: 20px 16px; }
  .search-bar { min-width: unset; }
  .search-placeholder { display: none; }
  .features-grid { grid-template-columns: 1fr; }
  .glossary-grid  { grid-template-columns: 1fr; }
}

/* ─── UTILITIES ───────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
