/* ===========================
   MYDESIRE - Charte Graphique
   =========================== */

:root {
  --primary: #C93F3F;
  --primary-light: #F6C0C0;
  --salmon: #FA8072;
  --salmon-light: #FFA07A;
  --salmon-mid: rgba(255,160,122,0.5);
  --dark-red: #8B0000;
  --white: #ffffff;
  --gray-light: #f8f9fa;
  --shadow: 0px 8px 30px rgba(201,63,63,0.18);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #faf5f5;
  color: #2d2d2d;
  min-height: 100vh;
}

/* ======= VIEWS ======= */
.view { display: none; }
.view.active { display: block; }

/* ======= AUTH PAGES ======= */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #C93F3F 0%, #F6C0C0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0px 30px 125px -5px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
}

.auth-banner {
  position: relative;
  height: 200px;
  background: linear-gradient(135deg, #C93F3F, #FA8072);
  display: flex;
  align-items: flex-end;
  padding: 1.5rem;
}

.auth-banner img.logo-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  width: 80px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}

.auth-banner h2 {
  color: white;
  font-size: 1.6rem;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 3px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 1;
}

.auth-body { padding: 2rem 2.5rem 2.5rem; }

.form-group { margin-bottom: 1.2rem; position: relative; }

.form-label {
  display: block;
  color: var(--dark-red);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid #e0d0d0;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fdfafa;
}
.form-control:focus {
  outline: none;
  border-color: var(--salmon);
  box-shadow: 0 0 0 3px rgba(250,128,114,0.15);
  background: white;
}

.btn-primary {
  background: linear-gradient(135deg, var(--salmon) 0%, var(--primary) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  width: 100%;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(201,63,63,0.35);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}
.btn-secondary:hover { background: var(--primary-light); }

.btn-sm {
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  width: auto;
}

.btn-ghost {
  background: transparent;
  color: var(--salmon);
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.btn-danger {
  background: #dc3545;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
}
.auth-links a { color: var(--salmon); font-size: 0.85rem; text-decoration: none; }
.auth-links a:hover { color: var(--primary); text-decoration: underline; }

.eye-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(50%);
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  width: 24px;
  padding: 0;
}
.eye-btn img { width: 100%; }

.error-msg {
  background: #fde8e8;
  color: var(--primary);
  border: 1px solid #f5c6c6;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.error-msg.visible { display: block; }

/* ======= NAVBAR ======= */
.navbar {
  background: var(--white);
  border-bottom: 2px solid var(--primary-light);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(201,63,63,0.1);
}

.navbar-inner {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  gap: 1rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  flex-shrink: 0;
}
.navbar-brand img { width: 38px; }
.navbar-brand span {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
}

.navbar-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  list-style: none;
}

.nav-link {
  padding: 0.5rem 1rem;
  color: #555;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  background: none;
}
.nav-link:hover, .nav-link.active { background: var(--primary-light); color: var(--primary); }

.navbar-pseudo { color: #888; font-size: 0.85rem; flex: 1; text-align: right; }
.navbar-pseudo strong { color: var(--primary); }

.btn-deconnect {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-deconnect:hover { background: var(--primary); color: white; }

/* ======= MAIN CONTENT ======= */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ======= PAGE HEADER ======= */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
}

.page-subtitle { color: #888; font-size: 0.9rem; margin-top: 0.2rem; }

/* ======= CARDS ======= */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(201,63,63,0.22);
}

.card-stripe {
  height: 6px;
  background: linear-gradient(90deg, var(--primary), var(--salmon-light));
}

.card-body { padding: 1.25rem; }
.card-title { font-size: 1.1rem; font-weight: 600; color: #1a1a1a; margin-bottom: 0.4rem; }
.card-meta { color: #888; font-size: 0.82rem; }
.card-desc { color: #666; font-size: 0.88rem; margin-top: 0.6rem; }
.card-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--primary-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-open { background: #e8f5e9; color: #2e7d32; }
.badge-closed { background: #f3e5f5; color: #6a1b9a; }
.badge-funded { background: #fff3e0; color: #e65100; }
.badge-code {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 1rem;
  letter-spacing: 2px;
  padding: 0.3rem 0.8rem;
}

/* ======= LIST DETAIL ======= */
.list-detail-header {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--primary);
}

.items-section { display: flex; gap: 1.5rem; }
.items-list { flex: 1; min-width: 0; }
.chat-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

@media (max-width: 900px) {
  .items-section { flex-direction: column; }
  .chat-panel { width: 100%; }
}

/* ======= ITEM CARDS ======= */
.item-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  margin-bottom: 1rem;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.item-card:hover { box-shadow: 0 4px 20px rgba(201,63,63,0.15); }

.item-card.status-funded, .item-card.status-reserved {
  opacity: 0.65;
}
.item-card.status-funded .item-name,
.item-card.status-reserved .item-name {
  text-decoration: line-through;
  color: #888;
}

.item-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 1rem; font-weight: 600; }
.item-price { color: var(--primary); font-weight: 700; font-size: 1.1rem; }
.item-url { font-size: 0.8rem; }
.item-url a { color: var(--salmon); text-decoration: none; }
.item-url a:hover { text-decoration: underline; }

.item-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.progress-bar-wrap {
  height: 6px;
  background: #f0e0e0;
  border-radius: 3px;
  overflow: hidden;
  margin: 0 1.25rem 0.75rem;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--salmon), var(--primary));
  transition: width 0.5s ease;
  border-radius: 3px;
}

.item-participations {
  padding: 0.5rem 1.25rem 0.75rem;
  border-top: 1px solid #f5e8e8;
}

.participation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--primary-light);
  color: var(--dark-red);
  border-radius: 99px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
}

/* ======= PARTICIPATION MODAL ======= */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.25rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #888;
  line-height: 1;
}
.modal-close:hover { color: var(--primary); }

.radio-group { display: flex; gap: 1rem; margin-bottom: 1rem; }
.radio-group label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; font-size: 0.9rem; }

/* ======= CHAT ======= */
.chat-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: 420px;
  position: sticky;
  top: 80px;
}

.chat-title {
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 1px solid var(--primary-light);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chat-bubble {
  max-width: 85%;
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
}
.chat-bubble.mine {
  background: linear-gradient(135deg, var(--salmon) 0%, var(--primary) 100%);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-bubble.other {
  background: #f5f0f0;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.bubble-pseudo { font-size: 0.75rem; font-weight: 600; opacity: 0.75; margin-bottom: 0.2rem; }
.bubble-time { font-size: 0.7rem; opacity: 0.6; margin-top: 0.2rem; text-align: right; }

.chat-input-wrap {
  display: flex;
  padding: 0.75rem;
  border-top: 1px solid var(--primary-light);
  gap: 0.5rem;
}
.chat-input {
  flex: 1;
  border: 1.5px solid #e0d0d0;
  border-radius: 20px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  outline: none;
}
.chat-input:focus { border-color: var(--salmon); }
.chat-send {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.chat-send:hover { background: var(--salmon); }

/* ======= ITEM CHAT ======= */
.item-chat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px solid var(--primary-light);
  color: var(--primary);
  border-radius: 99px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.item-chat-toggle:hover { background: var(--primary-light); }

.item-chat-box {
  display: none;
  border-top: 1px solid var(--primary-light);
  padding: 0.75rem 1.25rem;
  background: #fffafa;
}
.item-chat-box.open { display: block; }

.item-chat-messages {
  height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* ======= ACCUEIL ======= */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--salmon) 100%);
  border-radius: var(--radius);
  padding: 2.5rem;
  color: white;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}
.welcome-banner img { width: 80px; filter: brightness(0) invert(1); opacity: 0.9; }
.welcome-text h1 { font-size: 2rem; font-weight: 300; letter-spacing: 2px; }
.welcome-text p { opacity: 0.85; margin-top: 0.5rem; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--salmon);
}
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { color: #888; font-size: 0.82rem; }

/* ======= JOIN GROUP ======= */
.join-group-card {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  max-width: 500px;
}

.code-input {
  font-size: 2rem;
  letter-spacing: 0.5em;
  text-align: center;
  font-weight: 700;
  color: var(--primary);
}

/* ======= FORMS ======= */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.inline-form {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.inline-form h3 { color: var(--primary); font-size: 1rem; margin-bottom: 1rem; }

/* ======= EMPTY STATE ======= */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: #aaa;
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: 0.95rem; }

/* ======= TABS ======= */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 0;
}
.tab-btn {
  background: none;
  border: none;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: #888;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-weight: 500;
  transition: all 0.15s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ======= INVITE CODE DISPLAY ======= */
.invite-code-display {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 1rem 1.5rem;
  text-align: center;
  margin: 1rem 0;
}
.invite-code-number {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.3em;
}

/* ======= TOAST ======= */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: #2d2d2d;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  animation: slideIn 0.3s ease;
  min-width: 220px;
}
.toast.success { border-left: 3px solid #4caf50; }
.toast.error { border-left: 3px solid var(--primary); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ======= RESPONSIVE NAVBAR ======= */
@media (max-width: 650px) {
  .navbar-inner { flex-wrap: wrap; }
  .navbar-nav { order: 3; width: 100%; }
  .navbar-pseudo { display: none; }
}

/* ======= SCROLLBAR ======= */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--salmon); }

/* ======= ITEM IMAGE UPLOAD ======= */
.item-image-upload {
  width: 100%;
  height: 160px;
  border: 2px dashed var(--primary-light);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
  position: relative;
  background: #fdfafa;
}
.item-image-upload:hover { border-color: var(--salmon); background: #fff5f5; }

/* ======= ITEM CARD WITH IMAGE ======= */
.item-card-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.item-theme-badge {
  display: inline-flex;
  align-items: center;
  background: var(--primary-light);
  color: var(--dark-red);
  border-radius: 99px;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.item-description {
  color: #777;
  font-size: 0.83rem;
  margin-top: 0.3rem;
  line-height: 1.4;
}

/* ======= LIST PRIVACY INDICATOR ======= */
.list-visibility {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: 99px;
}
.list-visibility.private { background: #f3f4f6; color: #6b7280; }
.list-visibility.shared { background: #fef3c7; color: #92400e; }

/* ======= ITEM GRID IN OWNER VIEW ======= */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.item-card-v2 {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 2px 14px rgba(0,0,0,0.08);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}
.item-card-v2:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(201,63,63,0.15); }

.item-card-v2.status-funded,
.item-card-v2.status-reserved {
  opacity: 0.6;
}
.item-card-v2.status-funded .item-name,
.item-card-v2.status-reserved .item-name {
  text-decoration: line-through;
  color: #999;
}

.item-card-body { padding: 1rem; flex: 1; }
.item-card-footer-bar {
  padding: 0.6rem 1rem;
  border-top: 1px solid #f5e8e8;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.item-no-image {
  height: 120px;
  background: linear-gradient(135deg, #fdf0f0, #fde8e8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

/* ======= STATUS OVERLAY ON FUNDED ITEMS ======= */
.item-status-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(201,63,63,0.12);
  align-items: center;
  justify-content: center;
}
.item-card-v2.status-funded .item-status-overlay,
.item-card-v2.status-reserved .item-status-overlay {
  display: flex;
}
.item-status-stamp {
  background: white;
  border: 3px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 700;
  transform: rotate(-10deg);
  letter-spacing: 1px;
}

/* Sticky image zone relative */
.item-image-zone-wrap { position: relative; overflow: hidden; }
