:root {
  --bg: #1a1c20;
  --bg-elev: #25282e;
  --bg-hover: #2f333b;
  --border: #3a3f48;
  --text: #ffffff;
  --muted: #a9b0bb;
  --accent: #00e5ff;
  --accent-dim: #00b8d4;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* Topbar / search */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 16px 24px 8px;
  transition: all .35s ease;
}
.logo img { display: block; }
.logo-small { display: none; height: 36px; width: 36px; }
.logo-full { max-width: 300px; width: 70vw; height: auto; }
.search-form { display: flex; flex-direction: column; flex: 1; max-width: 692px; }
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: box-shadow .2s, border-color .2s;
}
.search-box:hover { background: var(--bg-hover); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0, 229, 255, .25); }
.search-icon { width: 22px; height: 22px; fill: var(--muted); margin-left: 18px; flex: none; }
.search-box input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 1rem;
  padding: 13px 18px 13px 12px;
  min-width: 0;
}
.search-box input::-webkit-search-cancel-button { filter: invert(1); }
.search-actions { display: none; gap: 12px; justify-content: center; margin-top: 28px; }
.btn {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--bg-elev);
  border-radius: 6px;
  padding: 10px 18px;
  font-size: .9rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); }

/* Home state */
body.home .topbar {
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  flex: 1;
  padding-bottom: 12vh;
}
body.home .search-form { width: 92vw; }
body.home .search-box { padding: 6px 0; box-shadow: 0 1px 6px rgba(0, 0, 0, .4); }
body.home .search-actions { display: flex; }
body.home .filters,
body.home .content { display: none; }

/* Results state */
body.results .topbar {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
body.results .logo-full { display: none; }
body.results .logo-small { display: block; }
body.results .search-box input { padding: 10px 18px 10px 12px; }

.filters { border-bottom: 1px solid var(--border); padding: 0 24px 0 96px; overflow-x: auto; }
.filters ul { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; white-space: nowrap; }
.filters a {
  display: block;
  padding: 12px 14px;
  color: var(--muted);
  border-bottom: 3px solid transparent;
}
.filters a:hover { color: var(--text); text-decoration: none; }
.filters a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Results */
.content { flex: 1; padding: 20px 24px 40px 96px; max-width: 900px; width: 100%; }
.status-message {
  background: rgba(255, 82, 82, .12);
  border: 1px solid #ff5252;
  color: #ffb3b3;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.status-message.info { background: var(--bg-elev); border-color: var(--border); color: var(--muted); }
.result { margin-bottom: 28px; max-width: 652px; }
.result-url {
  color: var(--muted);
  font-size: .82rem;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-title { font-size: 1.2rem; line-height: 1.3; display: inline-block; }
.result-snippet { color: #d5d9e0; font-size: .92rem; line-height: 1.55; margin: 4px 0 0; overflow-wrap: anywhere; }

/* Loader */
.loader { display: flex; gap: 8px; justify-content: center; padding: 40px 0; }
.loader span {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  animation: bounce 1s infinite ease-in-out both;
}
.loader span:nth-child(2) { animation-delay: .15s; }
.loader span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(.4); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Pagination */
.pagination { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 16px; }
.pagination a, .pagination span {
  min-width: 38px;
  text-align: center;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--accent);
}
.pagination a:hover { background: var(--bg-hover); text-decoration: none; }
.pagination .current { background: var(--accent); color: #0b0d10; font-weight: 600; }
.pagination .disabled { color: var(--muted); opacity: .5; }

.footer {
  padding: 14px 24px;
  background: #14161a;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .85rem;
}

/* Home footer (Google-like) */
body.home .footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.footer nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--accent); }
.home-top { position: absolute; top: 0; right: 0; display: flex; gap: 18px; padding: 16px 24px; font-size: .9rem; }
.home-top a { color: var(--text); }

/* Static pages */
body.page .topbar { border-bottom: 1px solid var(--border); padding-bottom: 12px; }
body.page .logo-small { display: block; }
.page-main { flex: 1; width: 100%; max-width: 820px; margin: 0 auto; padding: 36px 24px 56px; line-height: 1.7; }
.page-main h1 { font-size: 2rem; font-weight: 500; margin: 0 0 8px; }
.page-main h2 { font-size: 1.25rem; font-weight: 500; margin: 32px 0 8px; color: var(--accent); }
.page-main p, .page-main li { color: #d5d9e0; }
.page-main .lead { color: var(--muted); font-size: 1.1rem; margin-bottom: 24px; }
.page-main .card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 20px; }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.card:hover { border-color: var(--accent); }
.page-main label { display: block; margin: 16px 0 6px; color: var(--muted); }
.page-main input[type="text"], .page-main input[type="search"], .page-main input[type="url"], .page-main input[type="email"], .page-main select, .page-main textarea {
  width: 100%; background: var(--bg-elev); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font: inherit;
}
.page-main input:focus, .page-main select:focus, .page-main textarea:focus { outline: 0; border-color: var(--accent); }
.page-main .btn { margin-top: 20px; }

/* Error pages */
body.error .page-main { max-width: 700px; margin-top: 8vh; }
.error-code { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.error-title { font-size: 1.4rem; margin: 6px 0 14px; }
.error-text { color: #d5d9e0; }

/* Auth widget */
.auth-widget { position: relative; margin-left: auto; display: flex; align-items: center; }
.home-top .auth-widget { margin-left: 0; }
.auth-login {
  border: 1px solid var(--accent); color: var(--accent); border-radius: 999px;
  padding: 7px 16px; font-size: .85rem; white-space: nowrap;
}
.auth-login:hover { background: var(--accent); color: #0b0d10; text-decoration: none; }
.auth-toggle { background: none; border: 2px solid transparent; border-radius: 50%; padding: 0; cursor: pointer; }
.auth-toggle:hover, .auth-toggle:focus-visible { border-color: var(--accent); outline: 0; }
.auth-avatar { width: 36px; height: 36px; border-radius: 50%; display: block; object-fit: cover; }
.auth-initial { background: var(--accent-dim); color: #0b0d10; font-weight: 700; line-height: 36px; text-align: center; }
.auth-panel {
  position: absolute; right: 0; top: 46px; z-index: 20; min-width: 260px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.auth-panel[hidden] { display: none; }
.auth-name { font-weight: 600; }
.auth-email { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.auth-panel a, .auth-logout { font-size: .9rem; padding: 6px 0; }
.auth-logout { background: none; border: 0; border-top: 1px solid var(--border); color: var(--text); text-align: left; cursor: pointer; margin-top: 4px; padding-top: 10px; }
.auth-logout:hover { color: var(--accent); }
.auth-banner { background: #3a1e22; color: #ffb3b3; border-bottom: 1px solid #ff5252; padding: 10px 24px; text-align: center; }

.role-badge { align-self: flex-start; font-size: .75rem; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); background: var(--bg-hover); }
.role-moderateur { border-color: #4caf50; color: #9be29f; }
.role-developpeur { border-color: #b388ff; color: #d1b8ff; }
.role-administrateur { border-color: #ff9800; color: #ffcc80; }
.role-fondateur { border-color: var(--accent); color: var(--accent); }

@media (max-width: 700px) {
  .topbar { gap: 14px; padding: 12px; }
  body.home .topbar { padding-bottom: 8vh; }
  .filters, .content { padding-left: 14px; padding-right: 14px; }
  .search-actions { flex-wrap: wrap; }
}
