/* ============================================================================
 * FOLD Web Studio — Dark Audio Studio Stylesheet (Mobile-First + Desktop)
 * File: web/styles.css
 * ============================================================================ */

:root {
  --bg-root: #0b0e14;
  --bg-panel: #121722;
  --bg-elevated: #192130;
  --bg-input: #0e131d;
  --border-subtle: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.30);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #22d3ee;
  --accent-cyan-dim: rgba(34, 211, 238, 0.14);
  --accent-emerald: #10b981;
  --accent-emerald-dim: rgba(16, 185, 129, 0.16);
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-panel: 0 12px 32px rgba(0, 0, 0, 0.35);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-root);
  background-image:
    radial-gradient(circle at 12% 0%, rgba(34, 211, 238, 0.08), transparent 42%),
    radial-gradient(circle at 88% 100%, rgba(16, 185, 129, 0.07), transparent 45%);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.mono {
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}

/* App Shell */
.app-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 14px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.studio-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(16, 185, 129, 0.2));
  border: 1px solid rgba(34, 211, 238, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-shrink: 0;
}

.wave-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--accent-cyan);
}
.wave-bar:nth-child(1) { height: 10px; opacity: 0.7; }
.wave-bar:nth-child(2) { height: 22px; }
.wave-bar:nth-child(3) { height: 16px; background: var(--accent-emerald); }
.wave-bar:nth-child(4) { height: 12px; opacity: 0.8; }

.brand-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.version-pill {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-cyan);
  background: var(--accent-cyan-dim);
  border: 1px solid rgba(34, 211, 238, 0.35);
  padding: 2px 7px;
  border-radius: 999px;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-emerald-dim);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
  font-size: 0.78rem;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.status-dot.busy {
  background: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
}

/* Main Grid (Mobile-First: 1 column) */
.studio-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.file-size-tag {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

/* Mode Toggle */
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--bg-input);
  padding: 5px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.mode-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  min-height: 54px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 2px;
  transition: all 0.18s ease;
}

.mode-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.mode-btn.active {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.16), rgba(34, 211, 238, 0.06));
  border-color: rgba(34, 211, 238, 0.45);
  color: var(--text-primary);
}

.mode-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.mode-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Dropzone */
.dropzone {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 14px;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--border-strong);
  background: var(--bg-input);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  min-height: 82px;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(34, 211, 238, 0.06);
}

.dropzone-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.dropzone-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.dropzone-text strong {
  font-size: 0.9rem;
  color: var(--text-primary);
  word-break: break-word;
}

.dropzone-text span {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* Selects */
.studio-select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.studio-select:focus {
  border-color: var(--accent-cyan);
}

.dual-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 6px;
}

.field-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.helper-note {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.helper-note code {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  font-size: 0.75rem;
}

/* Buttons (Touch-friendly >= 46px) */
button {
  font-family: var(--font-sans);
}

.btn-primary,
.btn-secondary,
.btn-download,
.btn-outline {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, filter 0.15s ease, opacity 0.15s ease;
}

.btn-primary:active,
.btn-secondary:active,
.btn-download:active,
.btn-outline:active {
  transform: scale(0.99);
}

.btn-primary {
  border: none;
  background: linear-gradient(135deg, #06b6d4, #0ea5e9);
  color: #04131a;
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.28);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-primary:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.08);
  color: #cffafe;
  font-size: 0.88rem;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(34, 211, 238, 0.15);
}

.btn-download {
  border: none;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #031f16;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.28);
}

.btn-download:hover {
  filter: brightness(1.08);
}

.btn-outline {
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.88rem;
}

.btn-outline:hover {
  border-color: var(--accent-cyan);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.76rem;
  cursor: pointer;
  padding: 4px 6px;
}

.btn-text:hover {
  color: var(--text-primary);
}

/* Progress Card */
.progress-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-emerald));
  transition: width 0.16s ease-out;
}

/* Output Card */
.output-card {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.04));
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.badge-success {
  display: inline-block;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.18);
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.output-filename {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  word-break: break-all;
}

.output-summary {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: #cbd5e1;
  font-family: var(--font-mono);
}

.audio-preview {
  width: 100%;
  height: 40px;
  border-radius: 8px;
}

.output-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

/* Telemetry Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.metric-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.metric-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.metric-value {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-value.ok {
  color: var(--accent-emerald);
}

.metric-value.accent {
  color: var(--accent-cyan);
}

/* Console Log */
.console-block {
  flex: 1;
}

.console-log {
  background: #080b10;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 170px;
  max-height: 280px;
  overflow-y: auto;
  font-size: 0.76rem;
  line-height: 1.55;
  color: #cbd5e1;
}

.log-line {
  display: flex;
  gap: 8px;
  margin-bottom: 3px;
  word-break: break-word;
}

.log-ts {
  color: var(--text-muted);
  flex-shrink: 0;
}

.log-info { color: #cbd5e1; }
.log-ok { color: #34d399; }
.log-warn { color: #fbbf24; }
.log-err { color: #fb7185; }

/* Footer */
.studio-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 4px 6px;
}

/* Tablet & Desktop Breakpoints */
@media (min-width: 560px) {
  .dual-row {
    grid-template-columns: 1fr 1fr;
  }
  .output-actions {
    grid-template-columns: 1.6fr 1fr;
  }
}

@media (min-width: 900px) {
  .app-shell {
    padding: 22px 24px 32px;
    gap: 20px;
  }
  .studio-grid {
    grid-template-columns: 1.02fr 1fr;
    align-items: start;
    gap: 20px;
  }
  .panel {
    padding: 20px;
  }
  .telemetry-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .console-log {
    min-height: 240px;
    max-height: 360px;
  }
}
