/* ================================================================
   Binary Bloom — Global Stylesheet
   Dark theme, green accent, mobile-first
   ================================================================ */

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0d0f0e;
  --surface:      #161a18;
  --surface-2:    #1e2422;
  --border:       #2a312e;
  --text:         #e4ede8;
  --text-muted:   #7a9088;
  --accent:       #3ecf6e;
  --accent-dim:   #2a8f4c;
  --unripe:       #f5c842;
  --ready:        #3ecf6e;
  --overripe:     #f04747;
  --warning-bg:   #2b1f00;
  --warning-text: #fbbf24;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(0,0,0,.5);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Warning banner ── */
.api-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  text-align: center;
  font-size: .825rem;
  padding: .6rem 1rem;
  border-bottom: 1px solid #4a3500;
}

/* ── Header ── */
.site-header {
  background: linear-gradient(135deg, #0d1f14 0%, #0d1a18 100%);
  border-bottom: 1px solid var(--border);
  padding: 2.5rem 1rem 2rem;
  text-align: center;
}

.header-inner { max-width: 640px; margin: 0 auto; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .4rem;
}

.brand-palm { font-size: 2rem; }

.brand-name {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -.5px;
  background: linear-gradient(90deg, #3ecf6e, #a3e9be);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-sub {
  color: var(--text-muted);
  font-size: .9rem;
  letter-spacing: .02em;
}

/* ── Main layout ── */
.main-content {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── API config ── */
.api-config-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.config-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .6rem;
}

.config-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #4d6b5f;
}

.api-url-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

.api-url-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', monospace;
  font-size: .85rem;
  padding: .55rem .9rem;
  outline: none;
  transition: border-color .2s;
}

.api-url-input:focus { border-color: var(--accent); }
.api-url-input::placeholder { color: #3a5248; }

.url-status {
  font-size: .8rem;
  color: var(--accent);
  white-space: nowrap;
}

/* ── Buttons ── */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  padding: .55rem 1.25rem;
  transition: background .15s, opacity .15s, transform .1s;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: #062010;
}

.btn-primary:hover:not(:disabled) { background: #52e082; }

.btn-primary:disabled {
  background: #1e3528;
  color: #3a5c48;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }

/* ── Upload / drop zone ── */
.upload-section { display: flex; flex-direction: column; gap: 1rem; }

.drop-zone {
  position: relative;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 220px;
  overflow: hidden;
  transition: border-color .2s, background .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: #0f1f16;
}

.drop-zone-inner {
  text-align: center;
  padding: 2.5rem 1rem;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
}

.upload-icon { font-size: 2.5rem; }
.drop-text   { font-size: 1rem; font-weight: 600; color: var(--text); }
.drop-sub    { font-size: .8rem; color: var(--text-muted); }

.preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
  display: none;
}

.preview-img.visible { display: block; }

.actions-row {
  display: flex;
  gap: .75rem;
  justify-content: center;
}

.actions-row .btn { min-width: 140px; padding: .7rem 1.5rem; }

/* ── Loading ── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { color: var(--text-muted); font-size: .9rem; }

/* ── Error ── */
.error-section {
  background: #1f0c0c;
  border: 1px solid #4a1c1c;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.error-msg { color: #f47777; font-size: .9rem; }

/* ── Result card ── */
.result-section { animation: fadeUp .3s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.result-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.result-icon { font-size: 2.2rem; }

.result-stage-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.result-name {
  font-size: 1.6rem;
  font-weight: 700;
  text-transform: capitalize;
}

.result-name.unripe  { color: var(--unripe); }
.result-name.ready   { color: var(--ready); }
.result-name.overripe{ color: var(--overripe); }

.confidence-badge-wrap { margin-left: auto; }

.confidence-badge {
  font-size: .9rem;
  font-weight: 700;
  padding: .35rem .85rem;
  border-radius: 999px;
  display: inline-block;
}

.confidence-badge.unripe  { background: #2a2000; color: var(--unripe); }
.confidence-badge.ready   { background: #0a2016; color: var(--ready); }
.confidence-badge.overripe{ background: #200a0a; color: var(--overripe); }

/* Main confidence bar */
.main-bar-wrap  { margin-bottom: 1.5rem; }
.main-bar-bg    { background: var(--surface-2); border-radius: 999px; height: 8px; overflow: hidden; }
.main-bar       { height: 100%; border-radius: 999px; transition: width .5s ease; }
.main-bar.unripe  { background: var(--unripe); }
.main-bar.ready   { background: var(--ready); }
.main-bar.overripe{ background: var(--overripe); }

/* Breakdown */
.breakdown-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

.prob-list { display: flex; flex-direction: column; gap: .55rem; }

.prob-row {
  display: grid;
  grid-template-columns: 72px 1fr 44px;
  align-items: center;
  gap: .6rem;
}

.prob-label  { font-size: .82rem; font-weight: 500; color: var(--text-muted); }
.prob-bar-bg { background: var(--surface-2); border-radius: 999px; height: 6px; overflow: hidden; }
.prob-bar    { height: 100%; border-radius: 999px; transition: width .5s ease; }
.prob-pct    { font-size: .8rem; font-weight: 600; text-align: right; color: var(--text-muted); }

.unripe-bar  { background: var(--unripe); }
.ready-bar   { background: var(--ready); }
.overripe-bar{ background: var(--overripe); }

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--border);
  color: #3a5248;
  font-size: .78rem;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .brand-name    { font-size: 1.4rem; }
  .result-name   { font-size: 1.3rem; }
  .result-header { flex-wrap: wrap; }
  .confidence-badge-wrap { margin-left: 0; }
  .prob-row      { grid-template-columns: 62px 1fr 38px; }
}
