/* ═══════════════════════════════════════════════════════════
   ÉpicAlerte — style.css
   Thème : vert forêt + or doux, mode sombre
═══════════════════════════════════════════════════════════ */

/* ── VARIABLES ── */
:root {
  --bg:         #0b1a14;
  --bg2:        #0f2218;
  --bg3:        #142d20;
  --surface:    #1a3828;
  --border:     #2a5040;
  --green:      #22c55e;
  --green-dim:  #16a34a;
  --gold:       #d4af37;
  --gold-dim:   #b8932a;
  --text:       #e8f5ee;
  --text-dim:   #8ab89e;
  --text-mute:  #4a7a5c;
  --red:        #ef4444;
  --radius:     14px;
  --radius-sm:  8px;
  --font-head:  'Bricolage Grotesque', sans-serif;
  --font-body:  'Manrope', sans-serif;
  --tr:         0.2s ease;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── UTILS ── */
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: .9rem; font-weight: 500;
  cursor: pointer; border: none; transition: var(--tr);
  text-decoration: none; white-space: nowrap;
}
.btn-primary  { background: var(--green); color: #0b1a14; }
.btn-primary:hover  { background: var(--green-dim); transform: translateY(-1px); }
.btn-gold     { background: var(--gold); color: #1a0e00; }
.btn-gold:hover     { background: var(--gold-dim); transform: translateY(-1px); }
.btn-ghost    { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover    { border-color: var(--green); color: var(--green); }
.btn-danger   { background: transparent; color: var(--red); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover   { background: rgba(239,68,68,.1); }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }

input, select {
  width: 100%; padding: 10px 14px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font-body); font-size: .9rem;
  transition: var(--tr); outline: none;
}
input:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34,197,94,.1);
}
input::placeholder { color: var(--text-mute); }
label { display: block; font-size: .82rem; color: var(--text-dim); margin-bottom: 5px; font-weight: 500; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.badge-green { background: rgba(34,197,94,.15); color: var(--green); }
.badge-gold  { background: rgba(212,175,55,.15); color: var(--gold); }

/* ── TOAST ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 500; min-width: 260px;
  animation: slideUp .3s ease; display: flex; align-items: center; gap: 10px;
}
.toast.success { background: #16a34a; color: #fff; }
.toast.error   { background: #dc2626; color: #fff; }
.toast.info    { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.loader {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes bounce {
  0%, 100% { transform: translateY(0); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
  50%       { transform: translateY(-6px); animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
}
.logo-cart {
  display: inline-block;
  animation: bounce 1.2s infinite;
  font-size: 1.15em;
  line-height: 1;
  vertical-align: middle;
  will-change: transform;
}
.bounce-cart {
  display: inline-block;
  animation: bounce 1.2s infinite;
  vertical-align: middle;
  will-change: transform;
  transform-origin: center bottom;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── HEADER ── */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(11,26,20,.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo {
  font-family: var(--font-head); font-weight: 800; font-size: 1.3rem;
  color: var(--text); text-decoration: none; letter-spacing: -.01em;
  font-optical-sizing: auto;
  display: flex; align-items: center; gap: 8px;
}
.logo-text  { display: inline-flex; }
.logo-green { color: var(--green); }
.logo-white { color: #ffffff; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; color: var(--green); font-weight: 600;
}
#user-email-display {
  font-size: .82rem; color: var(--text-dim);
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── LANDING ── */
#page-landing { animation: fadeIn .4s ease; }

.hero {
  min-height: calc(100vh - 64px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 80px 24px 60px;
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(34,197,94,.08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 80%, rgba(212,175,55,.05) 0%, transparent 60%);
  pointer-events: none;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.25);
  padding: 5px 14px; border-radius: 20px;
  font-size: .8rem; color: var(--green); font-weight: 500; letter-spacing: .05em;
  margin-bottom: 28px;
}
.hero h1 {
  font-family: var(--font-head);
  font-size: clamp(2.4rem, 7vw, 5rem);
  font-weight: 800; line-height: 1.05; letter-spacing: -.02em;
  font-optical-sizing: auto;
  max-width: 800px; margin-bottom: 20px;
}
.hero h1 em { font-style: normal; color: var(--green); }
.hero > p {
  font-size: clamp(1rem, 2.5vw, 1.2rem); color: var(--text-dim);
  max-width: 560px; margin-bottom: 40px; line-height: 1.7;
}
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.hero-stats {
  display: flex; gap: 40px; margin-top: 64px;
  flex-wrap: wrap; justify-content: center;
  border-top: 1px solid var(--border); padding-top: 40px;
  width: 100%; max-width: 600px;
}
.stat-item { text-align: center; }
.stat-num   { font-family: var(--font-head); font-size: 2rem; font-weight: 800; color: var(--gold); }
.stat-label { font-size: .8rem; color: var(--text-mute); margin-top: 2px; }

.section { padding: 80px 24px; max-width: 1100px; margin: 0 auto; }
.section-label {
  text-align: center; font-size: .78rem; letter-spacing: .15em;
  color: var(--green); font-weight: 600; text-transform: uppercase; margin-bottom: 16px;
}
.section h2 {
  font-family: var(--font-head);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800; text-align: center; margin-bottom: 48px; letter-spacing: -.02em;
}

.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap: 20px; }
.feature-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  transition: var(--tr); position: relative; overflow: hidden;
}
.feature-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transform: scaleX(0); transform-origin: left; transition: var(--tr);
}
.feature-card:hover { border-color: var(--green); transform: translateY(-3px); }
.feature-card:hover::before { transform: scaleX(1); }
.feature-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; margin-bottom: 18px;
}
.feature-card h3 { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; margin-bottom: 10px; }
.feature-card p  { font-size: .88rem; color: var(--text-dim); line-height: 1.7; }

.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 24px; }
.step-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; text-align: center;
}
.step-num {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green-dim));
  color: #0b1a14; font-family: var(--font-head); font-weight: 800; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 18px;
}
.step-card h3 { font-family: var(--font-head); font-weight: 700; margin-bottom: 10px; }
.step-card p  { font-size: .88rem; color: var(--text-dim); }

footer {
  border-top: 1px solid var(--border); padding: 32px 24px;
  text-align: center; color: var(--text-mute); font-size: .82rem;
}
footer a { color: var(--text-mute); text-decoration: none; margin: 0 12px; }
footer a:hover { color: var(--text-dim); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; animation: overlayIn .25s ease forwards;
}
@keyframes overlayIn { to { opacity: 1; } }

.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px; width: 100%; max-width: 420px;
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
  transform: scale(.94) translateY(12px);
  animation: modalIn .25s ease forwards;
}
@keyframes modalIn { to { transform: scale(1) translateY(0); } }

.modal-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0;
}
.modal-brand {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 20px;
}
.modal-brand-cart {
  display: inline-block;
  font-size: 3rem; line-height: 1;
  animation: bounce 1.2s infinite;
  margin-bottom: 10px;
}
.modal-brand-name {
  font-family: var(--font-head); font-weight: 800; font-size: 1.6rem;
  letter-spacing: -.01em; font-optical-sizing: auto;
  display: inline-flex;
}
.modal-close  {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center; transition: var(--tr);
}
.modal-close:hover { border-color: var(--red); color: var(--red); }

.modal-tabs {
  display: flex; gap: 4px; background: var(--bg3);
  border-radius: 10px; padding: 4px; margin-bottom: 24px;
}
.tab-btn {
  flex: 1; padding: 8px; border-radius: 8px; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: .88rem; font-weight: 500;
  background: transparent; color: var(--text-dim); transition: var(--tr);
}
.tab-btn.active { background: var(--surface); color: var(--text); }

.form-group   { margin-bottom: 16px; }
.form-actions { margin-top: 22px; }
.form-footer  { text-align: center; margin-top: 16px; font-size: .82rem; color: var(--text-mute); }
.form-footer a { color: var(--green); text-decoration: none; cursor: pointer; }
.form-footer a:hover { text-decoration: underline; }
.error-msg { color: #f87171; font-size: .8rem; margin-top: 6px; }

/* ── APP ── */
#page-app { animation: fadeIn .4s ease; overflow-x: hidden; max-width: 100vw; }

.app-layout {
  display: grid; grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
  overflow-x: hidden;
}
.sidebar {
  background: var(--bg2); border-right: 1px solid var(--border);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-dim); cursor: pointer; transition: var(--tr);
  font-size: .88rem; font-weight: 500; border: none; background: none;
  width: 100%; text-align: left;
}
.nav-item:hover  { background: var(--surface); color: var(--text); }
.nav-item.active { background: rgba(34,197,94,.12); color: var(--green); }
.nav-item i { width: 18px; text-align: center; }
.sidebar-bottom { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }

.main-content { padding: 32px; overflow-y: auto; overflow-x: hidden; min-width: 0; }
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.page-title    { font-family: var(--font-head); font-size: 1.6rem; font-weight: 800; letter-spacing: -.015em; font-optical-sizing: auto; }
.page-subtitle { color: var(--text-dim); font-size: .88rem; margin-top: 4px; }

.screen        { display: none; }
.screen.active { display: block; min-width: 0; overflow-x: hidden; }

/* ── ONBOARDING ── */
#page-onboarding {
  min-height: calc(100vh - 64px);
  display: flex; align-items: center; justify-content: center; padding: 40px 24px;
}
.onboarding-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px; max-width: 560px; width: 100%;
}
.onboarding-card h2     { font-family: var(--font-head); font-size: 1.7rem; font-weight: 800; margin-bottom: 8px; }
.onboarding-card > p    { color: var(--text-dim); margin-bottom: 28px; }

.stores-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr));
  gap: 10px; margin-bottom: 24px;
}
.store-toggle {
  padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg3);
  cursor: pointer; transition: var(--tr); text-align: center;
  font-size: .85rem; font-weight: 500; color: var(--text-dim); user-select: none;
}
.store-toggle.selected { border-color: var(--green); background: rgba(34,197,94,.1); color: var(--green); }
.store-toggle:hover     { border-color: var(--green); }

/* ── DASHBOARD ── */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr));
  gap: 16px; margin-bottom: 28px;
}
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-card .label { font-size: .78rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.stat-card .value { font-family: var(--font-head); font-size: 2rem; font-weight: 800; }
.stat-card .sub   { font-size: .78rem; color: var(--text-mute); margin-top: 4px; }

.alerts-list { display: flex; flex-direction: column; gap: 10px; }
.alert-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
}
.alert-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(34,197,94,.1); color: var(--green);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.alert-body  { flex: 1; }
.alert-title { font-weight: 500; font-size: .9rem; }
.alert-sub   { font-size: .78rem; color: var(--text-mute); margin-top: 2px; }
.alert-price { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; color: var(--gold); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-mute); }
.empty-state i { font-size: 2.5rem; margin-bottom: 16px; display: block; }
.empty-state p { font-size: .9rem; }

/* ── PRODUCTS ── */
.add-product-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 24px;
}
.add-product-form h3 { font-family: var(--font-head); font-size: 1rem; font-weight: 700; margin-bottom: 16px; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row .form-group { flex: 1; min-width: 160px; }

.products-list { display: flex; flex-direction: column; gap: 10px; }
.product-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
  display: flex; align-items: center; gap: 16px; transition: var(--tr);
}
.product-card.on-sale { border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.04); }
.product-info     { flex: 1; }
.product-name     { font-weight: 600; font-size: .95rem; word-break: break-word; }
.product-threshold{ font-size: .78rem; color: var(--text-mute); margin-top: 2px; }
.product-price    { text-align: right; min-width: 90px; }
.product-price .current { font-family: var(--font-head); font-size: 1.2rem; font-weight: 700; }
.product-price .store   { font-size: .72rem; color: var(--text-mute); }
.product-price.deal .current { color: var(--green); }
.delete-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid rgba(239,68,68,.2);
  color: #f87171; cursor: pointer; font-size: .85rem;
  display: flex; align-items: center; justify-content: center; transition: var(--tr);
}
.delete-btn:hover { background: rgba(239,68,68,.1); border-color: var(--red); }

/* ── HISTORY ── */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
}
.history-date { font-size: .72rem; color: var(--text-mute); min-width: 80px; }

/* ── NOTIFICATIONS ── */
.notif-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
}
.notif-card h3 { font-family: var(--font-head); font-weight: 700; margin-bottom: 10px; }
.notif-card p  { color: var(--text-dim); font-size: .88rem; margin-bottom: 20px; line-height: 1.7; }
.ios-notice {
  background: rgba(212,175,55,.08); border: 1px solid rgba(212,175,55,.2);
  border-radius: var(--radius-sm); padding: 14px; margin-top: 16px;
  font-size: .82rem; color: var(--gold); display: flex; gap: 10px; align-items: flex-start;
}

/* ── SETTINGS ── */
.settings-section { margin-bottom: 32px; }
.settings-section h3 {
  font-family: var(--font-head); font-weight: 700;
  margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.danger-zone {
  background: rgba(239,68,68,.05); border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--radius); padding: 20px;
}
.danger-zone h4 { color: #f87171; margin-bottom: 8px; font-weight: 600; }
.danger-zone p  { font-size: .85rem; color: var(--text-dim); margin-bottom: 16px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }
  .sidebar {
    flex-direction: row; overflow-x: auto; padding: 12px;
    border-right: none; border-bottom: 1px solid var(--border); gap: 4px;
    /* Empêche la sidebar de forcer un dépassement horizontal */
    width: 100%; box-sizing: border-box;
  }
  .sidebar-bottom { margin-top: 0; padding-top: 0; border-top: none; margin-left: auto; }
  .nav-item       { padding: 8px 12px; font-size: .82rem; white-space: nowrap; flex-shrink: 0; }
  .main-content   { padding: 16px; overflow-x: hidden; min-width: 0; width: 100%; box-sizing: border-box; }
  .page-header    { flex-direction: column; }
  .page-title     { font-size: 1.3rem; }
  .form-row       { flex-direction: column; }
  .stats-row      { grid-template-columns: repeat(2, 1fr); }
  /* Cartes produits — empêcher le débordement */
  .product-card   { flex-wrap: wrap; gap: 10px; }
  .product-price  { min-width: 0; }
  /* Formulaire ajout produit */
  .add-product-form { padding: 16px; }
}
@media (max-width: 480px) {
  header               { padding: 0 16px; }
  #user-email-display  { display: none; }
  .hero h1             { font-size: 2rem; }
  .hero-cta            { flex-direction: column; align-items: center; }
}

/* ── CORRECTION GLOBALE DÉBORDEMENT MOBILE ── */
@media (max-width: 768px) {
  body, #page-app, #page-landing, #page-onboarding {
    overflow-x: hidden;
    max-width: 100vw;
  }
  /* Tous les écrans de l'app restent dans la fenêtre */
  .screen.active, .main-content, .app-layout {
    max-width: 100%;
    overflow-x: hidden;
  }
  /* Header : évite que les boutons débordent */
  .header-actions { gap: 8px; }
  .btn-sm { padding: 6px 10px; font-size: .78rem; }
}
