/* ===================================
   VPA — Styles principaux
   Dark UI: bleu marine #0a0e17 + bleu accent #3b6ef0 + or #d4a017
   =================================== */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --bg:          #0a0e17;
  --bg2:         #10141f;
  --bg3:         #161b29;
  --border:      #1c2230;
  --border2:     #262d40;
  --blue:        #3b6ef0;
  --blue-dark:   #2c54c9;
  --blue-light:  #6690ff;
  --blue-glow:   rgba(59,110,240,0.20);
  --gold:        #c8901a;
  --gold-light:  #e0a820;
  --gold-bg:     rgba(200,144,26,0.12);
  --gold-border: rgba(200,144,26,0.35);
  --text:        #e9ecf5;
  --text2:       #8c94ac;
  --text3:       #565d75;
  --green:       #22c55e;
  --red:         #ef4444;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   16px;
  --shadow:      0 4px 24px rgba(0,0,0,0.5);
  --shadow-blue: 0 4px 24px rgba(59,110,240,0.25);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Inter', 'Sora', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ===== TOPBAR ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: rgba(12,14,19,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 15px;
}
.topbar-logo {
  width: 32px;
  height: 32px;
  background: var(--blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
}
.topbar-logo-img {
  height: 26px;
  width: auto;
  object-fit: contain;
  display: block;
}
.topbar-brand span { color: var(--blue-light); }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-menu-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  font-size: 20px;
  line-height: 1;
}
.topbar-menu-btn:hover { background: var(--bg3); color: var(--text); }

/* ===== PAGE WRAPPER ===== */
.page {
  margin-top: 52px;
  min-height: calc(100vh - 52px);
  padding: 32px 20px;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  margin-top: 52px;
}
.page-wide {
  max-width: 1100px;
}

/* ===== BACK LINK ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text2);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s;
  margin-bottom: 28px;
  background: none;
  border: none;
}
.back-link:hover { color: var(--text); }
.back-link svg { width: 16px; height: 16px; }

/* ===== HEADINGS ===== */
.page-title {
  font-family: 'Sora', sans-serif;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-sub {
  color: var(--text2);
  font-size: 14px;
  margin-bottom: 32px;
}

/* ===== HOME CARDS ===== */
.home-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 52px);
  padding: 32px 20px;
  text-align: center;
}
.home-avatar {
  width: 72px;
  height: 72px;
  background: var(--blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Sora', sans-serif;
  font-weight: 800;
  font-size: 32px;
  color: #fff;
  margin-bottom: 20px;
}
.home-avatar-img {
  height: 64px;
  width: auto;
  object-fit: contain;
  margin-bottom: 24px;
}
.home-title {
  font-family: 'Sora', sans-serif;
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.2;
}
.home-sub {
  color: var(--text2);
  font-size: 14px;
  margin-bottom: 32px;
  max-width: 380px;
}
.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-gold {
  background: var(--gold-bg);
  color: var(--gold-light);
  border: 1px solid var(--gold-border);
}
.btn-gold:hover { background: rgba(200,144,26,0.2); }
.btn-ghost {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--border2); background: var(--border); }
.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}
.btn-block { width: 100%; }
.btn-danger { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.25); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 2-COLUMN GRID CARDS ===== */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}
.card-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  cursor: pointer;
  transition: all 0.25s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.card-select:hover {
  border-color: var(--blue-light);
  background: rgba(37,99,235,0.06);
  transform: translateY(-2px);
  box-shadow: var(--shadow-blue);
}
.card-select-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue-light);
}
.card-select-icon svg { width: 36px; height: 36px; }
.card-select-title {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-select-desc {
  color: var(--text2);
  font-size: 13px;
  line-height: 1.5;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.badge-beta { background: var(--gold-bg); color: var(--gold-light); border: 1px solid var(--gold-border); }
.badge-premium { background: var(--gold-bg); color: var(--gold-light); border: 1px solid var(--gold-border); }
.badge-green { background: rgba(34,197,94,0.12); color: var(--green); border: 1px solid rgba(34,197,94,0.25); }

/* ===== CREDIT BAR ===== */
.credit-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.credit-box-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.credit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 13px;
}
.credit-label { color: var(--text2); }
.credit-value { font-weight: 600; }
.credit-bar-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 4px;
  margin-bottom: 10px;
}
.credit-bar-fill {
  height: 4px;
  border-radius: 99px;
  background: var(--blue);
  transition: width 0.5s;
}

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-control:focus { border-color: var(--blue); }
.form-control::placeholder { color: var(--text3); }
textarea.form-control { resize: vertical; min-height: 120px; }

.tip-box {
  background: rgba(37,99,235,0.07);
  border: 1px solid rgba(37,99,235,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 16px;
}
.tip-box strong { color: var(--gold-light); }

/* ===== SECTION HEADERS ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-family: 'Sora', sans-serif;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title svg { width: 20px; height: 20px; color: var(--blue-light); }

/* ===== IMAGE DROP ZONE ===== */
.drop-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg3);
  position: relative;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--blue);
  background: rgba(37,99,235,0.05);
}
.drop-zone input[type="file"] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.drop-zone-icon { color: var(--text3); margin-bottom: 8px; }
.drop-zone-icon svg { width: 36px; height: 36px; }
.drop-zone-text { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.drop-zone-hint { color: var(--text3); font-size: 13px; }

/* ===== RESULT BOX ===== */
.result-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 24px;
}
.result-box-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.result-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.result-section:last-child { border-bottom: none; }
.result-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 8px;
}
.result-section-content {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}
.hashtags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.hashtag {
  background: rgba(37,99,235,0.12);
  color: var(--blue-light);
  border: 1px solid rgba(37,99,235,0.2);
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
}
.copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.copy-btn:hover { border-color: var(--blue); color: var(--blue-light); }
.copy-btn svg { width: 13px; height: 13px; }

/* ===== COMPTA TABLE ===== */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text3);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { color: var(--text2); }
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.article-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
}
.article-thumb-placeholder {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 18px;
}
.benef-positive { color: var(--green); font-weight: 600; }
.benef-negative { color: var(--red); font-weight: 600; }
.coeff-badge {
  background: rgba(34,197,94,0.12);
  color: var(--green);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
}
.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  font-size: 18px;
  padding: 2px;
  transition: color 0.2s;
}
.star-btn.active, .star-btn:hover { color: var(--gold-light); }
.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  color: var(--text3);
}
.action-btn:hover { background: var(--border); color: var(--text); }
.action-btn.delete:hover { background: rgba(239,68,68,0.1); color: var(--red); }
.action-btn svg { width: 16px; height: 16px; display: block; }

/* ===== TOP BAR COMPTA ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px 8px 36px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  width: 220px;
  transition: border-color 0.2s;
  position: relative;
}
.search-input:focus { border-color: var(--blue); }
.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
}
.search-icon svg { width: 15px; height: 15px; }
.filter-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 28px 8px 12px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  appearance: none;
}
.filter-select-wrap { position: relative; }
.filter-select-wrap::after {
  content: '▾';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  pointer-events: none;
  font-size: 12px;
}
.wh-badge {
  background: rgba(37,99,235,0.08);
  border: 1px solid rgba(37,99,235,0.15);
  color: var(--blue-light);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
}

/* ===== CLASSEMENT ===== */
.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
}
.ranking-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s;
}
.ranking-item.top1 {
  background: rgba(200,144,26,0.08);
  border-color: var(--gold-border);
}
.ranking-item.top2 { background: rgba(192,192,192,0.06); border-color: rgba(192,192,192,0.2); }
.ranking-item.top3 { background: rgba(205,127,50,0.06); border-color: rgba(205,127,50,0.2); }
.ranking-item.me { background: rgba(37,99,235,0.08); border-color: rgba(37,99,235,0.3); }
.ranking-rank {
  width: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--text3);
  flex-shrink: 0;
}
.ranking-medal { font-size: 20px; }
.ranking-name {
  flex: 1;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ranking-name svg { width: 15px; height: 15px; color: var(--gold-light); }
.ranking-amount { font-weight: 600; color: var(--text2); }
.ranking-item.top1 .ranking-amount { color: var(--gold-light); }

/* ===== CHATBOT ===== */
.chat-wrap {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: calc(100vh - 180px);
  min-height: 400px;
  display: flex;
  flex-direction: column;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-msg { display: flex; gap: 10px; max-width: 85%; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.ai { align-self: flex-start; }
.chat-bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.55;
}
.chat-msg.user .chat-bubble { background: var(--blue); color: #fff; border-radius: 12px 12px 4px 12px; }
.chat-msg.ai .chat-bubble { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; }
.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.chat-avatar.ai { background: var(--bg2); border: 1px solid var(--border); font-size: 16px; }
.chat-input-row {
  padding: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}
.chat-input {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  height: 44px;
  max-height: 120px;
  overflow: hidden;
}
.chat-input:focus { border-color: var(--blue); }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.25); color: #86efac; }
.alert-info { background: rgba(37,99,235,0.1); border: 1px solid rgba(37,99,235,0.2); color: var(--blue-light); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  padding: 28px;
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-title {
  font-family: 'Sora', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ===== AUTH ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at center top, rgba(37,99,235,0.06) 0%, transparent 60%), var(--bg);
}
.auth-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.auth-logo-icon {
  width: 44px;
  height: 44px;
  background: var(--blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Sora', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
}
.auth-logo-icon-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 10px;
}
.auth-logo-text strong {
  display: block;
  font-family: 'Sora', sans-serif;
  font-size: 16px;
  font-weight: 700;
}
.auth-logo-text span {
  font-size: 12px;
  color: var(--text2);
}
.auth-title {
  font-family: 'Sora', sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.auth-sub { color: var(--text2); font-size: 14px; margin-bottom: 24px; }

/* ===== DASHBOARD ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-card-label { font-size: 12px; color: var(--text3); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card-value { font-family: 'Sora', sans-serif; font-size: 24px; font-weight: 700; }
.stat-card-sub { font-size: 12px; color: var(--text2); margin-top: 4px; }
.stat-card.green .stat-card-value { color: var(--green); }
.stat-card.blue .stat-card-value { color: var(--blue-light); }
.stat-card.gold .stat-card-value { color: var(--gold-light); }

/* ===== FOURNISSEURS ===== */
.fournisseur-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.fournisseur-favicon {
  width: 24px; height: 24px;
  border-radius: 4px;
  object-fit: contain;
  background: var(--border);
}
.fournisseur-url { flex: 1; font-size: 13px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fournisseur-label { font-size: 14px; font-weight: 500; }

/* ===== HISTORIQUE ===== */
.history-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
}
.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  gap: 12px;
}
.history-item-title { font-size: 14px; font-weight: 600; flex: 1; display: flex; align-items: center; gap: 10px; }
.history-item-icon { color: var(--text3); width: 16px; height: 16px; }
.history-item-date { font-size: 12px; color: var(--text3); }
.history-arrow { color: var(--text3); font-size: 12px; transition: transform 0.2s; }
.history-item.open .history-arrow { transform: rotate(180deg); }
.history-item-body { padding: 0 16px; max-height: 0; overflow: hidden; transition: max-height 0.3s, padding 0.3s; }
.history-item.open .history-item-body { max-height: 500px; padding: 0 16px 16px; }

/* ===== LOADING ===== */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text2); font-size: 14px; display: flex; align-items: center; gap: 8px; }

/* ===== PREMIUM BANNER ===== */
.premium-banner {
  background: linear-gradient(135deg, rgba(200,144,26,0.12), rgba(200,144,26,0.06));
  border: 1px solid var(--gold-border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.premium-banner-icon { font-size: 28px; }
.premium-banner-text h4 { font-family: 'Sora', sans-serif; font-size: 16px; font-weight: 700; color: var(--gold-light); margin-bottom: 4px; }
.premium-banner-text p { font-size: 13px; color: var(--text2); }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } }
.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error { border-color: rgba(239,68,68,0.3); }
.toast-icon { font-size: 16px; }

/* ===== SIDE MENU ===== */
.side-menu {
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
}
.side-menu-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.2s;
}
.side-menu-panel {
  position: absolute;
  top: 0; right: 0;
  width: 280px;
  height: 100%;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.25s;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 8px;
}
.side-menu.open .side-menu-overlay { opacity: 1; pointer-events: all; }
.side-menu.open .side-menu-panel { transform: translateX(0); pointer-events: all; }
.side-menu.open { pointer-events: all; }
.side-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.side-menu-user { display: flex; align-items: center; gap: 10px; }
.side-menu-avatar {
  width: 36px; height: 36px;
  background: var(--blue);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.side-menu-name { font-weight: 600; font-size: 14px; }
.side-menu-email { font-size: 12px; color: var(--text3); }
.side-menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text2);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.side-menu-link:hover { background: var(--bg3); color: var(--text); }
.side-menu-link svg { width: 18px; height: 18px; }
.side-menu-link.danger { color: var(--red); }
.side-menu-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ===== EXAMPLE MODAL ===== */
.example-paste-area {
  font-size: 13px;
  min-height: 100px;
}

/* ===== ADMIN ===== */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.admin-tab {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--blue-light); border-bottom-color: var(--blue); }

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.role-badge.admin { background: rgba(239,68,68,0.12); color: var(--red); }
.role-badge.user { background: rgba(139,147,168,0.12); color: var(--text2); }

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border2);
  border-radius: 22px;
  transition: background 0.2s;
}
.switch-track::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch input:checked + .switch-track { background: var(--gold); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }

.credit-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.credit-edit-row input {
  width: 64px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 5px 8px;
  font-size: 13px;
  text-align: center;
}
.credit-edit-row input:focus { outline: none; border-color: var(--blue); }

.admin-stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.admin-stat-row .stat-card { flex: 1; min-width: 140px; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.user-cell-name { font-weight: 600; font-size: 14px; }
.user-cell-email { font-size: 12px; color: var(--text3); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text3);
}
.empty-state svg { width: 36px; height: 36px; margin: 0 auto 12px; display: block; opacity: 0.6; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text2); margin-bottom: 4px; }
.empty-state-sub { font-size: 13px; }

.chat-typing { display: flex; gap: 4px; padding: 4px 0; }
.chat-typing span {
  width: 6px; height: 6px;
  background: var(--text3);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .card-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .admin-stat-row { grid-template-columns: 1fr 1fr; }
  .page { padding: 20px 14px; }
  .data-table { font-size: 12px; }
  .data-table td, .data-table th { padding: 10px 8px; }
  .user-cell-email { display: none; }
}