/* ═══════════════════════ PAYTAB — Espace Client ═══════════════════════ */
:root {
  --brand: #2e6b96;
  --brand-light: #4d8fbe;
  --brand-deep: #1d4a6b;
  --ink: #0b1520;
  --ink-soft: #566372;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e5eaf0;
  --danger: #d64545;
  --success: #1f9d61;
  --warning: #c8862b;
  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --sidebar-w: 264px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }
button { font: inherit; cursor: pointer; }
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.2; }

.grad-text {
  background: linear-gradient(100deg, var(--brand) 10%, var(--brand-light) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: .95rem;
  padding: 12px 22px; border-radius: 999px; border: none;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s, opacity .2s;
}
.btn-primary { background: linear-gradient(120deg, var(--brand), var(--brand-light)); color: #fff; box-shadow: 0 8px 20px -8px rgba(46,107,150,.5); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 28px -10px rgba(46,107,150,.6); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: rgba(46,107,150,.06); border-color: var(--brand); }
.btn-danger { background: rgba(214,69,69,.1); color: var(--danger); }
.btn-danger:hover { background: rgba(214,69,69,.16); }
.btn-sm { padding: 8px 16px; font-size: .85rem; }
.btn-block { width: 100%; }

/* ── App shell ── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, #123952, var(--brand-deep));
  color: #fff;
  display: flex; flex-direction: column;
  padding: 26px 18px;
  position: fixed; inset: 0 auto 0 0; z-index: 50;
  transition: transform .3s var(--ease);
}
.sidebar-logo { display: flex; align-items: center; padding: 0 10px 28px; }
.sidebar-logo img { height: 26px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  color: rgba(255,255,255,.72); font-weight: 600; font-size: .92rem;
  transition: background .2s, color .2s;
}
.sidebar-link .ico { font-size: 1.1rem; width: 22px; text-align: center; }
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--danger, #d64545); color: #fff;
  font-size: .72rem; font-weight: 800; line-height: 20px; text-align: center;
  flex-shrink: 0;
}
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.is-active { background: rgba(255,255,255,.14); color: #fff; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: 16px; margin-top: 16px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px 14px; }
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.14); display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: .85rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-mail { font-size: .74rem; color: rgba(255,255,255,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logout {
  width: 100%; background: rgba(255,255,255,.08); color: #fff;
  padding: 10px 14px; border-radius: 12px; font-size: .88rem; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logout:hover { background: rgba(255,255,255,.16); }

.menu-toggle {
  display: none; position: fixed; top: 16px; left: 16px; z-index: 60;
  width: 42px; height: 42px; border-radius: 12px; border: none;
  background: #fff; box-shadow: 0 6px 18px -6px rgba(30,60,85,.3);
  font-size: 1.2rem; color: var(--brand-deep);
}

.main {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-width: 0;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 36px; background: rgba(245,247,250,.85);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.4rem; font-weight: 800; }
.topbar-sub { color: var(--ink-soft); font-size: .88rem; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.content { padding: 30px 36px 70px; max-width: 1100px; }

/* ── Cards ── */
.card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 26px;
}
.card + .card { margin-top: 20px; }
.card-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; }
.card-sub { color: var(--ink-soft); font-size: .88rem; margin-bottom: 20px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }

.stat-tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px;
}
.stat-tile small { color: var(--ink-soft); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-tile b { display: block; margin-top: 8px; font-size: 1.8rem; font-weight: 800; color: var(--brand); }
.stat-tile .stat-icon { font-size: 1.4rem; margin-bottom: 10px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 13px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  letter-spacing: .02em;
}
.badge-brand { background: rgba(46,107,150,.1); color: var(--brand-deep); }
.badge-success { background: rgba(31,157,97,.12); color: var(--success); }
.badge-warning { background: rgba(200,134,43,.12); color: var(--warning); }
.badge-muted { background: #eef1f4; color: var(--ink-soft); }
.badge-danger { background: rgba(214,69,69,.1); color: var(--danger); }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.field span { font-size: .86rem; font-weight: 600; color: var(--ink-soft); }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=url], .field input[type=number], .field select, .field textarea {
  font: inherit; color: var(--ink);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 15px; background: #fafcfe;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(46,107,150,.12);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-hint { font-size: .78rem; color: #93a0ab; margin-top: -2px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: none; }
.switch-row-text b { display: block; font-size: .94rem; }
.switch-row-text span { font-size: .82rem; color: var(--ink-soft); }
.switch { position: relative; width: 46px; height: 27px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; background: #d8dfe6; border-radius: 999px; cursor: pointer;
  transition: background .25s;
}
.switch-track::before {
  content: ""; position: absolute; width: 21px; height: 21px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .25s var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::before { transform: translateX(19px); }

.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 10px; }
.radio-card { cursor: pointer; }
.radio-card input { position: absolute; opacity: 0; }
.radio-card span {
  display: block; padding: 14px 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); font-size: .88rem; font-weight: 600; color: var(--ink-soft);
  transition: all .2s var(--ease);
}
.radio-card input:checked + span { border-color: var(--brand); background: rgba(46,107,150,.06); color: var(--brand-deep); }

.color-swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 2.5px solid transparent; transition: transform .2s, border-color .2s; }
.swatch:hover { transform: scale(1.1); }
.swatch.is-active { border-color: var(--ink); transform: scale(1.1); }

/* ── Table ── */
.data-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; min-width: 520px; background: #fff; }
.data-table th {
  text-align: left; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-soft); padding: 14px 20px; background: #fafcfe; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: .92rem; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafcfe; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty-state .ico { font-size: 2.2rem; margin-bottom: 12px; }

/* ── Pricing / plan cards ── */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 18px; }
.plan-card {
  background: #fff; border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 26px; display: flex; flex-direction: column; gap: 16px;
  position: relative; transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.plan-card:hover { transform: translateY(-4px); box-shadow: 0 20px 40px -20px rgba(30,60,85,.25); }
.plan-card.is-current { border-color: var(--brand); box-shadow: 0 20px 40px -20px rgba(46,107,150,.3); }
.plan-current-tag {
  position: absolute; top: -12px; right: 20px;
  background: var(--brand); color: #fff; font-size: .72rem; font-weight: 700;
  padding: 5px 12px; border-radius: 999px;
}
.plan-name { font-size: 1.1rem; font-weight: 800; }
.plan-price { font-size: 2rem; font-weight: 800; color: var(--brand); }
.plan-price span { font-size: .9rem; font-weight: 600; color: var(--ink-soft); }
.plan-features { list-style: none; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.plan-features li { padding-left: 26px; position: relative; font-size: .88rem; color: var(--ink-soft); }
.plan-features li::before {
  content: "✓"; position: absolute; left: 0; top: 0;
  width: 18px; height: 18px; border-radius: 50%; background: rgba(46,107,150,.12); color: var(--brand);
  font-size: .68rem; font-weight: 800; display: grid; place-items: center;
}

/* ── Spinners & états de chargement ── */
.spinner {
  width: 15px; height: 15px; border-radius: 50%; flex-shrink: 0;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn-ghost .spinner { border-color: rgba(46,107,150,.22); border-top-color: var(--brand); }
.btn-danger .spinner { border-color: rgba(214,69,69,.25); border-top-color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  position: fixed; inset: 0; z-index: 999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .35s var(--ease), visibility .35s;
}
.page-loader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.spinner-lg {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(46,107,150,.15); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}

.skeleton {
  position: relative; color: transparent !important; border-radius: 8px;
  background: linear-gradient(90deg, #eef1f4 25%, #f5f7fa 37%, #eef1f4 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  pointer-events: none; user-select: none;
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-row td { padding: 18px 20px; }

/* ── Contenu : entrée en fondu fluide ── */
.content { animation: contentFadeIn .45s var(--ease) both; }
@keyframes contentFadeIn { from { opacity: 0; transform: translateY(10px); } }

/* ── Champ mot de passe avec bouton œil ── */
.field-input-wrap { position: relative; }
.field-eye-btn {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: none; background: transparent; border-radius: 9px;
  font-size: 1rem; color: var(--ink-soft); display: grid; place-items: center;
  transition: background .2s;
}
.field-eye-btn:hover { background: #eef1f4; }

.field-hint.is-match { color: var(--success); font-weight: 600; }
.field-hint.is-mismatch { color: var(--warning); }

/* ── Boîte de réception / fils de discussion ── */
.inbox-layout {
  display: grid; grid-template-columns: 300px 1fr; gap: 18px;
  height: 620px; max-height: 72vh;
}
.thread-list {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-y: auto; display: flex; flex-direction: column;
}
.thread-item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .2s;
}
.thread-item:hover { background: var(--bg-soft, #f5f7fa); }
.thread-item.is-active { background: rgba(46,107,150,.08); }
.thread-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.thread-item-name { font-weight: 700; font-size: .92rem; }
.thread-item-preview { font-size: .82rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-item-date { font-size: .72rem; color: #93a0ab; flex-shrink: 0; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); flex-shrink: 0; }

.thread-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
}
.thread-panel-head {
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.thread-panel-head h3 { font-size: 1rem; font-weight: 700; }
.thread-panel-head small { color: var(--ink-soft); font-size: .8rem; }
.message-list { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.message-bubble {
  max-width: 72%; padding: 10px 15px; border-radius: 16px; font-size: .9rem; line-height: 1.5;
  animation: msgIn .25s var(--ease) both;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } }
.message-bubble.from-client { align-self: flex-start; background: #eef1f4; color: var(--ink); border-bottom-left-radius: 4px; }
.message-bubble.from-admin { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.message-time { display: block; margin-top: 5px; font-size: .7rem; opacity: .6; }
.thread-resolved-notice {
  padding: 14px 18px; border-top: 1px solid var(--border);
  background: var(--bg-soft, #f5f7fa); color: var(--ink-soft);
  font-size: .85rem; line-height: 1.5; text-align: center;
}
.reply-box { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
.reply-box textarea {
  flex: 1; resize: none; border: 1.5px solid var(--border); border-radius: 12px;
  padding: 10px 14px; font: inherit; max-height: 100px;
}
.reply-box textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(46,107,150,.12); }
.thread-empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink-soft); gap: 10px;
}

@media (max-width: 860px) {
  .inbox-layout { grid-template-columns: 1fr; height: auto; }
  .thread-list { max-height: 220px; }
  .thread-panel { height: 460px; }
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 26px; right: 26px; z-index: 200;
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 12px;
  font-size: .9rem; font-weight: 600; box-shadow: 0 20px 40px -15px rgba(0,0,0,.4);
  display: flex; align-items: center; gap: 10px;
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: transform .3s var(--ease), opacity .3s var(--ease);
}
.toast.is-visible { transform: none; opacity: 1; }
.toast.is-error { background: var(--danger); }
.toast.is-success { background: var(--success); }

/* ── Auth pages ── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef4f9, #f5f7fa 60%);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px; background: #fff;
  border-radius: 24px; padding: 40px 36px;
  box-shadow: 0 40px 90px -30px rgba(30,60,85,.3);
  animation: authCardIn .5s var(--ease) both;
}
@keyframes authCardIn { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.auth-logo { display: flex; justify-content: center; margin-bottom: 22px; }
.auth-logo img { height: 30px; }
.auth-title { text-align: center; font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--ink-soft); font-size: .9rem; margin-bottom: 26px; }
.auth-tabs { display: flex; background: #eef1f4; border-radius: 999px; padding: 4px; margin-bottom: 26px; }
.auth-tab { flex: 1; text-align: center; padding: 9px 0; border-radius: 999px; font-size: .86rem; font-weight: 700; color: var(--ink-soft); transition: all .2s; }
.auth-tab.is-active { background: #fff; color: var(--brand-deep); box-shadow: 0 3px 10px -4px rgba(30,60,85,.2); }
.auth-error {
  background: rgba(214,69,69,.08); color: var(--danger); border: 1px solid rgba(214,69,69,.2);
  border-radius: 12px; padding: 11px 15px; font-size: .84rem; margin-bottom: 16px; display: none;
}
.auth-error.is-visible { display: block; }
.auth-foot { text-align: center; margin-top: 18px; font-size: .85rem; color: var(--ink-soft); }
.auth-foot a { color: var(--brand); font-weight: 600; }
.auth-loading { text-align: center; color: var(--ink-soft); font-size: .9rem; }

/* ── Setup notice (Firebase not configured) ── */
.setup-banner {
  background: #fff8e8; border: 1.5px solid #f0d99a; color: #7a5b12;
  border-radius: 14px; padding: 16px 20px; font-size: .86rem; line-height: 1.55;
  margin-bottom: 22px;
}
.setup-banner b { display: block; margin-bottom: 4px; }
.setup-banner code { background: rgba(122,91,18,.1); padding: 1px 6px; border-radius: 5px; font-size: .82em; }

/* ── Responsive ── */
@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: none; }
  .menu-toggle { display: grid; place-items: center; }
  .main { margin-left: 0; }
  .topbar { padding: 18px 20px 18px 68px; }
  .content { padding: 22px 20px 60px; }
  .field-row { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .auth-card { padding: 30px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .content, .auth-card, .spinner, .spinner-lg, .skeleton { animation: none; }
  .page-loader { transition: none; }
}
