* { box-sizing: border-box; }

:root {
  --bg: #0b1020;
  --panel: #121a2d;
  --panel-2: #0e1628;
  --text: #eef3ff;
  --muted: #8f9ab3;
  --line: #27334d;
  --accent: #65e6b5;
  --accent-2: #4aa8ff;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at top, #18223b 0, var(--bg) 45%);
  color: var(--text);
}

.app {
  width: min(980px, calc(100% - 32px));
  margin: 34px auto;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

h1, h2, p { margin: 0; }

h1 { font-size: 28px; letter-spacing: .2px; }
.app-header p { color: var(--muted); margin-top: 5px; }

.status {
  border: 1px solid var(--line);
  background: #10192b;
  color: var(--accent);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.panel {
  background: linear-gradient(180deg, rgba(18,26,45,.98), rgba(14,22,40,.98));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 18px 45px rgba(0,0,0,.22);
  margin-bottom: 16px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
}

input[type="file"] { display: none; }

.file-button {
  cursor: pointer;
  padding: 11px 16px;
  border-radius: 10px;
  background: #1d2944;
  border: 1px solid #344462;
  font-weight: 700;
  white-space: nowrap;
}

.file-button:hover { border-color: var(--accent-2); }

.file-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info span, small { color: var(--muted); }

.transport {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin: 35px 0 22px;
}

button {
  border: 0;
  cursor: pointer;
  color: var(--text);
  font: inherit;
}

button:disabled {
  opacity: .38;
  cursor: not-allowed;
}

.play {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07111d;
  font-size: 27px;
  font-weight: 900;
  box-shadow: 0 8px 28px rgba(74,168,255,.22);
}

.secondary {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #1c2740;
  border: 1px solid #344462;
  font-size: 18px;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-family: Consolas, monospace;
  font-size: 18px;
  margin-bottom: 10px;
}

.progress-wrap {
  padding: 4px 0;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font: 11px Consolas, monospace;
  margin-top: 4px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 17px;
}

.section-title h2 { font-size: 17px; }

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.diagnostic-grid div {
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.diagnostic-grid small,
.diagnostic-grid strong {
  display: block;
}

.diagnostic-grid strong {
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

footer {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 3px;
}

@media (max-width: 680px) {
  .app { width: min(100% - 18px, 980px); margin: 18px auto; }
  .panel { padding: 17px; }
  .diagnostic-grid { grid-template-columns: repeat(2, 1fr); }
  .file-row { align-items: flex-start; }
  .scale span:nth-child(2),
  .scale span:nth-child(4) { display: none; }
}


/* ============================================================
   ETAPA 2 — Waveform / Equalizador
   ============================================================ */
.visual-panel {
  width: 100%;
  margin: 18px 0 14px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  background: rgba(9, 14, 28, .92);
  overflow: hidden;
  box-sizing: border-box;
}

.visual-header {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
  letter-spacing: .08em;
  color: rgba(255,255,255,.65);
  background: rgba(255,255,255,.025);
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.waveform-wrap {
  width: 100%;
  height: 220px;
  position: relative;
}

#waveformCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* ETAPA 3 — Régua temporal */
.timeline-panel{width:100%;margin:0 0 16px;border:1px solid rgba(255,255,255,.10);border-radius:14px;background:rgba(8,12,18,.82);overflow:hidden;box-sizing:border-box}.timeline-header{height:32px;display:flex;align-items:center;justify-content:space-between;padding:0 12px;box-sizing:border-box;font-size:11px;letter-spacing:.08em;color:rgba(255,255,255,.62);border-bottom:1px solid rgba(255,255,255,.07)}.timeline-wrap{width:100%;height:82px;position:relative}#timelineCanvas{display:block;width:100%;height:100%;cursor:pointer;touch-action:none}

/* ETAPA 4 — correção estrutural de overflow */
html, body { width:100%; max-width:100%; overflow-x:hidden; }
*, *::before, *::after { box-sizing:border-box; }
main, .app, .container, .player, .player-panel, .timeline-panel,
.waveform-panel, .controls, .content, .card { max-width:100%; min-width:0; }
canvas, audio, input, button, select { max-width:100%; }
.timeline-wrap, .waveform-wrap { max-width:100%; min-width:0; overflow:hidden; }

/* ETAPA 5 — compactação vertical e Whisper */
.app { margin-top: 14px; margin-bottom: 14px; }
.app-header { margin-bottom: 12px; }
.panel { padding: 18px; margin-bottom: 10px; }
.transport { margin: 20px 0 14px; }
.visual-panel { margin: 10px 0; }
.waveform-wrap { height: 150px; }
.timeline-panel { margin: 10px 0; }
.timeline-wrap { height: 64px; }
.whisper-panel { margin-bottom: 10px; }
.whisper-row { display:flex; align-items:center; gap:12px; min-width:0; }
.secondary-action { padding:10px 14px; border-radius:10px; background:#1c2740; border:1px solid #344462; font-size:13px; white-space:nowrap; }
#whisperDetail { color:var(--muted); font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
@media (max-height: 760px) and (min-width: 681px) {
  .app { margin-top: 8px; margin-bottom: 8px; }
  h1 { font-size: 24px; }
  .panel { padding: 14px; }
  .waveform-wrap { height: 110px; }
  .timeline-wrap { height: 52px; }
  .transport { margin: 12px 0 10px; }
  .play { width: 58px; height: 58px; font-size:22px; }
  .secondary { width:40px; height:40px; }
  .diagnostic-grid div { padding:10px; }
}
@media (max-width: 680px) {
  .waveform-wrap { height: 110px; }
  .timeline-wrap { height: 56px; }
  .whisper-row { align-items:flex-start; flex-direction:column; }
  #whisperDetail { max-width:100%; }
}

/* ETAPA 6 — arrastar áudio e arquivos Whisper */
.file-drop-zone {
  display:flex;
  align-items:center;
  gap:15px;
  min-width:0;
  padding:12px;
  border:1px dashed #344462;
  border-radius:12px;
  background:rgba(255,255,255,.018);
  transition:border-color .15s, background .15s;
}
.file-drop-zone.is-dragover,
.whisper-drop-zone.is-dragover { border-color:var(--accent); background:rgba(101,230,181,.06); }
#whisperFiles { display:none; }
.whisper-files-label { cursor:pointer; }
.whisper-row { flex-wrap:wrap; }
@media (max-width:680px) {
  .file-drop-zone { align-items:flex-start; flex-direction:column; }
}

/* ETAPA 8 */
.transcription-action{display:flex;align-items:center;gap:14px;min-width:0}
.transcribe-button{display:inline-flex;align-items:center;justify-content:center;gap:9px;min-height:46px;padding:0 18px;border-radius:10px;cursor:pointer;font-weight:700}
.transcribe-button:disabled{opacity:.45;cursor:not-allowed}
.transcribe-button.is-processing{cursor:wait}
.transcribe-icon{font-size:20px;line-height:1}
.transcription-status{display:flex;flex-direction:column;gap:3px;min-width:0}
.transcription-status strong,.transcription-status small{overflow-wrap:anywhere}
.transcription-result{margin:12px 0 0;max-height:260px;overflow:auto;white-space:pre-wrap;line-height:1.45}
@media(max-width:700px){.transcription-action{align-items:stretch;flex-direction:column}.transcribe-button{width:100%}}


/* ============================================================
   ETAPA 10 — VISUALIZAÇÃO INTEGRADA + APP CONTIDO NA TELA
   ============================================================ */
html, body {
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow: hidden;
}

body { min-height: 100%; }

.app {
  width: min(1100px, calc(100% - 24px));
  height: calc(100vh - 24px);
  max-height: calc(100vh - 24px);
  margin: 12px auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.app-header {
  flex: 0 0 auto;
  margin-bottom: 10px;
}

.app-content {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 3px;
  scrollbar-gutter: stable;
}

.app-content > section {
  min-width: 0;
}

.app-content::-webkit-scrollbar { width: 7px; }
.app-content::-webkit-scrollbar-thumb {
  background: rgba(143,154,179,.35);
  border-radius: 8px;
}

footer {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 6px 3px 0;
}

/* Um único quadro: waveform no fundo + régua sobreposta na base. */
.integrated-visual-panel {
  position: relative;
  margin: 8px 0 10px;
}

.integrated-waveform-wrap {
  height: clamp(150px, 25vh, 230px);
  position: relative;
  overflow: hidden;
  background: rgba(5,10,20,.72);
}

.integrated-waveform-wrap #waveformCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.timeline-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 62px;
  z-index: 3;
  background: linear-gradient(to bottom, rgba(8,12,18,.05), rgba(8,12,18,.92) 22%);
  border-top: 1px solid rgba(255,255,255,.10);
}

.timeline-overlay canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: none;
}

/* Cursor visual precisa atravessar waveform e régua. */
.integrated-waveform-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--playhead-x, 0%);
  width: 2px;
  transform: translateX(-1px);
  background: rgba(255,255,255,.82);
  box-shadow: 0 0 8px rgba(101,230,181,.45);
  pointer-events: none;
  z-index: 4;
  opacity: var(--playhead-opacity, 0);
}

@media (max-width: 680px) {
  .app {
    width: calc(100% - 12px);
    height: calc(100vh - 12px);
    max-height: calc(100vh - 12px);
    margin: 6px auto;
  }
  .app-header { gap: 10px; }
  h1 { font-size: 22px; }
  .integrated-waveform-wrap { height: clamp(130px, 22vh, 190px); }
  .timeline-overlay { height: 54px; }
  footer { font-size: 10px; }
}

@media (max-height: 700px) and (min-width: 681px) {
  .app { height: calc(100vh - 14px); max-height: calc(100vh - 14px); margin: 7px auto; }
  .integrated-waveform-wrap { height: 145px; }
  .timeline-overlay { height: 52px; }
  .panel { padding: 13px; }
}
