@tailwind base;
@tailwind components;
@tailwind utilities;

@font-face {
  font-family: "Poppins";
  src: url("../fonts/poppins.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

html {
  font-family: "Poppins", sans-serif;
}

body {
  margin: 0;
  padding: 0;
  /* Clean solid surface to reduce visual fatigue */
  background-color: var(--bg-surface);
  background-image: none;
  color: #e6e6ef;
}

#btn-loading {
  display: none;
}

#btn-loading.htmx-request {
  display: flex;
  opacity: 1;
}

#btn-text.htmx-request {
  opacity: 0;
}

#file-description.htmx-request {
  opacity: 0.5;
  pointer-events: none;
  cursor: none;
}

/* ═══════════════════════════════════════════════════════════════
   ALCUTE Design System v2 — dark premium UI
   ═══════════════════════════════════════════════════════════════ */

/* ── Color tokens ────────────────────────────────────────────── */
:root {
  --c-purple-900: #0d0819;
  --c-purple-800: #13082a;
  --c-purple-700: #1a0e38;
  --c-purple-600: #27154e;
  --c-purple-500: #7c3aed;
  --c-purple-400: #8b5cf6;
  --c-purple-300: #a78bfa;
  --c-purple-200: #c4b5fd;
  --c-green-500: #10b981;
  --c-red-500: #ef4444;
  --c-amber-500: #f59e0b;
  --glass-bg: rgba(18, 10, 40, 0.72);
  --glass-border: rgba(124, 58, 237, 0.16);
  --glass-blur: blur(14px);
  --bg-surface: #0d0618;
  /* new clean background */
}

/* ── Loading skeletons ───────────────────────────────────────── */
.skeleton-grid {
  display: flex;
  gap: 10px;
}

.skeleton-card {
  width: 100%;
  height: 64px;
  border-radius: 8px;
  background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.02),
      rgba(255, 255, 255, 0.03),
      rgba(255, 255, 255, 0.02));
  animation: pulse-skel 1.4s infinite;
  border: 1px solid rgba(124, 58, 237, 0.06);
}

@keyframes pulse-skel {
  0% {
    opacity: 0.8;
  }

  50% {
    opacity: 0.6;
  }

  100% {
    opacity: 0.8;
  }
}

/* ── Toasts ─────────────────────────────────────────────────── */
.alcute-toast-container {
  position: fixed;
  right: 18px;
  top: 56px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alcute-toast {
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(17, 15, 30, 0.95);
  color: white;
  border: 1px solid rgba(124, 58, 237, 0.12);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  font-size: 13px;
}

.alcute-toast--info {
  border-left: 4px solid var(--c-purple-500);
}

.alcute-toast--success {
  border-left: 4px solid var(--c-green-500);
}

.alcute-toast--warn {
  border-left: 4px solid var(--c-amber-500);
}

.alcute-toast--error {
  border-left: 4px solid var(--c-red-500);
}

/* ── Light mode (minimal) ───────────────────────────────────── */
body.light-mode {
  background-color: #f7f7fb;
  color: #0f172a;
}

body.light-mode .glass-card {
  background: rgba(255, 255, 255, 0.85);
  color: #0f172a;
  box-shadow: 0 6px 20px rgba(13, 13, 27, 0.05);
}

body.light-mode .btn-primary {
  color: white;
}

/* ── Custom scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.32);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(124, 58, 237, 0.55);
}

/* ── Keyframes ───────────────────────────────────────────────── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Pulsing red recording dot */
@keyframes pulse-rec {

  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  }

  50% {
    opacity: 0.7;
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
}

/* Ambient glow on the SVG ring while recording */
@keyframes glow-ring {

  0%,
  100% {
    filter: drop-shadow(0 0 4px rgba(124, 58, 237, 0.4));
  }

  50% {
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.75));
  }
}

/* Entrada de card com deslize */
@keyframes slide-down {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Glass card ──────────────────────────────────────────────── */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ── Recording dot ───────────────────────────────────────────── */
.rec-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-red-500);
  flex-shrink: 0;
  animation: pulse-rec 1.5s ease-in-out infinite;
}

/* ── Primary CTA button ──────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 55%, #5b21b6 100%);
  border: none;
  color: white;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.02em;
  position: relative;
  overflow: hidden;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.45);
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg,
      rgba(255, 255, 255, 0.1) 0%,
      transparent 60%);
  border-radius: inherit;
  pointer-events: none;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.6);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0px);
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.4);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary:focus-visible {
  outline: 2px solid var(--c-purple-300);
  outline-offset: 3px;
}

/* ── Secondary button ────────────────────────────────────────── */
.btn-secondary {
  width: 100%;
  padding: 10px 16px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid rgba(124, 58, 237, 0.28);
  color: #9ca3af;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s,
    background 0.15s;
}

.btn-secondary:hover {
  border-color: rgba(124, 58, 237, 0.55);
  color: var(--c-purple-200);
  background: rgba(124, 58, 237, 0.07);
}

.btn-secondary:active {
  background: rgba(124, 58, 237, 0.12);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--c-purple-300);
  outline-offset: 3px;
}

/* ── SVG timer ring ──────────────────────────────────────────── */
.timer-ring-track {
  fill: none;
  stroke: rgba(124, 58, 237, 0.14);
  stroke-width: 5;
}

.timer-ring-progress {
  fill: none;
  stroke: url(#ringGradient);
  stroke-width: 5;
  stroke-linecap: round;
  transform-origin: 50% 50%;
  transform: rotate(-90deg);
  transition: stroke-dashoffset 0.8s ease;
  animation: glow-ring 2.5s ease-in-out infinite;
}

/* ── Panel header ────────────────────────────────────────────── */
.panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(124, 58, 237, 0.13);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-header-title {
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Live transcript ─────────────────────────────────────────── */
.transcript-box {
  height: 150px;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Checklist ───────────────────────────────────────────────── */
.chk-label {
  font-size: 11px;
  color: #d1d5db;
  line-height: 1.4;
  transition: color 0.2s;
}

input[type="checkbox"]:checked+.chk-label {
  color: #4b5563;
  text-decoration: line-through;
}

/* ═══════════════════════════════════════════════════════════════
   RECORD PAGE — Layout v3
   ═══════════════════════════════════════════════════════════════ */

/* ── Root wrapper ────────────────────────────────────────────── */
.rec-root {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 37px);
  overflow: hidden;
}

/* ── Header bar ──────────────────────────────────────────────── */
.rec-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(10, 5, 22, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(124, 58, 237, 0.16);
  flex-shrink: 0;
  gap: 8px;
  min-height: 44px;
  -webkit-app-region: drag;
  user-select: none;
}

.rec-hdr button,
.rec-hdr input,
.rec-hdr a {
  -webkit-app-region: no-drag;
}

.rec-hdr-lead {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.rec-hdr-name {
  font-size: 12px;
  font-weight: 700;
  color: #f3f4f6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.rec-hdr-sub {
  font-size: 10px;
  color: #6b7280;
  letter-spacing: 0.02em;
}

.rec-hdr-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

/* ── Connection badge ────────────────────────────────────────── */
.conn-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid transparent;
  transition:
    background 0.3s,
    border-color 0.3s;
}

.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.conn-lbl {
  color: inherit;
}

.conn--wait {
  background: rgba(75, 85, 99, 0.18);
  border-color: rgba(75, 85, 99, 0.25);
  color: #9ca3af;
}

.conn--wait .conn-dot {
  background: #6b7280;
}

.conn--ok {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.28);
  color: #6ee7b7;
}

.conn--ok .conn-dot {
  background: #10b981;
}

.conn--err {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.conn--err .conn-dot {
  background: #ef4444;
}

/* ── Phase chip (closer) ─────────────────────────────────────── */
.phase-chip {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(124, 58, 237, 0.18);
  border: 1px solid rgba(124, 58, 237, 0.3);
  color: #c4b5fd;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ── Main grid ───────────────────────────────────────────────── */
.rec-grid {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── Left column ─────────────────────────────────────────────── */
.rec-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 8px;
  overflow-y: auto;
  min-width: 0;
}

/* ── Recording card ──────────────────────────────────────────── */
.rec-card {
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.rec-card form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rec-card .btn-primary,
.rec-card .btn-secondary {
  width: 100%;
  max-width: 220px;
}

/* ── Timer wrapper ───────────────────────────────────────────── */
.timer-wrap {
  position: relative;
  width: 132px;
  height: 132px;
  flex-shrink: 0;
  margin-bottom: 18px;
}

.timer-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  pointer-events: none;
}

.timer-digits {
  font-size: 28px;
  font-weight: 800;
  color: white;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.timer-sub {
  font-size: 9.5px;
  color: #6b7280;
  letter-spacing: 0.06em;
}

/* ── Transcript panel ────────────────────────────────────────── */
.transcript-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 160px;
  overflow: hidden;
}

/* ── Transcript chat area ────────────────────────────────────── */
.transcript-chat {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* ── Transcript message bubble ───────────────────────────────── */
.tmsg {
  display: flex;
  width: 100%;
}

.tmsg--seller {
  justify-content: flex-start;
}

.tmsg--client {
  justify-content: flex-end;
}

.tmsg--unknown {
  justify-content: flex-start;
}

.tmsg-bubble {
  max-width: 88%;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 7px 10px;
  animation: slide-down 0.2s ease forwards;
}

.tmsg--client .tmsg-bubble {
  border-radius: 10px 10px 2px 10px;
}

.tmsg--seller .tmsg-bubble {
  border-radius: 10px 10px 10px 2px;
}

.tmsg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.tmsg-badge {
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.tmsg-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.tmsg-conf {
  font-size: 9px;
  color: #4b5563;
  font-weight: 500;
}

.tmsg-ts {
  font-size: 9px;
  color: #4b5563;
  font-variant-numeric: tabular-nums;
}

.tmsg-text {
  font-size: 11.5px;
  color: #e5e7eb;
  line-height: 1.55;
  word-break: break-word;
  margin: 0;
  font-family: inherit;
}

/* ── Right column ────────────────────────────────────────────── */
.rec-right {
  width: 220px;
  flex-shrink: 0;
  border-left: 1px solid rgba(124, 58, 237, 0.14);
  background: rgba(8, 4, 18, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 0;
}

/* ── Phase + checklist panel ─────────────────────────────────── */
.phase-panel {
  flex-shrink: 0;
  max-height: 52%;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border: none;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
  overflow: hidden;
}

/* ── Phase bar segments ──────────────────────────────────────── */
.pseg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(124, 58, 237, 0.18);
  transition: background 0.3s;
}

.pseg--on {
  background: #7c3aed;
}

/* ── Phase scale labels ──────────────────────────────────────── */
.phase-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
}

.phase-scale span {
  font-size: 8px;
  color: #374151;
}

/* ── Section label ───────────────────────────────────────────── */
.sec-lbl {
  font-size: 9.5px;
  color: #4b5563;
  margin: 0 0 7px 0;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── Checklist rows ──────────────────────────────────────────── */
.chklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chk-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  cursor: pointer;
}

/* ── Responsive: small window / mobile ──────────────────────── */
@media (max-width: 540px) {
  .rec-grid {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .rec-right {
    width: 100%;
    border-left: none;
    border-top: 1px solid rgba(124, 58, 237, 0.14);
    min-height: 180px;
    max-height: 280px;
    flex-direction: row;
    overflow: hidden;
  }


  .phase-panel {
    flex: 1;
    max-height: none;
  }

  .rec-left {
    overflow-y: visible;
  }

  .rec-hdr-name {
    max-width: 110px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   Melhorias visuais — menu, spinners, titlebar e tema claro
   ═══════════════════════════════════════════════════════════════ */

/* ── Itens do menu lateral (hover/foco consistentes) ─────────── */
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #d1d5db;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .15s, color .15s;
}

.menu-item:hover {
  background: rgba(124, 58, 237, 0.14);
  color: var(--c-purple-200);
}

.menu-item:active {
  background: rgba(124, 58, 237, 0.2);
}

.menu-item:focus-visible {
  outline: 2px solid var(--c-purple-300);
  outline-offset: -2px;
}

/* ── Spinner de carregamento em botões (HTMX) ────────────────── */
.btn-spinner {
  display: none;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}

/* HTMX adiciona .htmx-request ao elemento/form em requisição */
.htmx-request .btn-spinner,
.htmx-request.btn-spinner {
  display: inline-block;
}

.btn-label {
  transition: opacity .15s;
}

.htmx-request .btn-label {
  opacity: .55;
}

/* ── Botões de ícone da titlebar (minimizar, tema) ───────────── */
.titlebar-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1;
  transition: background .15s, color .15s;
}

.titlebar-btn:hover {
  background: rgba(124, 58, 237, 0.2);
  color: #fff;
}

.titlebar-btn:focus-visible {
  outline: 2px solid var(--c-purple-300);
  outline-offset: 1px;
}

/* ── Tema claro (opt-in — escuro continua o padrão) ──────────── */
body.light-mode {
  --bg-surface: #f4f4fb;
  --glass-bg: rgba(255, 255, 255, 0.92);
  --glass-border: rgba(124, 58, 237, 0.2);
  color: #1f2230;
}

body.light-mode .glass-card {
  color: #1f2230;
  box-shadow: 0 4px 18px rgba(20, 20, 40, 0.08);
}

/* números das métricas (têm color inline branco) */
body.light-mode #metric-total,
body.light-mode #metric-opened,
body.light-mode #metric-conv {
  color: #1f2230 !important;
}

body.light-mode .menu-item {
  color: #334155;
}

body.light-mode .menu-item:hover {
  background: rgba(124, 58, 237, 0.12);
  color: #6d28d9;
}

body.light-mode .btn-secondary {
  color: #6d28d9;
  border-color: rgba(124, 58, 237, 0.4);
}

/* texto da tela inicial vazia (tem color inline claro) */
body.light-mode .empty-hint {
  color: #475569 !important;
}

body.light-mode .empty-hint strong {
  color: #1f2230 !important;
}

/* ── Linha do tempo de processamento ─────────────────────────── */
.proc-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  font-size: 12.5px;
  border-radius: 6px;
  transition: background .2s;
}

.proc-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.proc-spin {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(124, 58, 237, 0.3);
  border-top-color: #a78bfa;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.proc-lbl {
  color: #6b7280;
}

.proc-done .proc-lbl {
  color: #9aa0ad;
}

.proc-current {
  background: rgba(124, 58, 237, 0.1);
}

.proc-current .proc-lbl {
  color: #fff;
  font-weight: 600;
}

.proc-pending .proc-lbl {
  color: #6b7280;
}

/* ═══════════════════════════════════════════════════════════════
   Padronização de inputs + ajustes de legibilidade
   ═══════════════════════════════════════════════════════════════ */

/* ── Input padrão (com estado de foco, que faltava) ──────────── */
.input-field {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 13px;
  border-radius: 8px;
  background: rgba(28, 18, 54, 0.75);
  border: 1px solid rgba(43, 28, 74, 0.9);
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.input-field::placeholder {
  color: #8b93a3;
}

.input-field:focus {
  border-color: var(--c-purple-400);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
}

/* ── Legibilidade: fontes minúsculas um pouco maiores e cinzas
   secundários mais claros (melhora contraste sem mudar layout) ─ */
.rec-hdr-sub        { font-size: 11px;   color: #8b93a3; }
.timer-sub          { font-size: 10.5px; color: #8b93a3; }
.phase-scale span   { font-size: 9px;    color: #6b7280; }
.sec-lbl            { font-size: 10.5px; color: #8b93a3; }
.tmsg-conf,
.tmsg-ts            { font-size: 10px;   color: #9aa0ad; }
.tmsg-text          { font-size: 12.5px; }
.chk-label          { font-size: 12px; }
.panel-header-title { font-size: 10.5px; color: #9aa3b2; }
.phase-chip,
.conn-badge         { font-size: 10.5px; }