/* ===================================================================
 * VCF Architectures & Blueprints Library
 * Design aligné sur VCF Decision Library (hld.vcfninja.cloud)
 * =================================================================== */

:root {
  /* ---- Palette Decision Library ---- */
  --navy:        #1B2942;
  --navy-2:      #253550;
  --navy-3:      #334259;
  --cyan:        #5AC8DA;
  --cyan-2:      #3B8FA5;
  --cyan-3:      #8ADFE9;
  --cyan-bg:     #E0F5F8;
  --magenta:     #EC4899;
  --magenta-2:   #DB2777;
  --indigo:      #6366F1;
  --indigo-bg:   #EEF2FF;
  --success:     #22C55E;
  --success-bg:  #DCFCE7;
  --success-tx:  #166534;
  --warning:     #F59E0B;
  --warning-bg:  #FEF3C7;
  --warning-tx:  #92400E;
  --danger:      #EF4444;
  --danger-bg:   #FEE2E2;
  --danger-tx:   #991B1B;
  --paper:       #FFFFFF;
  --bg:          #F8FAFC;
  --border:      #E2E8F0;
  --border-2:    #CBD5E1;
  --text:        #1E293B;
  --text-2:      #475569;
  --muted:       #64748B;
  --muted-2:     #94A3B8;

  /* ---- Type ---- */
  --f-sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --f-mono:  "JetBrains Mono", "SF Mono", Menlo, monospace;

  /* ---- Rythmes ---- */
  --r-1: 4px;  --r-2: 8px;  --r-3: 12px; --r-4: 16px;
  --r-5: 20px; --r-6: 24px; --r-7: 32px; --r-8: 48px;

  /* ---- UI ---- */
  --topbar-h: 56px;
  --sidebar-w: 272px;
  --card-radius: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow:    0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.08);

  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ---- Reset ---- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--f-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; background: none; border: 0; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ================================================================ */
/*  TOPBAR                                                          */
/* ================================================================ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  background: var(--navy);
  color: white;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--r-5);
  padding: 0 var(--r-6);
  box-shadow: 0 1px 0 rgba(0,0,0,0.15);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: white;
}
.brand-mark { width: 36px; height: 36px; flex-shrink: 0; }
.brand-title-wrap {
  display: flex; align-items: center; gap: var(--r-2);
  line-height: 1.15;
}
.brand-title {
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: -0.005em;
  color: white;
}
.brand-version {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--muted-2);
  letter-spacing: 0.02em;
}
.brand-badge {
  display: inline-flex; align-items: center;
  height: 22px;
  padding: 0 10px;
  background: var(--cyan);
  color: white;
  border-radius: 11px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Nav */
.topnav {
  display: flex; align-items: center; gap: var(--r-5);
}
.topnav-link {
  color: rgba(255,255,255,0.75);
  font-size: 13.5px;
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color 150ms var(--ease), border-color 150ms var(--ease);
}
.topnav-link:hover { color: white; }
.topnav-link.active { color: white; border-bottom-color: var(--cyan); }

/* Search dans la topnav */
.search-wrap {
  position: relative;
  max-width: 420px; width: 100%;
}
.search-input {
  width: 100%;
  height: 34px;
  padding: 0 32px 0 34px;
  background: rgba(255,255,255,0.10);
  color: white;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  font-size: 13.5px;
  transition: background 150ms var(--ease), border-color 150ms var(--ease);
}
.search-input::placeholder { color: rgba(255,255,255,0.55); }
.search-input:focus {
  outline: none;
  background: rgba(255,255,255,0.16);
  border-color: var(--cyan);
}
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: rgba(255,255,255,0.6);
  pointer-events: none;
}
.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px;
  border-radius: 3px;
  color: rgba(255,255,255,0.7);
  display: none;
  align-items: center; justify-content: center;
}
.search-clear:hover { background: rgba(255,255,255,0.12); color: white; }
.search-wrap.has-value .search-clear { display: flex; }
.search-kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 3px;
  padding: 1px 5px;
  pointer-events: none;
}
.search-wrap.has-value .search-kbd { display: none; }

.view-toggle {
  display: flex;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 2px;
}
.view-btn {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  border-radius: 4px;
  transition: all 150ms var(--ease);
  display: flex; align-items: center; gap: 5px;
}
.view-btn:hover { color: white; }
.view-btn.active {
  background: var(--cyan);
  color: white;
}

/* ================================================================ */
/*  LAYOUT                                                          */
/* ================================================================ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--topbar-h));
}

/* ---- Sidebar ---- */
.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: white;
  border-right: 1px solid var(--border);
  padding: var(--r-5) 0;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.sidebar-title {
  padding: 0 var(--r-5);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--r-3);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-section {
  padding: 0 var(--r-3) var(--r-5);
}
.sidebar-section-title {
  padding: var(--r-2) var(--r-3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.filter-item, .cat-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  transition: background 120ms var(--ease);
  text-align: left;
  gap: 6px;
}
.filter-item:hover, .cat-toggle:hover { background: var(--bg); }
.filter-item.active, .cat-toggle.active {
  background: var(--cyan-bg);
  color: var(--cyan-2);
  font-weight: 500;
}
.filter-item.active .cat-count,
.cat-toggle.active .cat-count { color: var(--cyan-2); }
.cat-name, .cat-toggle-label { flex: 1; }
.cat-count {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  padding: 2px 6px;
  background: var(--bg);
  border-radius: 10px;
}
.filter-item.active .cat-count,
.cat-toggle.active .cat-count { background: white; }
.cat-toggle .chev {
  width: 12px; height: 12px;
  transition: transform 150ms var(--ease);
  color: var(--muted);
  flex-shrink: 0;
}
.cat-group.open .chev { transform: rotate(90deg); }
.cat-children { display: none; padding: 4px 0 4px 22px; }
.cat-group.open .cat-children { display: block; }

/* ================================================================ */
/*  MAIN                                                            */
/* ================================================================ */
.main { padding: var(--r-6) var(--r-6) var(--r-8); min-width: 0; }

.results-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--r-4);
  margin-bottom: var(--r-5);
  padding-bottom: var(--r-4);
  border-bottom: 1px solid var(--border);
}
.results-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.results-title .path {
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}
.results-count {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: var(--r-3);
}
.results-count strong { color: var(--text); font-weight: 600; }

.reset-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--magenta);
  background: transparent;
  border: 1px solid var(--magenta);
  border-radius: 5px;
  transition: all 150ms var(--ease);
}
.reset-btn:hover { background: var(--magenta); color: white; }

/* ---- Grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: var(--r-4);
}

/* ---- Card ---- */
.card {
  position: relative;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), border-color 180ms var(--ease);
  display: flex; flex-direction: column;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--cyan);
}
.card:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.card-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #F1F5F9;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.card-thumb img {
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center;
  padding: 10px;
  background: white;
}
.card-thumb.loading::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, #F1F5F9, #F8FAFC, #F1F5F9);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.card-num {
  position: absolute; top: 10px; right: 10px;
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--navy);
  z-index: 3;
  background: rgba(255,255,255,0.92);
  padding: 3px 7px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
}
.card-num::before {
  content: "N°";
  color: var(--muted);
  margin-right: 3px;
  font-size: 9.5px;
}

.card-body {
  padding: var(--r-3) var(--r-3) var(--r-3);
  display: flex; flex-direction: column; gap: var(--r-2);
  flex: 1;
}
.card-eyebrow {
  display: inline-flex; align-items: center;
  align-self: flex-start;
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--indigo);
  background: var(--indigo-bg);
  border-radius: 4px;
}
.card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.005em;
}
.card-meta {
  display: flex; gap: var(--r-3);
  margin-top: auto;
  padding-top: var(--r-2);
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--muted);
}
.card-meta .badge { display: inline-flex; align-items: center; gap: 3px; }
.card-meta .badge.res { color: var(--cyan-2); }
.card-meta .badge.hd::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--success);
}

/* ---- Tree ---- */
.tree-view { display: none; }
.tree-view.active { display: block; }
.grid-view { display: grid; }
.grid-view.hidden { display: none; }

.tree-cat { margin-bottom: var(--r-7); }
.tree-cat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  margin-bottom: var(--r-4);
  background: var(--navy);
  color: white;
  border-radius: 6px;
}
.tree-cat-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.tree-cat-count {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--cyan-3);
}
.tree-section { margin-bottom: var(--r-5); }
.tree-section-title {
  padding: 8px 14px;
  margin-bottom: var(--r-3);
  background: var(--navy-3);
  color: white;
  border-radius: 4px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px;
  font-weight: 600;
}
.tree-section-title .count {
  font-family: var(--f-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  font-weight: 500;
}

/* ---- Empty ---- */
.empty { text-align: center; padding: var(--r-8) var(--r-5); color: var(--muted); }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: var(--r-2); }
.empty-hint { font-size: 13px; color: var(--muted); }

/* ================================================================ */
/*  MODAL                                                           */
/* ================================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.85);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: stretch;
  justify-content: center;
  animation: fadeIn 180ms var(--ease);
}
.modal-backdrop.open { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  display: grid;
  grid-template-columns: 1fr 380px;
  width: 100%;
  height: 100vh;
  background: var(--navy);
}
.modal-viewer {
  position: relative;
  background: #0F1B31;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--navy-2);
}
.modal-viewer img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform 200ms var(--ease);
  background: white;
  padding: 12px;
  border-radius: 4px;
}
.modal-viewer.zoomed img { cursor: zoom-out; transform: scale(1.8); }
.modal-viewer-hint {
  position: absolute; bottom: 16px; left: 16px;
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  background: rgba(0,0,0,0.5);
  padding: 5px 10px;
  border-radius: 4px;
  pointer-events: none;
  font-family: var(--f-mono);
  letter-spacing: 0.02em;
}

.modal-panel {
  background: var(--navy);
  color: white;
  padding: var(--r-6) var(--r-5);
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: var(--r-4);
}
.modal-panel::-webkit-scrollbar { width: 6px; }
.modal-panel::-webkit-scrollbar-thumb { background: var(--navy-3); border-radius: 3px; }

.modal-close, .modal-nav {
  position: absolute; z-index: 10;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  color: white;
  transition: all 150ms var(--ease);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-close { top: 16px; right: 16px; width: 36px; height: 36px; }
.modal-nav  { top: 50%; transform: translateY(-50%); width: 44px; height: 44px; }
.modal-nav.prev { left: 16px; }
.modal-nav.next { right: 16px; }
.modal-close:hover, .modal-nav:hover {
  background: var(--magenta);
  border-color: var(--magenta);
}

.modal-eyebrow {
  display: inline-flex; align-items: center;
  align-self: flex-start;
  padding: 3px 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: white;
  background: var(--indigo);
  border-radius: 4px;
}
.modal-num {
  font-family: var(--f-mono);
  font-weight: 600;
  font-size: 12px;
  color: var(--cyan-3);
  letter-spacing: 0.04em;
}
.modal-num .lbl { color: rgba(255,255,255,0.5); margin-right: 6px; }
.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: white;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.modal-path {
  font-family: var(--f-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  line-height: 1.7;
  letter-spacing: 0.01em;
}
.modal-path .sep { color: var(--cyan); margin: 0 4px; }
.modal-path .leaf { color: white; }

.modal-meta {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--r-3);
  padding: var(--r-4) 0;
  border-top: 1px solid var(--navy-3);
  border-bottom: 1px solid var(--navy-3);
}
.modal-meta-item .lbl {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}
.modal-meta-item .val {
  font-family: var(--f-mono);
  font-size: 13px;
  color: white;
  letter-spacing: 0.01em;
}
.modal-meta-item .val.hi { color: var(--cyan-3); }

.modal-actions {
  display: flex; gap: var(--r-2);
  margin-top: auto;
  padding-top: var(--r-4);
}
.btn {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: 6px;
  color: white;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  transition: all 150ms var(--ease);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: rgba(255,255,255,0.15); }
.btn.primary {
  background: var(--magenta);
  border-color: var(--magenta);
  color: white;
  flex: 1;
  justify-content: center;
}
.btn.primary:hover { background: var(--magenta-2); border-color: var(--magenta-2); }

/* ---- Loader ---- */
.loader {
  display: flex; align-items: center; justify-content: center;
  padding: var(--r-8);
  font-size: 13px;
  color: var(--muted);
}
.loader::before {
  content: "";
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  margin-right: 10px;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Highlight ---- */
mark {
  background: var(--warning-bg);
  color: var(--warning-tx);
  padding: 0 2px;
  border-radius: 2px;
}

/* ================================================================ */
/*  RESPONSIVE                                                      */
/* ================================================================ */
.mobile-menu-btn {
  display: none;
  padding: 6px;
  color: white;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 5px;
  background: rgba(255,255,255,0.08);
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: -100%;
    width: min(320px, 90vw);
    height: calc(100vh - var(--topbar-h));
    transition: left 200ms var(--ease);
    z-index: 30;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .modal { grid-template-columns: 1fr; grid-template-rows: 60vh 1fr; }
  .modal-viewer { border-right: 0; border-bottom: 1px solid var(--navy-2); }
  .brand-badge, .brand-version { display: none; }
  .topnav .topnav-link { display: none; }
  .mobile-menu-btn { display: flex; }
}

@media (max-width: 640px) {
  .main { padding: var(--r-4); }
  .grid { grid-template-columns: 1fr 1fr; gap: var(--r-3); }
  .search-kbd { display: none; }
  .brand-title { font-size: 14px; }
  .results-title { font-size: 17px; }
  .view-btn span { display: none; }
}
