/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #00abc8;
  --brand-dark: #00758d;
  --brand-light: #e6f8fb;
  --brand-border: #b3e8f0;
  --success: #16a34a;
  --error: #dc2626;
  --gray-50: #f7f8f9;
  --gray-100: #f0f2f4;
  --gray-200: #e2e6ea;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1a2332;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.13);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Layout ─── */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ─── Header ─── */
.header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 24px 24px 20px;
}
.header-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.logo {
  height: 36px;
  width: auto;
}
.header-divider {
  width: 40px;
  height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  border-radius: 2px;
}
.header-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -.02em;
  margin-bottom: 4px;
}
.header-text p {
  font-size: 0.875rem;
  color: var(--gray-600);
}

/* ─── Main ─── */
.main {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 32px auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Footer ─── */
.footer {
  text-align: center;
  padding: 18px 16px;
  font-size: 0.82rem;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
  background: white;
  font-weight: 500;
}
.footer span {
  color: var(--brand-dark);
  font-weight: 600;
}

/* ─── Card ─── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  border: 1px solid var(--gray-200);
}

/* ─── Dropzone ─── */
.dropzone {
  border: 2px dashed var(--gray-200);
  border-radius: 10px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  outline: none;
}
.dropzone:hover,
.dropzone:focus,
.dropzone.drag-over {
  border-color: var(--brand);
  background: var(--brand-light);
}
.dropzone-icon {
  color: var(--gray-400);
  margin-bottom: 12px;
  transition: color .2s;
}
.dropzone:hover .dropzone-icon,
.dropzone.drag-over .dropzone-icon { color: var(--brand); }
.dropzone-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 4px;
}
.dropzone-sub {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-bottom: 12px;
}
.dropzone-formats {
  display: inline-block;
  background: var(--gray-100);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.78rem;
  color: var(--gray-600);
  letter-spacing: .04em;
  font-weight: 500;
  border: 1px solid var(--gray-200);
}

/* ─── File info ─── */
.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--brand-light);
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--brand-dark);
  font-weight: 500;
}
.file-info .file-icon { font-size: 1.1rem; }
.file-info #file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-info button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--brand-dark);
  font-size: 1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background .15s;
  opacity: .7;
}
.file-info button:hover { background: var(--brand-border); opacity: 1; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 8px;
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  font-family: var(--font);
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(0,171,200,.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,171,200,.4);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-800);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); }

#process-btn {
  display: flex;
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  font-size: 1rem;
}

/* ─── Segmentation modal ─── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(3px);
}
.modal {
  background: white;
  border-radius: 16px;
  padding: 36px 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  border: 1px solid var(--gray-200);
}
.modal-icon { font-size: 2.5rem; margin-bottom: 12px; }
.modal h2 {
  font-size: 1.15rem;
  margin-bottom: 10px;
  color: var(--gray-800);
  font-weight: 700;
}
.modal p {
  color: var(--gray-600);
  font-size: 0.9rem;
  margin-bottom: 24px;
  line-height: 1.6;
}
.modal-actions { display: flex; gap: 12px; justify-content: center; }

/* ─── Processing ─── */
.processing-animation { display: flex; justify-content: center; margin-bottom: 20px; }
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-title {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--gray-800);
}
.processing-sub {
  text-align: center;
  color: var(--gray-600);
  font-size: 0.875rem;
  margin-bottom: 20px;
}
.stream-preview {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 14px;
  font-size: 0.78rem;
  color: var(--gray-600);
  font-family: 'SF Mono', 'Fira Code', monospace;
  max-height: 150px;
  overflow: hidden;
  position: relative;
  line-height: 1.6;
}
.stream-preview::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 44px;
  background: linear-gradient(transparent, var(--gray-50));
}

/* ─── Result ─── */
.result-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--gray-100);
}
.result-icon { font-size: 2rem; flex-shrink: 0; }
.result-header h2 {
  font-size: 1.1rem;
  margin-bottom: 4px;
  font-weight: 700;
  color: var(--gray-800);
}
.result-header p { color: var(--gray-600); font-size: 0.875rem; }

/* ─── Summary ─── */
.summary-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.summary-box h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.summary-item {
  background: white;
  border-radius: 8px;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
}
.summary-item .label {
  font-size: 0.73rem;
  color: var(--gray-400);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 500;
}
.summary-item .value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-800);
}

/* ─── Result actions ─── */
.result-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* ─── CSV Preview ─── */
.csv-preview-container h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
}
.csv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.csv-table th {
  background: var(--gray-50);
  color: var(--gray-800);
  font-weight: 600;
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
  font-size: 0.78rem;
}
.csv-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-600);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.csv-table tr:last-child td { border-bottom: none; }
.csv-table tr:hover td { background: var(--brand-light); }

/* ─── Next Steps ─── */
.steps-card {
  padding-bottom: 32px;
}
.steps-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -.01em;
  margin-bottom: 6px;
}
.steps-subtitle {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-bottom: 28px;
}
.steps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.step {
  display: flex;
  gap: 16px;
  position: relative;
  padding-bottom: 28px;
}
.step:last-child { padding-bottom: 0; }

/* Vertical connector line between steps */
.step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 17px;
  top: 36px;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--brand-border) 0%, transparent 100%);
}

.step-number {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,171,200,.25);
  position: relative;
  z-index: 1;
}
.step-body {
  padding-top: 6px;
  flex: 1;
}
.step-body h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 4px;
}
.step-body p {
  font-size: 0.86rem;
  color: var(--gray-600);
  line-height: 1.6;
}
.step-tip {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 10px;
  background: var(--brand-light);
  border: 1px solid var(--brand-border);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 0.82rem;
  color: var(--brand-dark);
  line-height: 1.5;
}
.step-tip svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--brand);
}

/* ─── Utilities ─── */
.hidden { display: none !important; }

@media (max-width: 520px) {
  .card { padding: 20px 16px; }
  .modal { padding: 28px 20px; }
  .modal-actions { flex-direction: column; }
  .result-actions { flex-direction: column; }
  .result-actions .btn { width: 100%; }
  .header { padding: 20px 16px; }
}
