/* ==========================================================================
   Base & Reset
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;

  --primary: #0f172a;
  --primary-hover: #1e293b;
  --primary-light: #e2e8f0;

  --sport-color: #0369a1;
  --sport-bg: #e0f2fe;
  --finance-color: #4338ca;
  --finance-bg: #e0e7ff;

  --success: #059669;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ==========================================================================
   Layout Containers
   ========================================================================== */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3.5rem;
}

/* ==========================================================================
   Header
   ========================================================================== */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.875rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  display: block;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-light);
  display: block;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.status-ready {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

.model-meta-pill {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero-section {
  text-align: center;
  margin-bottom: 2rem;
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.hero-desc {
  max-width: 640px;
  margin: 0 auto;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ==========================================================================
   Card Component
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* ==========================================================================
   Input Section
   ========================================================================== */
.mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.75rem;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-light);
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-subtle);
}

.tab-btn.active {
  color: var(--text-main);
  background: var(--bg-subtle);
}

.input-group {
  display: flex;
  align-items: center;
  position: relative;
  background: var(--bg-page);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.375rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.input-icon {
  padding-left: 0.75rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
}

.input-group input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.75rem 0.75rem;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text-main);
  outline: none;
}

.input-group input::placeholder {
  color: #94a3b8;
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 0.75rem 1.35rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  white-space: nowrap;
}

.submit-btn:hover {
  background: var(--primary-hover);
}

.submit-btn:active {
  transform: scale(0.98);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Quick Samples */
.quick-samples {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.samples-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sample-chip {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.75rem;
  font-family: inherit;
  font-size: 0.775rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

.sample-chip:hover {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border-medium);
}

/* Textarea Form */
.textarea-group textarea {
  width: 100%;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.875rem;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-main);
  background: var(--bg-page);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease;
}

.textarea-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
}

.text-hint {
  font-size: 0.8125rem;
  color: var(--text-light);
}

/* ==========================================================================
   Alert Banner
   ========================================================================== */
.alert-box {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  margin-top: 1.25rem;
  font-size: 0.875rem;
}

.alert-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.alert-title {
  display: block;
  font-weight: 700;
}

.alert-desc {
  margin-top: 0.25rem;
  color: #b91c1c;
}

/* ==========================================================================
   Processing / Spinner State
   ========================================================================== */
.processing-card {
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: #ffffff;
}

.spinner-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.processing-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.processing-subtitle {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.pipeline-tracker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.tracker-item {
  font-size: 0.775rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-light);
  transition: all 0.3s ease;
}

.tracker-item.active {
  background: var(--primary);
  color: #ffffff;
}

.tracker-arrow {
  color: var(--border-medium);
  font-weight: 700;
  font-size: 0.8rem;
}

/* ==========================================================================
   Results Presentation
   ========================================================================== */
.results-wrapper {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-card {
  padding: 2rem;
}

.result-header {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

@media (min-width: 768px) {
  .result-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.pred-subheading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  display: block;
  margin-bottom: 0.375rem;
}

.pred-highlight {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pred-badge {
  display: inline-block;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 0.35rem 1.25rem;
  border-radius: var(--radius-md);
  text-transform: uppercase;
}

.badge-sport {
  background: var(--sport-bg);
  color: var(--sport-color);
  border: 1px solid #bae6fd;
}

.badge-finance {
  background: var(--finance-bg);
  color: var(--finance-color);
  border: 1px solid #c7d2fe;
}

.exec-time-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-light);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

/* Probabilities */
.prob-wrapper {
  min-width: 260px;
}

.prob-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.prob-bars {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.prob-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

.prob-name {
  width: 55px;
  font-weight: 600;
  color: var(--text-muted);
}

.prob-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.prob-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.fill-sport { background: var(--sport-color); }
.fill-finance { background: var(--finance-color); }

.prob-pct {
  width: 45px;
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.75rem;
}

/* Metadata Grid */
.meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

@media (min-width: 640px) {
  .meta-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.meta-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-light);
}

.meta-val {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  word-break: break-word;
}

.highlight-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
}

.meta-link {
  font-size: 0.8125rem;
  color: #2563eb;
  text-decoration: none;
  word-break: break-all;
}

.meta-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Details Tab Component
   ========================================================================== */
.details-card {
  padding: 0;
  overflow: hidden;
}

.details-tab-header {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-page);
  padding: 0.5rem 1rem 0;
  gap: 0.5rem;
  overflow-x: auto;
}

.dtab-btn {
  background: transparent;
  border: none;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.dtab-btn:hover {
  color: var(--text-main);
}

.dtab-btn.active {
  color: var(--text-main);
  border-bottom-color: var(--primary);
  background: #ffffff;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.details-tab-body {
  padding: 1.5rem;
}

.dtab-pane {
  display: none;
}

.dtab-pane.active {
  display: block;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.pane-note {
  font-size: 0.8125rem;
  color: var(--text-light);
}

.btn-copy {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy:hover {
  background: #ffffff;
  color: var(--text-main);
}

.text-content-box {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text-muted);
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.font-mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

/* Stats Row */
.stat-pills-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.stat-desc {
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 500;
}

/* Embedding Details */
.embedding-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.embed-box {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
}

.embed-title {
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase;
}

.embed-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.25rem;
}

.vocab-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  max-height: 120px;
  overflow-y: auto;
  padding: 0.75rem;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.word-chip {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.vector-box {
  background: #0f172a;
  color: #38bdf8;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  overflow-x: auto;
  letter-spacing: 0.02em;
}

.mt-4 { margin-top: 1rem; }

/* ==========================================================================
   Action Footer
   ========================================================================== */
.action-footer {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #ffffff;
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--text-light);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  border-top: 1px solid var(--border-subtle);
  background: #ffffff;
  padding: 1.25rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-light);
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.footer-separator {
  color: var(--border-medium);
}

/* Utility */
.hidden {
  display: none !important;
}
