/* ─── Bioshi Score v3 UI ─── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #f4f0ec;
  --bg-subtle: #e8e2dc;
  --card: #ffffff;
  --border: #ddd5cd;
  --orange-50: #fff8f1;
  --orange-100: #ffefdb;
  --orange-200: #ffddb5;
  --orange-400: #ffaa4d;
  --orange-500: #ff9422;
  --orange-600: #f58215;
  --orange-700: #e06f0a;
  --orange-800: #c46010;
  --orange-900: #7c2d12;
  --text: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #a8a29e;
  --red: #dc2626;
  --red-light: #fef2f2;
  --green: #16a34a;
  --green-50: #ecfdf0;
  --green-100: #d1fae0;
  --green-200: #a7f3c0;
  --green-700: #15803d;
  --log-bg: #140e0a;
  --log-surface: #1c1410;
  --log-text: #c9a882;
  --log-text-bright: #f0dcc8;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 4px rgba(0,0,0,0.03);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.04), 0 10px 24px rgba(0,0,0,0.06);
  --shadow-xl: 0 8px 30px rgba(0,0,0,0.08);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Header ─── */
.header {
  background: linear-gradient(135deg, var(--orange-700) 0%, var(--orange-600) 40%, var(--orange-500) 100%);
  color: white;
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(245, 130, 21, 0.3), 0 1px 3px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.header h1::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--orange-400);
  border-radius: 50%;
  margin-right: 8px;
  box-shadow: 0 0 8px rgba(251, 146, 60, 0.5);
}
.header h1 span {
  font-weight: 300;
  opacity: 0.7;
  font-size: 18px;
}

.header-status {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 100px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  letter-spacing: 0.3px;
}
.header-status.running {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.25);
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,255,255,0.2); }
  50% { opacity: 0.85; box-shadow: 0 0 0 6px rgba(255,255,255,0); }
}

/* ─── Layout ─── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 28px 48px;
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: 1fr auto;
  gap: 24px;
}

/* ─── Cards ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-lg);
}

.card h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
}

/* ─── Left Column: Controls ─── */
.controls-col {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Process Info Rows ─── */
.info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 13px;
}
.info-row:last-of-type { border-bottom: none; }
.info-row .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.info-row .value {
  font-weight: 500;
  color: var(--text);
  text-align: right;
  max-width: 180px;
  word-break: break-all;
}

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-idle { background: var(--bg-subtle); color: var(--text-muted); border: 1px solid var(--border); }
.badge-running { background: var(--orange-50); color: var(--orange-700); border: 1px solid var(--orange-200); animation: badgePulse 2s ease-in-out infinite; }
.badge-ok { background: var(--green-50); color: var(--green-700); border: 1px solid var(--green-200); }
.badge-error { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249,115,22,0.15); }
  50% { box-shadow: 0 0 0 4px rgba(249,115,22,0); }
}

/* ─── Buttons ─── */
.btn-run {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  background: linear-gradient(135deg, var(--orange-500) 0%, var(--orange-600) 100%);
  color: white;
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.2px;
  box-shadow: 0 2px 8px rgba(255, 148, 34, 0.35), 0 1px 2px rgba(0,0,0,0.08);
  position: relative;
  overflow: hidden;
  margin-top: 16px;
}
.btn-run::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  pointer-events: none;
}
.btn-run:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.35), 0 2px 4px rgba(0,0,0,0.1);
}
.btn-run:active:not(:disabled) { transform: translateY(0); box-shadow: 0 1px 4px rgba(234, 88, 12, 0.2); }
.btn-run:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-stop {
  width: 100%;
  padding: 12px 20px;
  border: 2px solid var(--red);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: var(--red-light);
  color: var(--red);
  font-family: 'Inter', sans-serif;
  margin-top: 8px;
  transition: all var(--transition);
}
.btn-stop:hover:not(:disabled) { background: #fee2e2; }
.btn-stop:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Progress Bar ─── */
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-top: 16px;
  margin-bottom: 6px;
}
.progress-label span:last-child {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
}
.progress-bar-bg {
  height: 10px;
  background: var(--bg-subtle);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange-500), var(--orange-600));
  border-radius: 5px;
  transition: width 0.5s ease;
  min-width: 2px;
}

/* ─── Grade Items ─── */
.grade-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0 !important;
}
.grade-letter { font-size: 13px; font-weight: 700; }
.grade-count { font-size: 11px; font-weight: 600; opacity: 0.85; }

/* ─── Pipeline Steps ─── */
.pipeline-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--bg);
}
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
}
.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.step-active {
  color: var(--orange-700);
  background: var(--orange-50);
}
.step-active .step-num {
  background: var(--orange-500);
  color: white;
  box-shadow: 0 0 0 3px rgba(249,115,22,0.15);
  animation: badgePulse 2s ease-in-out infinite;
}
.step-done {
  color: var(--green-700);
}
.step-done .step-num {
  background: var(--green);
  color: white;
}

.last-run-info {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--green-50);
  border: 1px solid var(--green-200);
  border-radius: var(--radius-xs);
  line-height: 1.6;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.btn-row .btn-run {
  flex: 1;
  margin-top: 0;
}
.btn-config {
  padding: 14px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-config:hover {
  border-color: var(--orange-400);
  color: var(--orange-700);
  background: var(--orange-50);
}

.btn-secondary {
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: white;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
}
.btn-secondary:hover {
  border-color: var(--orange-400);
  color: var(--orange-700);
  background: var(--orange-50);
}

.btn-danger {
  padding: 5px 12px;
  border: 1px solid #fecaca;
  border-radius: var(--radius-xs);
  background: var(--red-light);
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
}
.btn-danger:hover { background: #fee2e2; border-color: #fca5a5; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ─── Config dot ─── */
.config-status { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot-ok { background: var(--green); }
.dot-missing { background: var(--red); }

/* ─── Grade bar ─── */
.grade-bar { display: flex; gap: 4px; margin-top: 12px; }
.grade-item {
  flex: 1; text-align: center; padding: 7px 0;
  border-radius: var(--radius-xs); font-size: 11px; font-weight: 700;
  color: #fff; letter-spacing: 0.3px; transition: transform var(--transition);
}
.grade-item:hover { transform: translateY(-2px); }

/* ─── Right Column: Logs ─── */
.logs-panel {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  background: var(--log-bg);
  border: 1px solid #2e2218;
  overflow: hidden;
}
.logs-panel h2 {
  color: #7a6050;
  padding: 0;
  margin-bottom: 0;
  flex: 1;
}
.logs-panel h2::after {
  background: linear-gradient(to right, #2e2218, transparent);
}

.log-box {
  background: var(--log-surface);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-y: auto;
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.75;
  color: var(--log-text);
  border: 1px solid #2e2218;
}

.log-box .log-line {
  white-space: pre-wrap;
  word-break: break-all;
  padding: 1px 0;
  border-radius: 3px;
  transition: background 0.15s;
}
.log-box .log-line:hover { background: rgba(255,255,255,0.03); }
.log-box .log-line .ts { color: var(--orange-400); font-weight: 500; }
.log-box .log-line .src-scoring { color: #6daaf2; }
.log-box .log-line .src-upload { color: #c586c0; }
.log-box .log-line .src-upload-desc { color: #4ec9b0; }
.log-box .log-line .error { color: #f44747; }
.log-box .log-line .warn { color: #cca700; }
.log-box .log-line.step-header { color: var(--orange-400); font-weight: 600; margin-top: 6px; }

.log-box::-webkit-scrollbar { width: 6px; }
.log-box::-webkit-scrollbar-track { background: transparent; }
.log-box::-webkit-scrollbar-thumb { background: #2e2218; border-radius: 3px; }
.log-box::-webkit-scrollbar-thumb:hover { background: #4e3e30; }

.log-empty {
  color: #5a4030;
  font-style: italic;
}

.log-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.btn-clear {
  padding: 5px 12px;
  border-radius: var(--radius-xs);
  background: rgba(255,255,255,0.06);
  color: #7a6050;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #2e2218;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
}
.btn-clear:hover { background: rgba(255,255,255,0.1); border-color: #4e3e30; }

/* ─── Full-Width Cards ─── */
.full-width { grid-column: 1 / -1; }

/* ─── Slack Webhooks ─── */
.webhook-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--bg);
  transition: background var(--transition);
}
.webhook-item:last-child { border-bottom: none; }
.webhook-info { flex: 1; }
.webhook-name { font-weight: 600; font-size: 13px; color: var(--text); }
.webhook-url { font-size: 11px; color: var(--text-muted); word-break: break-all; margin-top: 2px; font-family: 'JetBrains Mono', monospace; }
.webhook-empty { color: var(--text-muted); font-size: 13px; padding: 8px 0; font-style: italic; }

.add-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--bg-subtle); }

/* ─── Input Groups ─── */
.input-group { margin-bottom: 14px; }
.input-group label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px;
}
.input-group input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  font-size: 13px; font-weight: 500; font-family: 'Inter', sans-serif;
  color: var(--text); background: var(--bg); transition: all var(--transition); outline: none;
}
.input-group input:focus {
  border-color: var(--orange-500);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
  background: white;
}
.input-group input::placeholder { color: var(--text-muted); font-weight: 400; }

/* ─── IdoSell Config ─── */
.config-panel { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--bg-subtle); }

/* ─── Toast ─── */
.toast-container { position: fixed; top: 76px; right: 20px; z-index: 1000; }
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  margin-bottom: 8px; font-size: 13px; font-weight: 600;
  max-width: 360px; animation: toastIn 0.3s ease; box-shadow: var(--shadow-lg);
}
.toast-success { background: var(--green-50); color: var(--green-700); border: 1px solid var(--green-200); }
.toast-error { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Responsive ─── */
@media (max-width: 860px) {
  .header { padding: 0 20px; }
  .container { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .controls-col { grid-column: 1; }
  .logs-panel { grid-column: 1; grid-row: auto; }
  .full-width { grid-column: 1; }
  .log-box { min-height: 240px; max-height: 360px; }
}
@media (max-width: 480px) {
  .header h1 { font-size: 17px; }
  .header h1 span { display: none; }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Selection ─── */
::selection { background: var(--orange-200); color: var(--orange-900); }
