/* ============================================================
   Caprice PROD — console-style, no-scroll, single viewport
   ============================================================ */

* { box-sizing: border-box; }

:root {
  --bg: #05070d;
  --bg-1: #0b1020;
  --bg-2: #11172b;
  --bg-deep: #020308;
  --border: #22304f;
  --border-soft: #172141;
  --text: #e8edf8;
  --text-dim: #8a97b8;
  --text-mute: #55618a;
  --brand: #ec4899;
  --brand-2: #8b5cf6;
  --accent: #60a5fa;
  --ok: #22c55e;
  --ok-2: #16a34a;
  --warn: #f59e0b;
  --err: #ef4444;
  --reject: #fbbf24;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;            /* no scroll */
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -20%, #1a1f3a 0%, transparent 60%),
    var(--bg);
}

/* ============================================================
   Login screen (pleine page, centré)
   ============================================================ */
.login-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}
.login-screen .brand-mini { margin-bottom: 1rem; }
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 320px;
  padding: 1.75rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-form label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.login-form input {
  padding: 0.7rem 0.85rem;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
.login-form input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(236,72,153,0.15);
}
.error { color: #fca5a5; font-size: 0.88rem; text-align: center; margin: 0; }

/* ============================================================
   Layout principal (flex column, no-scroll)
   ============================================================ */
.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  gap: 0.75rem;
}

/* Header minimal */
.top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.25rem;
}
.brand-mini {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.brand-mini .brand-mark {
  font-size: 1.5rem;
  filter: drop-shadow(0 2px 8px rgba(236,72,153,0.4));
}
.brand-mini h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #f9a8d4 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-accent {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.top-right { margin: 0; }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }

/* ============================================================
   Barre de config compacte (1 seule ligne)
   ============================================================ */
.config {
  flex: 0 0 auto;
  display: flex;
  gap: 0.85rem;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.config-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
.config-group.grow { flex: 1; min-width: 220px; position: relative; }
.cfg-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  font-weight: 600;
}
.config select, .config input[type=text] {
  padding: 0.5rem 0.7rem;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  min-width: 160px;
}
.config select:focus, .config input[type=text]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(96,165,250,0.15);
}
.btn-clear {
  position: absolute;
  right: 6px;
  bottom: 7px;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  color: var(--text-mute);
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 4px;
}
.btn-clear:hover { color: var(--text); background: var(--bg-2); }

/* Chips régions */
.chip-row { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-dim);
  user-select: none;
  transition: all 0.15s;
}
.chip input { display: none; }
.chip:hover { border-color: var(--text-dim); color: var(--text); }
.chip.chip-on {
  background: rgba(236,72,153,0.12);
  border-color: var(--brand);
  color: #fbcfe8;
}

/* Bouton principal */
.btn-primary {
  padding: 0.6rem 1.35rem;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
  box-shadow: 0 4px 20px rgba(236,72,153,0.25);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   Console (flex: 1, fills remaining space)
   ============================================================ */
.console {
  flex: 1 1 auto;
  min-height: 0;              /* important pour que flex-grow + overflow marche */
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.console-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  background: linear-gradient(180deg, #0f1426 0%, #0a0f1e 100%);
  border-bottom: 1px solid var(--border-soft);
}
.dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  display: inline-block;
}
.dot.red    { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green  { background: #28c840; }
.console-header .title {
  margin-left: 0.6rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-mute);
}
.console-body {
  flex: 1 1 auto;
  overflow-y: auto;           /* scroll interne si log dépasse */
  padding: 0.85rem 1rem;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.55;
}
.console-body::-webkit-scrollbar { width: 8px; }
.console-body::-webkit-scrollbar-track { background: transparent; }
.console-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.line {
  white-space: pre-wrap;
  word-break: break-word;
  animation: slide-in 0.18s ease-out;
}
@keyframes slide-in {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}
.line.muted { color: var(--text-mute); }
.line .prompt { color: var(--ok); font-weight: 700; margin-right: 0.3rem; }
.line .cmd { color: #c4b5fd; }
.line .arrow { color: var(--brand); }
.line .ok { color: var(--ok); font-weight: 700; }
.line .warn { color: var(--warn); font-weight: 700; }
.line .err { color: var(--err); font-weight: 700; }
.line .err-txt { color: #fca5a5; }
.line .reject { color: var(--reject); }
.line .dim { color: var(--text-mute); }
.line .mono { font-family: var(--mono); }
.line .val { color: var(--text); font-weight: 500; }
.line .sid { color: var(--accent); font-family: var(--mono); }
.line .badge-ok {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  margin-left: 0.25rem;
  background: rgba(34,197,94,0.15);
  color: var(--ok);
  border: 1px solid rgba(34,197,94,0.4);
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.row-pending { opacity: 0.85; }
.row-ok { background: linear-gradient(90deg, rgba(34,197,94,0.10) 0%, transparent 80%); }
.row-rej { opacity: 0.75; }
.row-err { color: #fca5a5; }
.err-line { color: #fca5a5; }

/* Ligne gagnante (meilleur ping parmi les matches) */
.row-winner {
  background: linear-gradient(90deg, rgba(236,72,153,0.18) 0%, rgba(139,92,246,0.08) 70%, transparent 100%) !important;
  border-left: 2px solid var(--brand);
  padding-left: calc(0.25rem);
  margin-left: -2px;
  box-shadow: 0 0 18px rgba(236,72,153,0.08);
}
.badge-winner {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  margin-left: 0.25rem;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 8px rgba(236,72,153,0.35);
}

/* ============================================================
   Winner (bande fixe en bas)
   ============================================================ */
.winner {
  flex: 0 0 auto;
  padding: 0.85rem 1rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.3s;
}
.winner:has(.winner-content:not([hidden])) {
  border-color: var(--ok);
  box-shadow: 0 0 0 1px rgba(34,197,94,0.15), 0 -8px 30px rgba(34,197,94,0.08);
}
.winner-empty {
  color: var(--text-mute);
  font-size: 0.85rem;
  font-family: var(--mono);
  text-align: center;
  padding: 0.4rem 0;
}
.winner-empty .empty-mark {
  display: inline-block;
  margin-right: 0.4rem;
  animation: blink 1.2s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.winner-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.winner-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.winner-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}
.tag {
  display: inline-block;
  padding: 0.22rem 0.6rem;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.78rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.tag.mono { font-family: var(--mono); font-size: 0.76rem; }
.tag-ok {
  background: rgba(34,197,94,0.12);
  border-color: rgba(34,197,94,0.5);
  color: var(--ok);
  font-weight: 700;
}
.tag-lang {
  background: rgba(96,165,250,0.12);
  border-color: rgba(96,165,250,0.4);
  color: var(--accent);
  font-weight: 600;
}

.btn-copy {
  padding: 0.45rem 1rem;
  background: var(--ok);
  color: #052e20;
  border: none;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}
.btn-copy:hover { background: var(--ok-2); color: white; }

.winner-url {
  display: block;
  padding: 0.65rem 0.85rem;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: #93c5fd;
  user-select: all;
  cursor: text;
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.45;
  max-height: 4.5em;
  overflow: auto;
}

/* ============================================================
   Responsive (petits écrans)
   ============================================================ */
@media (max-width: 900px) {
  .config { flex-direction: column; align-items: stretch; }
  .config-group.grow { min-width: 0; }
  .winner-top { flex-direction: column; }
  .btn-copy { width: 100%; }
  .tag { max-width: 100%; }
}
@media (max-width: 600px) {
  html, body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .console { min-height: 280px; }
}
