/* SAV-bot dashboard — style minimal, lisible, sans framework. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #2a2a2a;
  background: #faf7f5;
  /* filet de sécurité : aucun contenu ne doit déclencher un scroll horizontal global */
  overflow-x: hidden;
  max-width: 100vw;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid #ead7cd;
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { text-decoration: none; color: #2a2a2a; font-weight: bold; font-size: 16px; }
.warning {
  color: #b35a00;
  background: #fff4e6;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
}

.container { max-width: 1200px; margin: 24px auto; padding: 0 24px; }

/* tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid #ead7cd; }
.tab {
  padding: 8px 16px;
  text-decoration: none;
  color: #6a6a6a;
  border-bottom: 2px solid transparent;
  font-size: 13px;
}
.tab:hover { color: #2a2a2a; }
.tab.active { color: #c89b8c; border-bottom-color: #c89b8c; font-weight: 600; }
.badge {
  display: inline-block;
  background: #ead7cd;
  color: #6a3a2a;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  margin-left: 4px;
}

.empty { color: #888; font-style: italic; }
.back { display: inline-block; margin-bottom: 12px; color: #888; text-decoration: none; }
.back:hover { color: #2a2a2a; }

/* tickets table */
table.tickets {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
table.tickets th, table.tickets td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f0e7e1;
}
table.tickets th { background: #f7efe9; font-weight: 600; font-size: 12px; }
table.tickets tr:hover td { background: #fcf7f4; }

/* status badges */
.status { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-pending_enrichment { background: #e6e6fa; color: #5a3a8a; }
.status-pending_llm { background: #fff0d6; color: #8a6a3a; }
.status-awaiting_validation { background: #d6e9ff; color: #1a558a; }
.status-escalated { background: #ffd6d6; color: #8a1a1a; }
.status-auto_sent { background: #d6f0d6; color: #1a6a3a; }
.status-closed { background: #e6e6e6; color: #555; }
.pill { display: inline-block; background: #ead7cd; color: #6a3a2a; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.success { color: #1a6a3a; background: #d6f0d6; padding: 6px 12px; border-radius: 4px; }

/* ticket detail */
.ticket-header h1 { margin: 0 0 6px 0; font-size: 18px; word-break: break-word; overflow-wrap: anywhere; }
.ticket-header .meta { color: #6a6a6a; font-size: 12px; display: flex; gap: 16px; flex-wrap: wrap; }
.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  margin-top: 20px;
}
@media (max-width: 1000px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.col-left, .col-right {
  background: #fff;
  border-radius: 6px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  min-width: 0;   /* clé : permet à la colonne grid de shrinker proprement */
  overflow: hidden;
}
.col-left h2, .col-right h2 { margin-top: 0; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: #888; }

/* messages */
.message {
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 6px;
  background: #f7efe9;
  overflow: hidden;
}
.message.outbound { background: #e6f0ea; }
.message header { font-size: 12px; color: #6a6a6a; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.message pre {
  margin: 0;
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-all;       /* coupe MÊME à l'intérieur d'un mot/base64 sans espace */
  font-family: inherit;
  font-size: 13px;
}
.shopify dd { word-break: break-word; overflow-wrap: anywhere; }
.items li { word-break: break-word; overflow-wrap: anywhere; }

/* shopify panel */
.shopify { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; font-size: 13px; }
.shopify dt { color: #888; }
.shopify dd { margin: 0; }
.items { font-size: 13px; padding-left: 18px; }

/* draft editor */
textarea {
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  padding: 12px;
  border: 1px solid #ead7cd;
  border-radius: 6px;
  resize: vertical;
}
textarea:focus { outline: none; border-color: #c89b8c; box-shadow: 0 0 0 2px rgba(200,155,140,0.2); }

.actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.spacer { flex: 1; }
.who { padding: 6px 10px; border: 1px solid #ead7cd; border-radius: 4px; font-size: 13px; width: 200px; }
.reason { padding: 6px 10px; border: 1px solid #ead7cd; border-radius: 4px; font-size: 13px; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 4px;
  border: 1px solid #c89b8c;
  background: #fff;
  color: #c89b8c;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-family: inherit;
}
.btn:hover { background: #fcf7f4; }
.btn.primary { background: #c89b8c; color: #fff; }
.btn.primary:hover { background: #b88a7c; }
.btn.primary:disabled { background: #d8c5be; cursor: not-allowed; }
.btn.ghost { border-color: #ccc; color: #555; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.advanced { margin-top: 16px; font-size: 13px; }
.advanced summary { cursor: pointer; color: #888; }
.advanced form.inline { display: inline-block; margin-right: 8px; margin-top: 8px; }

code { background: #f7efe9; padding: 1px 6px; border-radius: 3px; font-size: 12px; }

/* nav */
.topnav { display: flex; gap: 16px; margin-left: 16px; }
.topnav a { color: #888; text-decoration: none; font-size: 13px; }
.topnav a:hover { color: #c89b8c; }

/* metrics */
.metrics-grid { display: flex; gap: 16px; margin: 16px 0 24px 0; flex-wrap: wrap; }
.metric { background: #fff; padding: 16px 24px; border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); min-width: 140px; }
.metric-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #888; }
.metric-value { font-size: 24px; font-weight: bold; color: #2a2a2a; margin-top: 4px; }

.bar { display: inline-block; vertical-align: middle; width: 100px; height: 6px; background: #f0e7e1; border-radius: 3px; margin-left: 8px; }
.bar-fill { display: block; height: 100%; background: #c89b8c; border-radius: 3px; }
section h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: #888; margin-top: 24px; }
section { margin-bottom: 24px; }

.safety-note { color: #b35a00; font-size: 11px; margin: 6px 0 0 0; font-style: italic; }

/* déconnexion dans la topbar */
.logout-link { margin-left: auto; color: #a08070; font-size: 12px; text-decoration: none; padding: 4px 10px; border: 1px solid #ead7cd; border-radius: 4px; }
.logout-link:hover { background: #fcf7f4; }

/* ---------- page de login ---------- */
.login-body {
  background: linear-gradient(135deg, #fff4ee 0%, #f5e6dc 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}
.login-wrap { width: 100%; padding: 24px; display: flex; justify-content: center; }
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(200, 155, 140, 0.18);
  padding: 40px 32px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-brand { margin-bottom: 28px; }
.login-emoji { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.login-brand h1 { margin: 0; font-size: 20px; font-weight: 700; color: #2a2a2a; letter-spacing: 0.5px; }
.login-subtitle { margin: 4px 0 0; font-size: 12px; color: #a08070; text-transform: uppercase; letter-spacing: 2px; }

.login-error {
  background: #fff0e8;
  color: #b35a00;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid #f7d6c2;
}

.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form label { display: block; }
.login-form label span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  margin-bottom: 4px;
}
.login-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #ead7cd;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  background: #faf7f5;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.login-form input:focus {
  outline: none;
  border-color: #c89b8c;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(200, 155, 140, 0.18);
}

.login-btn {
  margin-top: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #d4a596 0%, #c89b8c 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: transform 0.08s, box-shadow 0.15s;
}
.login-btn:hover { box-shadow: 0 4px 12px rgba(200, 155, 140, 0.35); }
.login-btn:active { transform: translateY(1px); }

.login-footer {
  margin: 24px 0 0;
  font-size: 11px;
  color: #b0a0a0;
}

/* blocklist */
.blocklist-form { display: flex; gap: 8px; margin: 12px 0; }
.blocklist-form input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ead7cd;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
}
.blocklist-form input[type="text"]:focus {
  outline: none;
  border-color: #c89b8c;
  box-shadow: 0 0 0 2px rgba(200,155,140,0.2);
}

/* related tickets */
.related { background: #fff; border-radius: 6px; padding: 12px 18px; margin-top: 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.related summary { cursor: pointer; color: #6a6a6a; font-size: 13px; }
.related summary strong { color: #2a2a2a; }
.related-group { margin: 12px 0; padding-left: 8px; border-left: 3px solid #ead7cd; }
.related-group h3 { font-size: 13px; color: #6a3a2a; margin: 4px 0 6px 0; font-weight: 600; }
.related-group ul { list-style: none; padding-left: 0; margin: 0; }
.related-group li { padding: 4px 0; font-size: 13px; color: #555; border-bottom: 1px dashed #f0e7e1; }
.related-group li:last-child { border-bottom: none; }
.related-group li a { color: #c89b8c; text-decoration: none; font-weight: 600; }
.related-group li a:hover { text-decoration: underline; }
