/* ═══════════════════════════════════════════════════════════════════════════
   AI CHEATSHEET — Design System
   Inspiré du Symfony CheatSheet — palette moderne IA
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── TOKENS CLAIR ─── */
:root {
  --bg:            #f8fafc;
  --bg-surface:    #ffffff;
  --bg-raised:     #f1f5f9;
  --sidebar-bg:    #ffffff;
  --sidebar-w:     272px;
  --sidebar-w-sm:  64px;

  --text:          #1e293b;
  --text-muted:    #64748b;
  --text-faint:    #94a3b8;

  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  --accent:        #6366f1;
  --accent-light:  #eef2ff;
  --accent-hover:  #4f46e5;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:  0 20px 60px rgba(0,0,0,.12);

  --transition: 200ms cubic-bezier(.4,0,.2,1);
}

/* ─── TOKENS SOMBRE ─── */
[data-theme="dark"] {
  --bg:            #0d1117;
  --bg-surface:    #161b22;
  --bg-raised:     #1c2333;
  --sidebar-bg:    #161b22;

  --text:          #e6edf3;
  --text-muted:    #8b949e;
  --text-faint:    #484f58;

  --border:        #30363d;
  --border-strong: #3d444d;

  --accent:        #818cf8;
  --accent-light:  #1a1f3a;
  --accent-hover:  #6366f1;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.3);
  --shadow-md:  0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:  0 20px 60px rgba(0,0,0,.6);
}

/* ═══════════════════════════════════════════════════════ RESET & BASE */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════ LAYOUT */
.app { display: flex; height: 100vh; overflow: hidden; }
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ═══════════════════════════════════════════════════════ SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition), background var(--transition);
  overflow: hidden;
  flex-shrink: 0;
  z-index: 100;
}
.sidebar.collapsed { width: var(--sidebar-w-sm); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.brand-icon { font-size: 1.5rem; flex-shrink: 0; }
.brand-text {
  font-size: .875rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition);
  letter-spacing: -.02em;
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-count,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-divider,
.sidebar.collapsed .sidebar-footer .nav-label { opacity: 0; width: 0; overflow: hidden; }

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

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.nav-section-title {
  font-size: .65rem; font-weight: 600; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 4px 8px; margin-top: 4px;
  white-space: nowrap; transition: opacity var(--transition);
}
.nav-divider {
  height: 1px; background: var(--border); margin: 6px 0;
  transition: opacity var(--transition);
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; border: none; cursor: pointer;
  border-radius: var(--radius-md); background: none;
  color: var(--text-muted); text-align: left;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap; 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: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; transition: opacity var(--transition); }
.nav-count {
  font-size: .7rem; font-weight: 600; color: var(--text-faint);
  background: var(--bg-raised); padding: 1px 6px; border-radius: 99px;
  transition: opacity var(--transition);
}
.nav-item.active .nav-count { background: var(--accent-light); color: var(--accent); }

.sidebar-footer {
  padding: 8px; border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════ TOPBAR */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 56px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  transition: background var(--transition);
}
.topbar-menu-btn {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 6px; border-radius: var(--radius-sm);
}
.topbar-menu-btn svg { width: 18px; height: 18px; }

.search-bar {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 0 12px; max-width: 480px;
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: text;
}
.search-bar:focus-within {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.search-icon { width: 15px; height: 15px; color: var(--text-faint); flex-shrink: 0; }
.search-input {
  flex: 1; border: none; background: none; outline: none;
  font-size: .85rem; color: var(--text); padding: 8px 0;
}
.search-input::placeholder { color: var(--text-faint); }
.search-kbd {
  font-size: .65rem; padding: 2px 6px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-faint);
  font-family: inherit; flex-shrink: 0;
}

.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.theme-toggle {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 8px 10px; border-radius: var(--radius-md);
  font-size: .85rem; width: 100%;
  transition: background var(--transition), color var(--transition);
}
.theme-toggle:hover { background: var(--bg-raised); color: var(--text); }
.theme-icon { font-size: .95rem; }
[data-theme="dark"] .theme-icon--light { display: none; }
[data-theme="light"] .theme-icon--dark,
:root:not([data-theme]) .theme-icon--dark { display: none; }

/* ═══════════════════════════════════════════════════════ MAIN CONTENT */
.main-content {
  flex: 1; overflow-y: auto; padding: 32px 32px 64px;
  scroll-behavior: smooth;
}
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════ HERO */
.page-hero {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.page-title {
  font-size: 2rem; font-weight: 800; color: var(--text);
  letter-spacing: -.04em; line-height: 1.2; margin-bottom: 8px;
}
.page-title-accent { color: var(--accent); }
.page-subtitle { font-size: .95rem; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════ CATEGORY SECTION */
.category-section {
  margin-bottom: 48px;
  scroll-margin-top: 24px;
}
.category-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px; padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--cat-color, var(--accent));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.category-header-icon { font-size: 1.5rem; }
.category-header-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.category-header-desc { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.category-header-count {
  margin-left: auto; font-size: .75rem; font-weight: 700;
  background: var(--bg-raised); color: var(--text-muted);
  padding: 3px 10px; border-radius: 99px;
}

/* ═══════════════════════════════════════════════════════ TOOLS GRID */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* ═══════════════════════════════════════════════════════ TOOL CARD */
.tool-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
}
.tool-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.tool-card-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.tool-name {
  font-size: 1rem; font-weight: 700; color: var(--text); line-height: 1.3;
}
.tool-maker {
  font-size: .75rem; color: var(--text-faint); font-weight: 500;
}
.tool-link {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--bg-raised); color: var(--text-muted);
  text-decoration: none; flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.tool-link:hover { background: var(--accent-light); color: var(--accent); }
.tool-link svg { width: 14px; height: 14px; }

.tool-desc { font-size: .85rem; color: var(--text-muted); line-height: 1.55; }

.tool-usecases {
  display: flex; flex-wrap: wrap; gap: 5px;
}
.usecase-badge {
  font-size: .7rem; font-weight: 600; padding: 2px 8px;
  border-radius: 99px; background: var(--accent-light); color: var(--accent);
}

.tool-pricing {
  font-size: .75rem; color: var(--text-faint);
  background: var(--bg-raised); border-radius: var(--radius-sm);
  padding: 6px 10px; line-height: 1.4;
}
.tool-pricing-label { font-weight: 600; color: var(--text-muted); }

.tool-tips {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.tips-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint); margin-bottom: 2px;
}
.tip-item {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: .8rem; color: var(--text-muted); line-height: 1.45;
}
.tip-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0; margin-top: 6px;
}

.tool-tags {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.tool-tag {
  font-size: .65rem; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 99px;
  padding: 1px 7px;
}

/* ═══════════════════════════════════════════════════════ SEARCH OVERLAY */
.search-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 80px;
}
.search-overlay-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
}
.search-overlay-panel {
  position: relative; z-index: 1;
  width: 100%; max-width: 600px; margin: 0 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-overlay-input-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.search-overlay-input-wrap svg { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }
.search-overlay-input {
  flex: 1; border: none; background: none; outline: none;
  font-size: 1rem; color: var(--text);
}
.search-overlay-close {
  background: none; border: none; cursor: pointer; padding: 0;
}
.search-overlay-close kbd {
  font-size: .7rem; padding: 2px 7px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-faint);
  font-family: inherit;
}

.search-results { max-height: 420px; overflow-y: auto; }
.search-hint { padding: 20px; font-size: .85rem; color: var(--text-muted); text-align: center; }
.search-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.selected { background: var(--accent-light); }
.search-result-icon { font-size: 1.1rem; flex-shrink: 0; }
.search-result-main { flex: 1; min-width: 0; }
.search-result-name { font-size: .9rem; font-weight: 600; color: var(--text); }
.search-result-cat { font-size: .75rem; color: var(--text-muted); }
.search-result-desc { font-size: .78rem; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-no-results { padding: 32px 20px; text-align: center; color: var(--text-muted); font-size: .9rem; }

/* ═══════════════════════════════════════════════════════ EMPTY STATE */
.empty-state {
  text-align: center; padding: 64px 32px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.empty-state p { font-size: .875rem; }

/* ═══════════════════════════════════════════════════════ MOBILE */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform var(--transition), width var(--transition);
    width: var(--sidebar-w) !important;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .topbar-menu-btn { display: flex; }
  .main-content { padding: 20px 16px 48px; }
  .tools-grid { grid-template-columns: 1fr; }
  .search-kbd { display: none; }
  .page-title { font-size: 1.5rem; }
}

/* ═══════════════════════════════════════════════════════ HIGHLIGHT */
mark {
  background: rgba(99,102,241,.2);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
}
