/* SCRIBA V21 - progresso individual por etapa */
:root {
  --doccx-purple: #742eb0;
  --doccx-purple-dark: #5f2394;
  --doccx-bg: #f4f4f5;
  --doccx-border: #d6d6dc;
  --doccx-text: #111827;
  --doccx-muted: #5b5b66;
  --doccx-card: #ffffff;
  --doccx-error: #b00000;
  --doccx-success: #188038;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--doccx-text);
  background: var(--doccx-bg);
}

.site-header {
  min-height: 92px;
  padding: 14px clamp(18px, 3vw, 40px);
  background: var(--doccx-purple);
  color: #fff;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
}

.logo {
  width: clamp(52px, 5vw, 62px);
  height: auto;
  display: block;
}

.site-title {
  margin: 0;
  text-align: center;
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  font-weight: 800;
  letter-spacing: 0.2px;
}

.navmenu ul {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: clamp(18px, 2vw, 30px);
  list-style: none;
}

.navmenu a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
}

.mobile-nav-toggle {
  display: none;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 8px;
  border-radius: 9px;
  align-items: center;
  justify-content: center;
}

.mobile-nav-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: none;
}

.header-icon,
.button-icon,
.social-icon {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  vertical-align: -0.16em;
  color: currentColor;
}

.mobile-nav-toggle .header-icon {
  width: 24px;
  height: 24px;
}

button .button-icon {
  margin-right: 6px;
}

.main-content {
  width: min(820px, 100%);
  margin: 0 auto;
  padding: clamp(26px, 5vh, 44px) clamp(16px, 4vw, 28px) clamp(22px, 4vh, 34px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.language-select {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: clamp(0.86rem, 1.6vw, 0.98rem);
}

.language-select select {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--doccx-border);
  border-radius: 8px;
  color: var(--doccx-purple);
  background: #fff;
}

.upload-area {
  width: min(720px, 100%);
  min-height: 110px;
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--doccx-border);
  border-radius: 10px;
  background: var(--doccx-card);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.45;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.upload-prompt {
  display: inline;
  max-width: 100%;
  font-size: clamp(0.92rem, 1.7vw, 1rem);
}

.upload-prompt span { display: inline; }

.click-here {
  color: var(--doccx-purple);
  font-weight: 800;
  margin: 0 4px;
}

.upload-area.hover {
  border-color: var(--doccx-purple);
  box-shadow: 0 0 0 4px rgba(116, 46, 176, 0.12);
}

.upload-area.is-loading {
  min-height: 92px;
  cursor: wait;
}

.upload-area.has-result,
.upload-area.has-error {
  min-height: auto;
  align-items: stretch;
  justify-content: stretch;
  text-align: left;
  cursor: default;
}

.blink-red {
  color: var(--doccx-purple);
  font-weight: 800;
  animation: blink 1s infinite;
}

@keyframes blink { 50% { opacity: 0.35; } }

.transcript-card,
.error-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.transcript-header,
.error-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ededf2;
}

.transcript-header h2,
.error-header h2 {
  margin: 0;
  font-size: clamp(1rem, 1.8vw, 1.14rem);
  line-height: 1.2;
}

.transcript-time {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(116, 46, 176, 0.08);
  color: var(--doccx-purple);
  font-size: clamp(0.76rem, 1.5vw, 0.86rem);
  font-weight: 800;
  white-space: nowrap;
}

.transcript-text {
  width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
  font-size: clamp(0.98rem, 1.75vw, 1.08rem);
}

.error-header h2,
.error-message { color: var(--doccx-error); }

.error-message {
  text-align: center;
  font-weight: 800;
  line-height: 1.45;
}

.error-help {
  color: var(--doccx-muted);
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.45;
}

.processing-status {
  width: min(720px, 100%);
  display: none;
  padding: 14px;
  border: 1px solid var(--doccx-border);
  border-radius: 10px;
  background: var(--doccx-card);
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.05);
}

.processing-status.active {
  display: block;
}

.processing-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 800;
  color: var(--doccx-text);
  font-size: clamp(0.86rem, 1.7vw, 0.98rem);
}

#processingStatusPercent {
  color: var(--doccx-purple);
  white-space: nowrap;
}

.processing-progress {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #ece8f2;
}

.processing-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--doccx-purple);
  transition: width 0.45s ease;
}

.processing-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.processing-step {
  position: relative;
  padding-top: 20px;
  color: var(--doccx-muted);
  text-align: center;
  font-size: clamp(0.72rem, 1.45vw, 0.84rem);
  line-height: 1.25;
}

.processing-step::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 11px;
  height: 11px;
  border: 2px solid var(--doccx-border);
  border-radius: 999px;
  background: #fff;
  transform: translateX(-50%);
}

.processing-step.active {
  color: var(--doccx-purple);
  font-weight: 800;
}

.processing-step.active::before,
.processing-step.completed::before {
  border-color: var(--doccx-purple);
  background: var(--doccx-purple);
}

.processing-step.completed {
  color: var(--doccx-text);
}

.processing-status.done #processingStatusPercent,
.processing-status.done .processing-status-header {
  color: var(--doccx-success);
}

.processing-status.done .processing-progress-bar {
  background: var(--doccx-success);
}

.processing-status.done .processing-step::before {
  border-color: var(--doccx-success);
  background: var(--doccx-success);
}

.processing-status.error #processingStatusPercent,
.processing-status.error .processing-status-header {
  color: var(--doccx-error);
}

.processing-status.error .processing-progress-bar {
  background: var(--doccx-error);
}

.controls {
  width: min(720px, 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.border-rocketseat-dark,
button {
  border: 0;
  border-radius: 9px;
  padding: 10px 18px;
  background: var(--doccx-purple);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  min-height: 40px;
  transition: background 0.2s ease, transform 0.2s ease;
}

.border-rocketseat-dark:hover,
button:hover {
  background: var(--doccx-purple-dark);
  transform: translateY(-1px);
}


.recording-active {
  background: var(--doccx-purple-dark);
}

.recording-pulse {
  position: relative;
  animation: recordingPulse 1.05s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(116, 46, 176, 0.55);
}

.recording-pulse .button-icon,
.blinking {
  animation: recordingIconBlink 0.9s ease-in-out infinite;
}

@keyframes recordingPulse {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 0 rgba(116, 46, 176, 0.55);
  }
  70% {
    transform: translateY(-1px) scale(1.025);
    box-shadow: 0 0 0 12px rgba(116, 46, 176, 0);
  }
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 0 rgba(116, 46, 176, 0);
  }
}

@keyframes recordingIconBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.recording-status {
  width: min(720px, 100%);
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(95, 35, 148, 0.22);
  border-radius: 999px;
  background: rgba(95, 35, 148, 0.08);
  color: var(--doccx-purple-dark);
  font-size: clamp(0.86rem, 1.7vw, 0.98rem);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.recording-status.active {
  display: flex;
}

.recording-status strong {
  min-width: 52px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}

.recording-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #c00000;
}

.recording-status.is-recording .recording-dot {
  animation: recordingDotPulse 1s ease-in-out infinite;
}

.recording-status.is-finished .recording-dot {
  background: var(--doccx-success);
}

@keyframes recordingDotPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(1.25);
  }
}

#audioPlayer {
  width: min(360px, 100%);
  margin-top: 2px;
}

.site-footer {
  background: var(--doccx-purple);
  color: #fff;
  padding: 18px 14px;
  text-align: center;
  margin-top: clamp(24px, 6vh, 56px);
}

.site-footer .container {
  width: min(920px, 100%);
  margin: 0 auto;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 10px;
}

.social-links a {
  color: #fff;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  text-decoration: none;
}

.social-links a:hover {
  background: rgba(255, 255, 255, 0.14);
}

.social-links .social-icon {
  width: 19px;
  height: 19px;
}

.copyright,
.credits,
#browser-info {
  font-size: clamp(0.76rem, 2vw, 0.9rem) !important;
  line-height: 1.38;
}

@media (max-width: 760px) {
  .site-header {
    min-height: 58px;
    padding: 9px 12px;
  }

  .logo { width: 42px; }

  .site-title { font-size: 1.05rem; }

  .mobile-nav-toggle { display: inline-flex; }

  .navmenu {
    display: none;
    grid-column: 1 / -1;
    width: 100%;
  }

  .navmenu.active { display: block; }

  .navmenu ul {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-top: 8px;
  }

  .navmenu a {
    display: block;
    padding: 9px 0;
  }

  .main-content {
    padding-top: 18px;
    gap: 12px;
  }

  .upload-area {
    min-height: 106px;
    padding: 16px;
  }

  .transcript-header,
  .error-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .transcript-time {
    width: 100%;
    text-align: center;
    white-space: normal;
  }

  .processing-status {
    padding: 12px;
  }

  .processing-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 12px;
  }

  .site-footer {
    margin-top: 22px;
    padding: 15px 10px;
  }
}

@media (max-width: 420px) {
  .main-content {
    padding-left: 9px;
    padding-right: 9px;
  }

  .language-select {
    gap: 8px;
    font-size: 0.78rem;
  }

  .language-select select {
    min-height: 31px;
    max-width: 110px;
    font-size: 0.78rem;
  }

  .upload-area {
    border-radius: 7px;
    min-height: 104px;
    padding: 14px 12px;
  }

  .upload-prompt {
    font-size: 0.84rem;
  }

  .controls {
    gap: 8px;
  }

  .controls button {
    flex: 1 1 120px;
    min-height: 38px;
    padding: 9px 10px;
    font-size: 0.82rem;
  }

  .processing-status-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .processing-steps {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 10px;
  }

  .processing-step {
    padding: 0 0 0 24px;
    text-align: left;
  }

  .processing-step::before {
    top: 2px;
    left: 6px;
    transform: none;
  }

  #audioPlayer { width: 100%; }
}

/* ===== V9 - Detalhes técnicos de tempo ===== */
.technical-details {
  margin-top: 2px;
  border-top: 1px solid #ededf2;
  padding-top: 10px;
  color: var(--doccx-muted);
}

.technical-details summary {
  cursor: pointer;
  color: var(--doccx-purple);
  font-weight: 800;
  font-size: clamp(0.82rem, 1.5vw, 0.92rem);
  outline: none;
}

.technical-details summary:hover {
  color: var(--doccx-purple-dark);
}

.timing-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.timing-grid div {
  min-width: 0;
  border: 1px solid rgba(95, 35, 148, 0.26);
  background: rgba(95, 35, 148, 0.075);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.timing-grid span {
  color: #4f2874;
  font-size: 0.78rem;
  line-height: 1.25;
}

.timing-grid strong {
  color: #43136d;
  font-size: 0.82rem;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .timing-grid {
    grid-template-columns: 1fr;
  }

  .timing-grid div {
    padding: 8px;
  }
}

/* ===== V10 - Detalhamento por etapa da última requisição ===== */
.timing-note {
  margin-top: 8px;
  color: var(--doccx-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.timing-grid-primary {
  margin-top: 10px;
}

.timing-grid-primary div {
  border-color: rgba(67, 19, 109, 0.38);
  background: rgba(67, 19, 109, 0.13);
}

.timing-grid-primary span {
  color: #3d1164;
}

.timing-grid-primary strong {
  color: #2f0d4e;
}

.timing-grid-secondary {
  margin-top: 8px;
}

@media (max-width: 520px) {
  .timing-note {
    font-size: 0.76rem;
  }
}

/* ===== V12 - Detalhes técnicos em roxo escuro ===== */
.technical-details {
  border-top-color: rgba(47, 13, 78, 0.22);
  color: #3d1164;
}

.technical-details summary {
  color: #3d1164;
}

.technical-details summary:hover {
  color: #2f0d4e;
}

.timing-note {
  color: #4f2874;
}

.timing-grid div,
.timing-grid-primary div,
.timing-grid-secondary div {
  border-color: rgba(47, 13, 78, 0.46);
  background: rgba(67, 19, 109, 0.16);
}

.timing-grid span,
.timing-grid-primary span,
.timing-grid-secondary span {
  color: #3d1164;
}

.timing-grid strong,
.timing-grid-primary strong,
.timing-grid-secondary strong {
  color: #2f0d4e;
}

/* ===== Modal de segurança, cookies e privacidade ===== */
body.consent-pending {
  overflow: hidden;
}

.privacy-consent-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(17, 24, 39, 0.58);
  backdrop-filter: blur(3px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.privacy-consent-card {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid rgba(116, 46, 176, 0.22);
  box-shadow: 0 24px 70px rgba(29, 15, 46, 0.35);
  padding: clamp(18px, 4vw, 32px);
  color: var(--doccx-text);
  text-align: left;
  -webkit-overflow-scrolling: touch;
}

.privacy-consent-icon {
  width: clamp(38px, 10vw, 48px);
  height: clamp(38px, 10vw, 48px);
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #4f167e;
  color: #ffffff;
  font-size: clamp(1.08rem, 5vw, 1.35rem);
  margin-bottom: 12px;
}

.privacy-consent-card h2 {
  margin: 0 0 12px;
  color: #4f167e;
  font-size: clamp(1.05rem, 5vw, 1.55rem);
  line-height: 1.18;
}

.privacy-consent-text {
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: clamp(0.86rem, 3.6vw, 1rem);
  line-height: 1.42;
}

.privacy-consent-text p {
  margin: 0;
}

.privacy-consent-text strong {
  color: #4f167e;
}

.privacy-consent-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.privacy-consent-accept,
.privacy-consent-cancel {
  border: 0;
  border-radius: 10px;
  min-height: 42px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  white-space: normal;
  line-height: 1.2;
}

.privacy-consent-accept {
  background: #4f167e;
  color: #ffffff;
}

.privacy-consent-accept:hover {
  background: #3d1064;
}

.privacy-consent-cancel {
  background: #f1edf6;
  color: #4f167e;
}

.privacy-consent-cancel:hover {
  background: #e7ddef;
}

@media (max-width: 480px) {
  .privacy-consent-overlay {
    align-items: flex-start;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .privacy-consent-card {
    width: min(100%, calc(100vw - 20px));
    max-height: calc(100dvh - 20px);
    border-radius: 14px;
    padding: 16px 14px;
  }

  .privacy-consent-actions {
    flex-direction: column;
    margin-top: 14px;
  }

  .privacy-consent-accept,
  .privacy-consent-cancel {
    width: 100%;
    min-height: 40px;
    padding: 10px 12px;
    font-size: 0.9rem;
  }
}

@media (max-width: 360px) {
  .privacy-consent-card {
    padding: 14px 12px;
  }

  .privacy-consent-text {
    gap: 7px;
    font-size: 0.82rem;
    line-height: 1.34;
  }

  .privacy-consent-card h2 {
    font-size: 1rem;
  }
}

@media (max-height: 560px) {
  .privacy-consent-overlay {
    align-items: flex-start;
  }

  .privacy-consent-card {
    max-height: calc(100dvh - 20px);
  }
}


@media (max-width: 420px) {
  .recording-status {
    width: 100%;
    border-radius: 12px;
    padding: 9px 10px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .recording-status strong {
    min-width: auto;
  }

  .recording-pulse {
    animation-duration: 1.15s;
  }
}

/* ===== Captura opcional de lead - V19 ===== */
.lead-invite {
  margin-top: 16px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid rgba(64, 18, 103, 0.22);
  background: linear-gradient(135deg, rgba(64, 18, 103, 0.08), rgba(116, 46, 176, 0.05));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.lead-invite-content h3 {
  margin: 0 0 6px;
  color: #401267;
  font-size: clamp(1rem, 1.8vw, 1.12rem);
}

.lead-invite-content p {
  margin: 0;
  color: #3b3050;
  line-height: 1.45;
  font-size: clamp(0.88rem, 1.7vw, 0.96rem);
}

.lead-invite-internal {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(64, 18, 103, 0.1);
  color: #401267;
  font-size: 0.82rem;
  font-weight: 800;
}

.lead-form {
  display: grid;
  gap: 8px;
}

.lead-form label {
  color: #401267;
  font-size: 0.86rem;
  font-weight: 800;
}

.lead-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.lead-form input[type="email"] {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid rgba(64, 18, 103, 0.35);
  border-radius: 10px;
  color: var(--doccx-text);
  background: #fff;
  font-size: 0.95rem;
  outline: none;
}

.lead-form input[type="email"]:focus {
  border-color: #401267;
  box-shadow: 0 0 0 3px rgba(64, 18, 103, 0.13);
}

.lead-form button {
  min-height: 42px;
  border-radius: 10px;
  background: #401267;
  white-space: nowrap;
}

.lead-form button:hover {
  background: #2f0d4e;
}

.lead-form button:disabled {
  opacity: 0.72;
  cursor: wait;
  transform: none;
}

.lead-form-feedback {
  min-height: 18px;
  color: var(--doccx-error);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
}

.lead-form-feedback.success {
  color: #255f2d;
}

@media (max-width: 520px) {
  .lead-invite {
    padding: 13px;
    border-radius: 12px;
  }

  .lead-form-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .lead-form button {
    width: 100%;
  }
}

/* ===== V21: progresso por etapa (síncrono e assíncrono) ===== */
.processing-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding-top: 22px;
}

.processing-step-percent {
  display: block;
  color: var(--doccx-muted);
  font-size: clamp(0.72rem, 1.4vw, 0.82rem);
  font-weight: 800;
  line-height: 1;
}

.processing-step > span:last-child {
  display: block;
}

.processing-step.active .processing-step-percent {
  color: var(--doccx-purple);
}

.processing-step.completed .processing-step-percent {
  color: var(--doccx-text);
}

.processing-status.done .processing-step-percent {
  color: var(--doccx-success);
}

.processing-status.error .processing-step.active .processing-step-percent {
  color: var(--doccx-error);
}

@media (max-width: 560px) {
  .processing-steps {
    gap: 4px;
  }

  .processing-step {
    padding-top: 20px;
    font-size: 0.69rem;
  }

  .processing-step-percent {
    font-size: 0.7rem;
  }
}
