﻿/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  /* overflow-x: hidden; */
}

body.is-loading .cards-grid {
  opacity: 0.6;
  pointer-events: none;
}

body.menu-open {
  overflow: hidden;
}

body.lightbox-open {
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
}

:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 3px;
}

.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;
}

/* Variables */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --panel: #f1f4fb;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #111827;
  --highlight: #2563eb;
  --border: #e5e7eb;
  --shadow: none;
  --radius: 18px;
  --nav-height: 72px;
}

body.theme-dark {
  --bg: #0b1221;
  --card: #0f172a;
  --panel: #111827;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #fbbf24;
  --highlight: #38bdf8;
  --border: #1f2937;
  --shadow: none;
}

/* Layout */
.app-shell {
  min-height: 100vh;
  width: 100%;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  flex-wrap: wrap;
  color: var(--text);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--text);
  display: grid;
  place-items: center;
  color: var(--card);
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.brand-text {
  display: grid;
  gap: 2px;
  font-size: 1.42rem;
  /* color: #e5e7eb; */
}

.brand-text .muted {
  font-size: 0.85rem;
  /* color: #cbd5e1; */
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.nav-links a i {
  width: 18px;
  text-align: center;
}

.nav-links a.active,
.nav-links a:hover {
  background: var(--panel);
  color: var(--text);
  border-color: #e5e7eb;
  transform: translateY(-1px);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.nav-actions .icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border-color: #e5e7eb;
  background: #fff;
  color: var(--text);
}

.nav-actions .profile-avatar {
  width: 34px;
  height: 34px;
}

/* ============= Search ============= */

.Search-bar-container{
  width: 100%;
  margin-bottom: 1rem;
}


.site-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  padding: 10px 12px 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  width: 100%;
  max-width: min(100vw, 760px);
  margin: 2rem auto 0.7rem;
  box-sizing: border-box; 
  min-width: 0;
  overflow: hidden;
}


.site-search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: 0.98rem;
  min-width: 0;
}

.site-search i {
  color: #94a3af;
}

.btn-search {
  padding-inline: 16px;
  background: #0f172a;
  color: #fff;
  border: 1px solid #0f172a;
  white-space: nowrap;
}

.quick-filters {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 6px 0;
  max-width: 960px;
  margin: 0 auto 2rem;
}

.chip {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #0f172a;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}

main {
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 18px 20px 24px;
  min-height: calc(100vh - var(--nav-height));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 6px 0 6px;
  margin-bottom: 1.5rem;
  background: var(--card);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 260px;
  justify-content: space-between;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search {
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
}

.search-icon {
  color: #94a3b8;
  font-size: 0.95rem;
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
}

.profile-avatar {
  width: 42px;
  height: 42px;
  border-radius: 60px;
  background: #0f172a;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.profile-meta {
  display: grid;
  gap: 2px;
}

.search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  background: transparent !important;
  color: var(--text) !important;
  box-shadow: 0 0 0 1000px transparent inset !important; /* force le fond */
}

section {
  display: grid;
  gap: 8px;
}

#resultats {
  position: relative;
  min-height: 260px;
}

#result-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  pointer-events: none;
}

.status-hidden {
  display: none;
}

.status-error {
  color: #dc2626;
  font-weight: 700;
}

section header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

section header h2 {
  font-size: 1.1rem;
}

.pill {
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  border: 1px dashed #e2e8f0;
  background: #f8fafc;
  color: #475569;
  padding: 18px 16px;
  border-radius: 14px;
  display: grid;
  gap: 8px;
  place-items: start;
}

.empty-state h3 {
  font-size: 1rem;
}

.empty-state .muted {
  font-size: 0.9rem;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, #eef2f7 0%, #e3e9f2 50%, #eef2f7 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  width: 100%;
}

.skeleton-card {
  border-radius: 20px;
  min-height: 260px;
  background: var(--card);
}

/* ==== Card ===== */

.cards-grid,
.favorite-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  grid-auto-rows: 10px;
  grid-auto-flow: dense;
  align-items: start;
  width: 100%;
}

.card {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background: var(--panel);
  /* border: 1px solid var(--border); */
  box-shadow: none;
  display: flex;
  flex-direction: column;
  width: 100%;
  grid-row-end: span 1;
}

.card::before {
  content: none;
}

.card img {
  width: 100%;
  height: auto;
  border-radius: 20px;
}

.card-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 10px;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.card:hover .card-actions,
.card:focus-within .card-actions {
  opacity: 1;
  pointer-events: auto;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 70px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--panel);
  border-color: var(--border);
}

.nav-actions .icon-btn:hover {
  background: #f8fafc;
  border-color: #dfe3ea;
  color: var(--text);
}

.icon-btn.ghost {
  background: rgba(255, 255, 255, 0.8);
  color: #0f172a;
  border: 1px solid #e5e7eb;
}

.icon-btn.soft {
  background: #f0f4ff;
  border: 1px solid #d9e2f5;
  width: 44px;
  height: 44px;
  color: var(--text);
  box-shadow: none;
}

.card-footer {
  position: static;
  padding: 14px 14px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  /* border-top: 1px solid var(--border); */
  color: var(--text);
  z-index: 1;
}

.author {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-footer .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  object-fit: cover;
}

.meta {
  display: grid;
  gap: 2px;
  font-size: 0.9rem;
}

.card-footer .muted {
  font-size: 0.9rem;
}

.card-footer .ghost {
  margin-left: auto;
}

.fav-btn.active {
  color: #ef4444;
  border-color: #fecdd3;
  background: #fff5f5;
}

.card-footer .ghost {
  margin-left: auto;
}

/* ==== Collections ===== */

.collection-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  grid-auto-rows: auto;
  grid-auto-flow: row;
  width: 100%;
}

.collection-section {
  display: grid;
  gap: 10px;
}

.collection-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.collection-card {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: #e5e7eb;
  aspect-ratio: 4 / 2;
  isolation: isolate;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  cursor: pointer;
}

.collection-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.collection-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.5) 20%,
    rgba(15, 23, 42, 0.75) 100%
  );
}

.collection-card__title {
  position: absolute;
  /* left: 14px;
  right: 14px;
  bottom: 14px; */
  color: #ffffff;
  font-weight: 700;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.collection-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16);
}

/* Collection modal */
body.collection-modal-open {
  overflow: hidden;
}

.collection-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.collection-modal.open {
  pointer-events: auto;
  opacity: 1;
}

.collection-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
}

.collection-modal__panel {
  position: relative;
  width: min(420px, 100%);
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  overflow: hidden;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.collection-modal__search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.collection-modal__search i {
  color: #94a3b8;
}

.collection-modal__search input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.95rem;
  background: transparent;
}

.collection-modal__list {
  max-height: 360px;
  overflow: auto;
  padding: 8px 10px;
  display: grid;
  gap: 10px;
}

.collection-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.collection-option:hover {
  border-color: #cbd5e1;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.collection-option__info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.collection-option img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  background: #f1f5f9;
}

.collection-option__meta {
  display: grid;
  gap: 2px;
  text-align: left;
  min-width: 0;
}

.collection-option__meta strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collection-modal__empty {
  padding: 20px 12px;
  color: var(--muted);
}

.collection-option__delete {
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}

.collection-option__delete:hover {
  color: #ef4444;
  background: #fef2f2;
}

.collection-option__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.collection-option__rename {
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}

.collection-option__rename:hover {
  color: #2563eb;
  background: #eff6ff;
}

.collection-option__info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.collection-option__meta {
  display: grid;
  gap: 2px;
  text-align: left;
  min-width: 0;
}

.collection-option__meta strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Collection detail modal */
.collection-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.collection-detail-modal.open {
  pointer-events: auto;
  opacity: 1;
}

.collection-detail__panel {
  position: fixed;
  inset: 10%;
  max-width: 1100px;
  margin: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  z-index: 1;
  padding: 16px 16px 18px;
}

.collection-detail__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
}

.collection-detail__title {
  font-size: 1.2rem;
}

.collection-detail__grid {
  margin-top: 12px;
  overflow: auto;
  max-height: calc(100vh - 180px);
}

.collection-detail__grid .card {
  background: #fff;
}

.collection-detail__empty {
  padding: 16px;
}

.collection-option__delete {
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}

.collection-option__delete:hover {
  color: #ef4444;
  background: #fef2f2;
}

.collection-modal__new {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
}

.collection-modal__new input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
}

.collection-modal__new input:focus {
  border-color: #94a3b8;
}

.btn {
  border: none;
  background: #0f172a;
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  background: #111827;
  transform: translateY(-1px);
}

.favorite-card {
  width: 100%;
  grid-row-end: span 1;
}

.badge {
  background: #e0e7ff;
  color: #4338ca;
  padding: 6px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
}

.muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox__content {
  position: relative;
  display: grid;
  place-items: center;
  max-width: min(1100px, 90vw);
  max-height: 90vh;
  width: 100%;
  background: #0b1221;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.lightbox__img {
  max-width: 90vw;
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #0b1221;
}

.lightbox__close,
.lightbox__nav {
  position: absolute;
  top: 12px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #1f2937;
  background: rgba(17, 24, 39, 0.75);
  color: #e5e7eb;
  cursor: pointer;
}

.lightbox__close {
  right: 12px;
}

.lightbox__nav {
  bottom: 12px;
  top: auto;
}

.lightbox__nav--prev {
  left: 12px;
}

.lightbox__nav--next {
  right: 12px;
}

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 20;
}

body.menu-open .menu-overlay {
  opacity: 1;
  visibility: visible;
}

.global-loader {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.6);
  z-index: 80;
  backdrop-filter: blur(3px);
}

body.is-loading .global-loader {
  display: flex;
}

.loader-spinner {
  position: relative;
  width: 64px;
  height: 64px;
}

.loader-spinner div {
  position: absolute;
  inset: 0;
  border: 6px solid #e0f2fe;
  border-radius: 50%;
  border-color: #e0f2fe transparent #e0f2fe transparent;
  animation: spin 1s linear infinite;
}

.loader-spinner div:nth-child(2) {
  animation-delay: -0.5s;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@media (min-width: 1100px) {
  .cards-grid,
  .favorite-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .site-nav {
    gap: 10px;
    position: sticky;
    top: 0;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .nav-links {
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(100% + 10px);
    display: grid;
    gap: 8px;
    padding: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.16);
    transform: translateY(-14px);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
    z-index: 25;
  }

  body.menu-open .nav-links {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transform: translateY(0);
  }

  .nav-links {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-links a {
    width: 100%;
    justify-content: flex-start;
  }

  .nav-actions {
    margin-left: 0;
    order: 3;
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
    margin-top: 6px;
  }
}

@media (max-width: 640px) {
  .site-search {
    padding: 10px 12px;
    gap: 8px;
    width: 100%;
    max-width: 100vw;
    margin-left: 0;
    margin-right: 0;
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .btn-search {
    padding-inline: 12px;
    font-size: 0.9rem;
  }

  .card-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 480px) {
  .site-search {
    padding: 8px 10px;
    gap: 6px;
    row-gap: 6px;
  }

  .btn-search {
    padding-inline: 10px;
    font-size: 0.9rem;
  }
}
