* { box-sizing: border-box; margin: 0; padding: 0; }

/* O atributo [hidden] deve sempre ocultar, mesmo quando há display explícito no CSS. */
[hidden] { display: none !important; }

:root {
  --nav-bg: #14161f;
  --nav-bg-2: #1a1c28;
  --nav-text: #9aa1b5;
  --nav-active: #ffffff;
  --surface: #f5f6fa;
  --panel: #ffffff;
  --border: #e6e8f0;
  --border-soft: #eef0f6;
  --text: #191d2b;
  --muted: #767f95;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-soft: #eef0ff;
  --success: #15803d;
  --success-soft: #e9f9f0;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #dc2645;
  --danger-soft: #fdebef;
  --shadow-sm: 0 1px 2px rgba(18, 22, 36, 0.05), 0 1px 3px rgba(18, 22, 36, 0.04);
  --shadow-md: 0 6px 20px rgba(18, 22, 36, 0.08);
  --shadow-lg: 0 20px 50px rgba(10, 12, 20, 0.3);
  --radius: 14px;
  --radius-sm: 9px;
}

html, body { height: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 14.5px; font-weight: 650; }
h4 { font-size: 11.5px; font-weight: 650; margin: 16px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; }

/* ============ FORM CONTROLS ============ */

input, button, textarea, select { font-family: inherit; font-size: 14px; }

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: #a6adc0; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.13);
}
textarea { resize: vertical; line-height: 1.55; }
select { cursor: pointer; }

button {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
  white-space: nowrap;
}
button:hover { background: var(--primary-dark); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.6; cursor: default; }

.btn-primary { box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3); }

.btn-ghost {
  background: var(--panel);
  color: var(--text);
  border: 1.5px solid var(--border);
  font-weight: 600;
}
.btn-ghost:hover { background: var(--surface); }
.btn-ghost.danger { color: var(--danger); border-color: rgba(220, 38, 69, 0.25); }
.btn-ghost.danger:hover { background: var(--danger-soft); }

.mini-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}
.mini-btn:hover { background: var(--primary-soft); }
.mini-btn.danger { color: var(--danger); }
.mini-btn.danger:hover { background: var(--danger-soft); }

label { display: block; font-size: 12.5px; color: var(--muted); margin: 13px 0 5px; font-weight: 550; }

.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.error-text { color: var(--danger); font-size: 13px; margin: 4px 0; font-weight: 500; }
.success-text { color: var(--success); font-size: 13px; margin-left: 10px; font-weight: 600; }

/* ============ LOGIN ============ */

#login-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 600px at 12% 15%, rgba(99, 102, 241, 0.55), transparent 55%),
    radial-gradient(800px 700px at 88% 85%, rgba(217, 70, 239, 0.45), transparent 55%),
    linear-gradient(135deg, #10121b 0%, #1a1030 55%, #0f1117 100%);
}
.login-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(circle at 50% 50%, #000, transparent 75%);
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  animation: cardIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 24px;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
}
.brand-mark.sm { width: 34px; height: 34px; font-size: 18px; border-radius: 10px; }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: 1.5px; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.login-heading { font-size: 22px; font-weight: 700; }
.login-desc { color: var(--muted); font-size: 14px; margin: 6px 0 24px; line-height: 1.5; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

#login-submit { width: 100%; margin-top: 6px; padding: 12px; font-size: 15px; }

/* ============ APP SHELL ============ */

#app-view { display: flex; min-height: 100vh; }

#nav {
  width: 252px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--nav-bg-2), var(--nav-bg));
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 20px 24px;
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 1.5px;
}

#nav-items { display: flex; flex-direction: column; gap: 3px; padding: 0 12px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 10px;
  color: var(--nav-text);
  text-decoration: none;
  font-weight: 550;
  font-size: 13.5px;
  transition: background 0.13s, color 0.13s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #d6dae6; }
.nav-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(168, 85, 247, 0.14));
  color: var(--nav-active);
  box-shadow: inset 0 0 0 1px rgba(120, 122, 255, 0.28);
}

.nav-footer { padding: 14px; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.nav-user { display: flex; align-items: center; gap: 10px; padding: 6px 6px 12px; }
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.nav-user-info { min-width: 0; }
#nav-user-name { color: #e8eaf2; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nav-user-role { color: var(--nav-text); font-size: 11.5px; }

.nav-footer-actions { display: flex; gap: 6px; }
.nav-action {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  color: #c3c8d6;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 6px;
}
.nav-action:hover { background: rgba(255, 255, 255, 0.12); }
.nav-action.danger:hover { background: rgba(220, 38, 69, 0.25); color: #ff98ab; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

#topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 30px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 15;
}
#page-title { font-size: 17px; font-weight: 700; }
#topbar-sub { font-size: 13px; }

#pages { padding: 26px 30px 60px; max-width: 1160px; width: 100%; margin: 0 auto; }

/* ============ CARDS / PAGES ============ */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin: 4px 0 14px; }
.page-head .muted { margin-top: 4px; }

.breadcrumb {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  padding: 4px 8px;
  border-radius: 6px;
}
.breadcrumb:hover { background: var(--primary-soft); color: var(--primary); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.toolbar input[type="search"] { max-width: 320px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.save-row { display: flex; align-items: center; margin-top: 4px; }

/* ============ STATS ============ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-grid.compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-bottom: 16px; }

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}
.stat-card.slim { padding: 13px 16px; display: block; }
.stat-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat-card.slim .stat-value { font-size: 20px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 550; margin-top: 1px; }

/* ============ TABLES ============ */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border-soft); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 650; }
tbody tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; transition: background 0.1s; }
tr.clickable:hover { background: var(--surface); }
.row-actions { text-align: right; white-space: nowrap; }

.empty-state { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty-icon {
  width: 46px; height: 46px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 20px;
}
.empty-state p { font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* ============ BADGES / TABS ============ */

.badge {
  font-size: 11px;
  font-weight: 650;
  padding: 4px 11px;
  border-radius: 20px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.status-done { background: var(--success-soft); color: var(--success); border-color: transparent; }
.status-error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.status-transcribing, .status-generating, .status-uploaded { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.tabs { display: flex; gap: 2px; border-bottom: 1.5px solid var(--border); margin: 4px 0 18px; flex-wrap: wrap; }
.tab {
  background: none;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 15px;
  margin-bottom: -1.5px;
  font-weight: 600;
}
.tab:hover { background: none; color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content p { margin: 8px 0; line-height: 1.6; }
.tab-content ul { list-style: disc; padding-left: 22px; }
.tab-content li { margin: 5px 0; line-height: 1.5; }

/* ============ RECORD / MEETING ============ */

.record-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 6px 0; }
#record-btn { background: var(--danger); box-shadow: 0 2px 10px rgba(220, 38, 69, 0.3); }
#record-btn:hover { background: #b91c3c; }
#record-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 16px;
  color: var(--danger);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
#record-timer::before {
  content: "";
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.upload-label { color: var(--muted); font-size: 13px; }
.upload-label input { width: auto; display: inline-block; border: none; padding: 4px; }

audio { width: 100%; margin: 6px 0; }

.processing {
  color: var(--warn);
  background: var(--warn-soft);
  padding: 15px 18px;
  border-radius: var(--radius-sm);
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.spinner {
  width: 16px; height: 16px;
  border: 2.5px solid rgba(180, 83, 9, 0.25);
  border-top-color: var(--warn);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  background: var(--danger-soft);
  border: 1px solid rgba(220, 38, 69, 0.2);
  color: var(--danger);
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  line-height: 1.5;
}

.ata { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 22px 26px; margin-top: 12px; background: var(--surface); }
.ata h3, .ata h4, .ata h5, .ata h6 { margin: 16px 0 6px; color: var(--text); text-transform: none; letter-spacing: 0; }
.ata p { line-height: 1.65; }

.transcript {
  white-space: pre-wrap;
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  line-height: 1.7;
  max-height: 480px;
  overflow-y: auto;
  font-size: 13.5px;
}

.key-status { font-weight: 650; color: var(--text); margin-left: 6px; }
.key-row { display: flex; gap: 8px; align-items: center; }

/* ============ TRANSCRIÇÃO AO VIVO ============ */

#live-box { margin-top: 16px; }

/* Seletor de modo de processamento */
.mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
@media (max-width: 700px) { .mode-options { grid-template-columns: 1fr; } }
.mode-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  margin: 0;
  transition: border-color 0.15s, background 0.15s;
}
.mode-card:hover { background: var(--surface); }
.mode-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.mode-card input { width: auto; margin-top: 3px; accent-color: var(--primary); }
.mode-card strong { color: var(--text); font-size: 14px; }
.mode-card p { margin-top: 4px; }
.mode-badge { margin-left: 8px; background: var(--success-soft); color: var(--success); border-color: transparent; }
.mode-badge.live { background: var(--primary-soft); color: var(--primary); }

.voice-hint {
  background: var(--primary-soft);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 14px;
}

.live-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .live-grid { grid-template-columns: 1fr; } }

.live-transcript h5 {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 12px 0 4px;
}
.live-transcript ul { list-style: disc; padding-left: 20px; }
.live-transcript li { margin: 3px 0; }

.draft-instructions { margin-bottom: 10px; }
.draft-instr {
  background: var(--success-soft);
  color: var(--success);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 5px;
}
.live-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 8px;
}
.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1s infinite;
}
.live-transcript {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  min-height: 90px;
  max-height: 280px;
  overflow-y: auto;
  line-height: 1.65;
  font-size: 14px;
}
.live-transcript p { margin: 0 0 8px; }
.live-transcript .pending { color: var(--muted); }

/* ============ CHAT DE REVISÃO ============ */

#chat-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
  max-height: 340px;
  overflow-y: auto;
}
.chat-msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 13.5px;
  white-space: pre-wrap;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg.assistant.error { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.chat-msg.thinking { color: var(--muted); font-style: italic; }
.chat-msg .dots { animation: pulse 1.2s infinite; }

.chat-input-row { display: flex; gap: 10px; margin: 0; flex-direction: row; }
.chat-input-row input { flex: 1; }

/* ============ MODAIS ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 14, 22, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 24px;
  animation: cardIn 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h3 { font-size: 16px; }
.modal-close {
  background: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 2px 8px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--surface); color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ============ TOASTS ============ */

#toasts {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}
.toast {
  background: #1c202e;
  color: #fff;
  padding: 12px 18px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 550;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  max-width: 360px;
  border-left: 3px solid var(--success);
}
.toast.error { border-left-color: var(--danger); }
.toast.show { opacity: 1; transform: none; }

/* ============ RESPONSIVE ============ */

@media (max-width: 900px) {
  #app-view { flex-direction: column; }
  #nav { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 8px 10px; }
  .nav-brand { padding: 8px 10px; }
  #nav-items { flex-direction: row; padding: 0; overflow-x: auto; }
  .nav-item span { display: none; }
  .nav-footer { border-top: none; padding: 6px; margin-left: auto; }
  .nav-user { display: none; }
  #pages { padding: 18px 14px 50px; }
  #topbar { padding: 0 16px; }
  .grid-2 { grid-template-columns: 1fr; }
}
