/* =====================================================
   MAKE — Assistente de Orçamentos
   styles.css  |  Última organização: 2026

   ÍNDICE DE SECÇÕES
   ─────────────────────────────────────────────────
    1.  Reset & Base
    2.  Layout Principal (app-container, section, grid)
    3.  Header
    4.  Project Bar
    5.  Cards
    6.  Formulários
    7.  Botões
    8.  Tabs
    9.  Painel Estrutura IA / Articulado
   10.  Contexto (Upload / Ficheiros)
   11.  Chat IA (input, mensagens, áudio)
   12.  Toolbar da Estrutura
   13.  Tabela de Orçamento
   14.  Resumo / Summary Bar
   15.  Modals
   16.  Toast / Notificações
   17.  Login
   18.  Badges, Animações e Utilitários
===================================================== */


/* =====================================================
   0. THEME VARIABLES — editar apenas aqui (ou via JS)
===================================================== */

:root {
  --color-primary:   #0551b5;
  --color-secondary: #1A1A1A;
  --color-accent:    #e8d25a;
}


/* =====================================================
   1. RESET & BASE
===================================================== */

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

body {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  background: #F5F5F5;
  color: #1A1A1A;
}


/* =====================================================
   2. LAYOUT PRINCIPAL
===================================================== */

.app-container {
  width: 100%;
  padding: 16px 24px 32px;
}

.section {
  margin-bottom: 24px;
}

.grid-2-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  width: 100%;
  max-width: 1800px;
  margin: auto;
}

.hidden {
  display: none !important;
}


/* =====================================================
   3. HEADER
===================================================== */

header {
  background: var(--color-secondary);
  padding: 16px 32px;
  color: white;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  height: 42px;
}

.header-left h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #e5e5e5;
}

.header-left p {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.6;
}

.token-battery {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  height: 38px;  /* mesma altura do pill do utilizador */
}

.battery-shell {
  width: 48px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 4px;
  position: relative;
  padding: 2px;
}

.battery-shell::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 8px;
  background: rgba(255,255,255,0.4);
  border-radius: 0 2px 2px 0;
}

.battery-level {
  height: 100%;
  border-radius: 2px;
  background: #2ed573;
  transition: width 0.5s ease, background 0.5s ease;
  width: 0%;
}

#batteryText {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  font-family: 'Courier New', monospace;
  min-width: 36px;
}

/* Area do utilizador */
.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid transparent;
  transition: 0.2s;
  cursor: pointer;
}

.user-profile:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: color-mix(in srgb, var(--color-accent) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-avatar i {
  width: 16px;
  height: 16px;
  color: var(--color-accent);
}

#userEmail {
  font-size: 13px;
  font-weight: 500;
  color: #ccc;
  letter-spacing: 0.3px;
}

.divider-v {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 4px;
}

/* Botao Sair */
.logout-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #eee;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.logout-btn i {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.logout-btn:hover {
  background: #c0392b;
  border-color: #c0392b;
  color: white;
  box-shadow: 0 4px 12px rgba(192, 57, 43, 0.2);
}

.logout-btn:hover i {
  transform: translateX(3px);
}

/* AI Badge header */
.header-ai {
  display: flex;
  align-items: center;
}

.ai-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 14px;
  border-radius: 30px;
  backdrop-filter: blur(4px);
}

#aiModeLabel {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
}


/* =====================================================
   4. PROJECT BAR
===================================================== */

.project-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  padding: 12px 24px;
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid #eee;
}

.project-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: #1a1a1a;
}

.icon-gold {
  color: var(--color-accent);
}

.project-actions {
  display: flex;
  gap: 10px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: white;
  color: #444;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #f5f5f5;
  border-color: #111;
  color: #111;
}

.action-btn i {
  width: 16px;
  height: 16px;
}

.action-btn.primary {
  background: var(--color-secondary);
  color: white;
  border-color: var(--color-secondary);
}

.action-btn.primary:hover {
  background: #333;
}

.action-btn.secondary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #111;
}

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


/* =====================================================
   5. CARDS
===================================================== */

.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  width: 100%;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-secondary);
  color: white;
  padding: 12px 18px;
  border-radius: 12px 12px 0 0;
}

.card-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.card-title h3 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title h3 i {
  width: 20px;
  height: 20px;
  stroke-width: 2px;
  color: var(--color-accent);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-toggle {
  font-size: 18px;
  opacity: 0.7;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.card-subtitle {
  font-size: 11px;
  opacity: 0.6;
}

.card-content {
  padding: 20px 22px;
  position: relative;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 2000px;
  opacity: 1;
  overflow: hidden;
}

.card-content.collapsed {
  display: block !important;
  max-height: 0;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  opacity: 0;
  pointer-events: none;
}

/* Destrancar o card pai quando a estrutura esta expandida */
.card-content:has(.estrutura-expandida) {
  max-height: none !important;
  overflow: visible !important;
}

/* Tooltip "Comeca por aqui" */
.start-tooltip {
  position: absolute;
  background: var(--color-secondary);
  color: var(--color-accent);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  top: 45px;
  left: 10px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: bounceTooltip 0.5s infinite alternate;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.start-tooltip::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 15px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent var(--color-secondary) transparent;
}

@keyframes bounceTooltip {
  from { transform: translateY(0); }
  to   { transform: translateY(5px); }
}

/* Cards de orcamento em lista */
.orc-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  border: 1px solid #eee;
}

.orc-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.orc-ref   { font-weight: 600; font-size: 15px; }
.orc-total { font-weight: 600; color: #000; }

.orc-card-body {
  font-size: 14px;
  line-height: 1.5;
  color: #444;
  margin-bottom: 10px;
}

.orc-card-actions {
  text-align: right;
}

/* Card de sobreposicao IA */
.ia-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.ia-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: #333;
}

/* ── Transição Quadro / Orçamento ──────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view-enter {
  animation: fadeSlideIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* =====================================================
   6. FORMULARIOS
===================================================== */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

.field-full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: #444;
}

.field input,
.field select,
.field textarea {
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 14px;
  transition: 0.15s;
}

.field textarea {
  height: auto;
  padding: 10px 12px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(var(--color-accent-rgb, 232, 210, 90), 0.15);
  outline: none;
}


/* =====================================================
   7. BOTOES
===================================================== */

.primary-btn {
  background-color: var(--color-secondary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
}

.primary-btn:hover {
  background-color: #2a2a2a;
  transform: translateY(-1px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.primary-btn:active {
  transform: translateY(0);
}

.primary-btn i {
  width: 18px;
  height: 18px;
  stroke-width: 2.5px;
  display: block;
  transition: transform 0.2s ease;
}

.primary-btn:hover i {
  transform: scale(1.1);
}

.primary-btn:disabled {
  background-color: #444;
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.secondary-btn {
  background: var(--color-accent);
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.ghost-btn {
  background: white;
  border: 1px solid #ddd;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.ghost-btn i {
  width: 16px;
  height: 16px;
  color: #666;
}

.ghost-btn:hover i {
  color: #111;
}

.dark-btn {
  background: var(--color-secondary);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
}

.danger-btn {
  background: #c0392b;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.danger-btn:hover {
  background: #a93226;
}

.ia-btn {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 8px;
  height: 34px;
}

.actions-row {
  margin-top: 26px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.full-width {
  width: 100%;
  justify-content: center;
}


/* =====================================================
   8. TABS
===================================================== */

.tabs {
  display: flex;
  width: 100%;
  border-bottom: 2px solid #eee;
  margin-bottom: 20px;
  background: white;
}

.tab-content {
  display: none !important;
  width: 100%;
}

.tab-content.active {
  display: block !important;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #777;
  border-radius: 8px 8px 0 0;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: #f5f5f5;
  color: #333;
}

.tab-btn.active {
  color: #111;
  background: #f9f9f9;
  border-bottom: 3px solid var(--color-accent);
  font-weight: 700;
}

.tab-btn i {
  width: 18px;
  height: 18px;
  stroke-width: 2.2px;
  opacity: 0.7;
}

.tab-btn.active i {
  opacity: 1;
  color: var(--color-accent);
}


/* =====================================================
   9. PAINEL ESTRUTURA IA / ARTICULADO
===================================================== */

/* Workspace (grid com 2 colunas) */
.estrutura-workspace {
  display: grid;
  gap: 24px;
  align-items: start;
  width: 100%;
  transition: grid-template-columns 0.3s ease;
}

.estrutura-workspace.modo-ia {
  grid-template-columns: 45% 55% !important;
}

.estrutura-workspace.modo-articulado {
  grid-template-columns: 30% 70% !important;
}

.estrutura-workspace.estrutura-expandida {
  display: block !important;
}

/* Evitar que os filhos bloqueiem o encolhimento */
.estrutura-left,
#estruturaPanel {
  min-width: 0 !important;
  width: 100% !important;
}

/* Esconder a esquerda no modo expandido */
.estrutura-workspace.estrutura-expandida > .estrutura-left {
  display: none !important;
}

#estruturaPanel {
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  flex: 1;
}

/* Container de estrutura IA (painel direito) */
.ia-estrutura {
  border: 1px solid #eee;
  border-radius: 10px;
  background: white;
  display: flex;
  flex-direction: column;
  height: 520px;
  width: 100%;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ia-box {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Estado expandido */
.estrutura-workspace.estrutura-expandida .ia-estrutura {
  height: 90vh !important;
  min-height: 90vh !important;
  width: 100% !important;
  max-width: none !important;
}

#estruturaResultadoIA,
#estruturaResultadoArticulado {
  width: 100%;
  overflow-x: hidden;
}

/* Layout do tab IA */
.ia-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 20px;
  margin-top: 10px;
  align-items: start;
  height: 520px;
}

.ia-section {
  display: flex;
  flex-direction: column;
}

.ia-divider {
  height: 1px;
  background: #eee;
  margin: 26px 0;
}

/* Tab Articulado */
.articulado-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

#dropZoneArticulado {
  min-height: 160px !important;
  max-height: 180px;
  padding: 10px !important;
}

#dropZoneArticulado.drag-over::after {
  content: "Largar Articulado aqui";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  border: 2px dashed var(--color-accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--color-accent);
  z-index: 100;
  opacity: 1;
}

.articulado-observacoes {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  background: #fafafa;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.observacoes-header {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
  color: #444;
  display: flex;
  align-items: center;
  gap: 6px;
}

#listaObservacoes {
  padding-left: 20px;
  margin: 0;
}

#listaObservacoes li {
  font-size: 13px;
  margin-bottom: 8px;
  color: #555;
  line-height: 1.4;
}

.articulado-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 5px;
}

.tab-estrutura.hidden {
  display: none;
}

/* Grupos */
.grupo-container {
  border: 1px solid #ddd;
  border-radius: 12px;
  margin-bottom: 24px;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.grupo-header {
  background: #f8f9fa;
  padding: 6px 14px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 11px 11px 0 0;
  min-height: 38px;
}

.grupo-titulo {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #1a1a1a;
  flex: 1;
  outline: none;
}

.grupo-drag-handle {
  cursor: grab;
  color: #ccc;
}

.grupo-body-capitulos {
  padding: 15px;
  min-height: 60px;
  background: #fcfcfc;
  border-radius: 0 0 10px 10px;
}

.grupo-actions .table-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  color: #666;
  transition: all 0.2s;
}

.grupo-actions .table-btn:hover {
  background: #f0f0f0;
  border-color: #111;
  color: #111;
}

/* Capitulos */
.capitulo {
  margin-bottom: 12px;
}

.capitulo-header {
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.capitulo-header:hover {
  color: #000;
}

.capitulo-seta {
  font-size: 14px;
}

.capitulo-bloco {
  margin-bottom: 18px;
  animation: fadeIn 0.25s ease;
}

.capitulo-titulo {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid #eee;
  padding-bottom: 4px;
  cursor: text;
  flex: 1;
}

.capitulo-titulo:focus {
  outline: 2px solid #4a90e2;
  background: #f5f9ff;
  border-radius: 4px;
}

.capitulo-chip {
  background: #f1f2f6;
  color: #57606f;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 6px;
  white-space: nowrap;
  cursor: text;
}

.capitulo-chip:focus {
  outline: none;
  background: #e8ecff;
}

.capitulo-drag-handle {
  cursor: grab;
  color: #888;
  margin-right: 8px;
  user-select: none;
}

.capitulo-drag-handle:active {
  cursor: grabbing;
}

.novo-capitulo {
  opacity: 0.9;
}

.capitulo-header-novo {
  cursor: text;
  border: 1px dashed #d6d6d6;
  background: #fafafa;
}

.capitulo-header-novo:hover {
  background: #f5f5f5;
}

.novo-capitulo-input {
    display: inline-block;
    min-width: 200px;
    min-height: 20px;
    outline: none;
    cursor: text;
}

/* Placeholder visível quando está vazio */
.novo-capitulo-input:empty::before {
    content: attr(data-placeholder);
    color: #999;
    pointer-events: none;
    font-style: italic;
}

/* Artigos */
.artigos-lista {
  list-style: none;
  padding-left: 0;
}

.artigo-item {
  padding: 6px 0;
  cursor: default;
}

.artigo-item:hover {
  background: #f7f9fc;
}

.artigo-item:hover .drag-handle {
  color: #555;
}

.artigo-item:active {
  cursor: grabbing;
}

.artigo-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.artigo-titulo {
  flex: 1;
  min-width: 0;
}

.artigo-titulo[contenteditable="true"] {
  border-radius: 4px;
  padding: 2px 4px;
}

.artigo-titulo[contenteditable="true"]:focus {
  outline: 2px solid #4a90e2;
  background: #f5f9ff;
}

.item-tipo-texto {
  background-color: #f9f9f9 !important;
  border-left: 4px solid #d1d1d1 !important;
  margin-bottom: 8px;
  padding: 10px !important;
}

.item-tipo-texto .artigo-header {
  align-items: center;
}

.item-tipo-texto .artigo-titulo {
  font-style: italic;
  font-size: 13px;
  line-height: 1.5;
}

.artigo-metricas {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.artigo-unidade {
  background: #eef2ff;
  padding: 2px 6px;
  border-radius: 6px;
  color: #3730a3;
}

.artigo-preco-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.artigo-preco {
  padding: 4px 8px;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  min-width: 52px;
  text-align: right;
}

.artigo-preco.missing {
  background: #f3f4f6;
  color: #aaa;
  border-bottom: 1px dashed #bbb;
}

.artigo-preco-euro {
  font-size: 11px;
  color: #666;
}

.artigo-preco:empty::before {
  content: attr(data-placeholder);
  color: #aaa;
}

.artigo-quantidade {
  background: #ecfdf5;
  padding: 2px 6px;
  border-radius: 6px;
  color: #065f46;
  font-weight: 600;
}

.artigo-quantidade:empty::before,
.artigo-unidade:empty::before {
  content: attr(data-placeholder);
  color: #aaa;
}

.artigo-quantidade.missing,
.artigo-unidade.missing {
  border-bottom: 1px dashed #bbb;
}

.artigo-total {
  margin-left: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--color-secondary);
  color: white;
  font-size: 13px;
  font-weight: 600;
}

.artigo-total.missing {
  background: #e5e7eb;
  color: #999;
}

.artigo-descricao {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
  line-height: 1.35;
  min-height: 18px;
}

.artigo-descricao:empty::before {
  content: attr(data-placeholder);
  color: #999;
  font-style: italic;
  pointer-events: none;
}

.artigo-zona {
  list-style: none;
  font-weight: 600;
  color: #666;
  margin-top: 8px;
}

.artigo-zona:empty::before {
  content: "zona";
  color: #999;
}

.artigo-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.artigo-metricas,
.zona-chip,
.capitulo-chip,
.artigo-edit-btn,
.artigo-duplicate-btn,
.artigo-delete-btn {
  flex-shrink: 0;
}

.zona-chip {
  background: #eef2ff;
  color: #3742fa;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 8px;
  white-space: nowrap;
}

.artigo-edit-btn {
  border: none;
  background: none;
  cursor: pointer;
  opacity: 0.6;
}

.artigo-edit-btn:hover {
  opacity: 1;
}

.artigo-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.7;
}

.artigo-delete-btn:hover {
  opacity: 1;
  color: #e74c3c;
}

.artigo-duplicate-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.7;
}

.artigo-duplicate-btn:hover {
  opacity: 1;
}

.artigo-edicao {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.artigo-edicao.hidden {
  display: none;
}

.artigo-edicao-input {
  flex: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #ddd;
}

.artigo-edicao-btn {
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: var(--color-secondary);
  color: white;
  cursor: pointer;
}

.novo-artigo-input {
  display: inline-block;
  min-width: 140px;
  outline: none;
}

.novo-artigo-input:empty::before {
  content: attr(data-placeholder);
  color: #999;
  pointer-events: none;
}

.novo-artigo-input:focus::before {
  content: "";
}

.drag-handle {
  flex: 0 0 auto;
  margin-right: 8px;
  cursor: grab;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-ghost {
  opacity: 0.4;
  background: #eef2ff;
}

.estrutura-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.estrutura-actions button {
  position: sticky;
  bottom: 10px;
}

[contenteditable="true"] {
  cursor: text;
}

[contenteditable="true"]:focus {
  outline: 2px solid #4a90e2;
  background: #f5f9ff;
  border-radius: 4px;
}

.edit-ok {
  background: #ecfdf5;
  transition: background 0.3s ease;
}

/* Modos de visualizacao */
.modo-capitulos .capitulo        { margin-bottom: 20px; }
.modo-capitulos .artigo-zona     { font-weight: 600; color: #666; margin-top: 8px; }
.modo-zonas .capitulo            { margin-bottom: 26px; }
.modo-zonas .capitulo-titulo     { font-size: 18px; font-weight: 600; }
.modo-zonas .artigo-capitulo     { font-size: 12px; background: #eef2f7; padding: 2px 6px; border-radius: 6px; margin-left: 8px; color: #666; }
.modo-zonas .artigo-header       { display: flex; align-items: center; gap: 8px; }
.modo-zonas .artigo-titulo       { flex: 1; }
.modo-zonas .artigo-unidade      { width: 40px; text-align: right; }
.modo-zonas .zona                { margin-bottom: 28px; }
.modo-zonas .zona-header         { font-size: 18px; font-weight: 600; border-bottom: 1px solid #eee; padding-bottom: 4px; }

/* Analitica - Preços de Histórico */

.badge-historico {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--color-text-muted, #6b7280);
  background: var(--color-surface-2, #f3f4f6);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 6px;
  padding: 2px 7px;
  margin-top: 3px;
  white-space: nowrap;
}
.badge-historico strong { font-weight: 600; color: var(--color-text, #374151); }

/* ── Histórico de Preços por Capítulo ── */
.historico-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  color: var(--color-accent);
  transition: all 0.2s;
}

.historico-btn:hover {
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
  border-color: var(--color-accent);
}

.historico-btn-ativo {
  background: var(--color-accent) !important;
  border-color: var(--color-accent) !important;
  color: #fff !important;
}
.historico-painel {
  margin: 0 12px 8px 12px;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 8px;
  overflow: hidden;
  animation: fadeIn 0.15s ease;
}
.historico-vazio {
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--color-text-muted, #6b7280);
}
.historico-loading { font-style: italic; }

.historico-tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.historico-tabela thead tr {
  background: var(--color-surface-2, #f3f4f6);
}
.historico-tabela th, .historico-tabela td {
  padding: 5px 10px;
  text-align: left;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
}
.historico-tabela tbody tr:last-child td { border-bottom: none; }
.historico-tabela tbody tr:hover { background: var(--color-surface-2, #f9fafb); }

.historico-media   { font-weight: 600; }
.historico-variacao { color: var(--color-text-muted, #9ca3af); }
.historico-range   { color: var(--color-text-muted, #9ca3af); font-size: 0.74rem; }
.historico-obras   { color: var(--color-text-muted, #9ca3af); }
.historico-sem-dados td { opacity: 0.5; }
.historico-nd      { font-style: italic; }

/* =====================================================
   ESTILO UNIFICADO: SPINNER IA DOURADO
===================================================== */
.ai-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(var(--color-accent-rgb, 232, 210, 90), 0.1);
    border-top: 3px solid var(--color-accent);
    border-radius: 50%;
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Tamanho Grande (para Modals e Overlays de ecrã inteiro) */
.ai-spinner.large {
    width: 50px;
    height: 50px;
    border-width: 5px;
}

/* Tamanho Mini (se precisares dentro de botões) */
.ai-spinner.small {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.ai-btn-loading {
  opacity: 0.6;
  pointer-events: none;
}

.ia-overlay-text {
  transition: opacity 0.3s ease;
}

/* Cards de auditoria IA */
.ia-auditoria {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 10px;
}

.ia-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
  border: 1px solid #eee;
}

.ia-card-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
  color: #111;
  border-left: 4px solid var(--color-accent);
  padding-left: 8px;
}

.ia-card-body             { font-size: 14px; line-height: 1.6; color: #333; }
.ia-card-body ul          { margin-left: 18px; }
.ia-card-body li          { margin-bottom: 6px; }

/* Resumo IA (Modal) */
.ia-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 15px;
  margin-top: 10px;
}

.ia-summary-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px;
  border-left: 4px solid #ddd;
}

.card-demolir  { border-left-color: #f1c40f; background: #fffdf0; }
.card-construir { border-left-color: #e74c3c; background: #fdf2f2; }

.ia-summary-card h5 {
  margin: 0 0 8px 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ia-summary-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: #333;
}

.ia-summary-list li {
  margin-bottom: 4px;
}

/* Idioma readonly */
.estrutura-ia.readonly [contenteditable="false"] { cursor: default; }
.estrutura-ia.readonly .drag-handle,
.estrutura-ia.readonly .capitulo-drag-handle     { display: none; }
.readonly-hidden                                  { visibility: hidden; pointer-events: none; }

/* Transicoes da estrutura */
.estrutura-ia                  { transition: opacity 0.18s ease, transform 0.18s ease; }
.estrutura-ia.anim-out         { opacity: 0; transform: translateY(6px); }
.estrutura-ia.anim-in          { opacity: 0; transform: translateY(-6px); }


/* =====================================================
   10. CONTEXTO (UPLOAD / FICHEIROS)
===================================================== */

.ia-contexto {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #eee;
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 510px;
  max-height: 520px;
  width: 100%;
  transition: all 0.3s ease;
}

.contexto-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 15px;
}

/* Suporte para h4 e h5 (retrocompatibilidade) */
.contexto-header h4,
.contexto-header h5 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.contexto-header h4 i,
.contexto-header h5 i {
  width: 16px;
  height: 16px;
  color: var(--color-accent);
  stroke-width: 2.5px;
}

.empty-state p {
  font-size: 12px;
  color: #999;
  font-style: italic;
  text-align: center;
  margin-top: 20px;
}

.upload-btn-circ {
  width: 30px;
  height: 30px;
  background: var(--color-secondary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.upload-btn-circ:hover {
  background: var(--color-accent);
  transform: scale(1.1);
}

.upload-btn-circ i {
  width: 16px;
  height: 16px;
}

/* Grid de ficheiros */
.contexto-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px;
  max-height: 420px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-accent) #f1f1f1;
}

.contexto-grid::-webkit-scrollbar        { width: 5px; }
.contexto-grid::-webkit-scrollbar-track  { background: #f1f1f1; border-radius: 10px; }
.contexto-grid::-webkit-scrollbar-thumb  { background: var(--color-accent); border-radius: 10px; }
.contexto-grid::-webkit-scrollbar-thumb:hover { background: var(--color-accent); filter: brightness(0.85); }

/* Cards de ficheiro */
.file-card {
  position: relative;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
  height: 54px;
}

.file-card:hover {
  border-color: #111;
  background: #fafafa;
}

.file-icon {
  width: 24px;
  height: 24px;
  color: #444;
  flex-shrink: 0;
}

.file-name {
  font-size: 12px;
  color: #333;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.btn-remove-file {
  background: #eee;
  color: #666;
  border: none;
  border-radius: 6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
}

.btn-remove-file:hover {
  background: #ff4757;
  color: white;
}

/* Drag & Drop overlay */
.ia-contexto::after {
  content: "Largar ficheiros aqui";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  border: 2px dashed var(--color-accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--color-accent);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}

.ia-contexto.drag-over::after {
  opacity: 1;
}

.ia-contexto.drag-over {
  transform: scale(1.02);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

/* Card especial IA (Resumo Tecnico) */
.file-card.ai-context-card {
  background: linear-gradient(135deg, #fffcf0 0%, #fff 100%);
  border: 1px solid var(--color-accent);
  box-shadow: 0 4px 10px rgba(var(--color-accent-rgb, 232, 210, 90), 0.2);
}

.file-card.ai-context-card .file-icon {
  color: var(--color-accent);
}

.ai-badge {
  font-size: 8px;
  background: var(--color-accent);
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 2px;
}


/* =====================================================
   11. CHAT IA (input, mensagens, audio)
===================================================== */

.ia-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  position: relative;
}

.ai-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}

.ai-message-user {
  align-self: flex-end;
  background: var(--color-secondary);
  color: white;
  padding: 10px 14px;
  border-radius: 14px 14px 2px 14px;
  max-width: 85%;
  font-size: 13px;
  line-height: 1.4;
}

.ai-message-ai {
  align-self: flex-start;
  background: #f0f0f0;
  color: #1a1a1a;
  padding: 10px 14px;
  border-radius: 14px 14px 14px 2px;
  max-width: 85%;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid #e0e0e0;
}

/* Input area */
.ai-input-area {
  border-top: 1px solid #eee;
  padding: 10px;
  background: #fff;
  flex-shrink: 0;
}

.ai-input-area textarea {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px 12px;
  resize: none;
  overflow: hidden;
  font-size: 14px;
}

#descricaoObraInput {
  resize: none;
  overflow-y: auto;
  min-height: 36px;
  max-height: 120px;
  line-height: 1.4;
}

.ai-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Audio */
.audio-btn {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid #e5e5e5;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.audio-btn svg {
  width: 18px;
  height: 18px;
}

.audio-btn:hover {
  background: #f5f5f5;
}

.audio-btn.recording {
  background: #ff3b30;
  border-color: #ff3b30;
  color: white;
  animation: micPulse 1.2s infinite;
}

@keyframes micPulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.6); }
  70%  { box-shadow: 0 0 0 12px rgba(255, 59, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

.audio-recording {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 8px;
}

.recording-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #c53030;
}

.record-dot {
  width: 8px;
  height: 8px;
  background: #e53e3e;
  border-radius: 50%;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.3; }
  100% { opacity: 1; }
}

.wave-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 24px;
}

.wave-bars span {
  width: 4px;
  background: #ff3b30;
  border-radius: 3px;
  height: 4px;
  max-height: 24px;
  transition: height 0.1s linear;
}

/* Overlay de transcricao */
.audio-transcribing {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.audio-transcribing-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.audio-transcribing-text {
  font-size: 14px;
  color: #333;
}

.audio-controls {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}


/* =====================================================
   12. TOOLBAR DA ESTRUTURA
===================================================== */

.estrutura-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  background: rgba(30, 30, 30, 0.7) !important;
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

#toolbar-left-side  { grid-column: 1; justify-self: start; }
#idioma-selector    { grid-column: 2; justify-self: center; display: flex; background: rgba(255, 255, 255, 0.1); padding: 2px; border-radius: 8px; gap: 2px; }
.toolbar-actions    { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 8px; }

/* Botoes dentro da toolbar */
.estrutura-toolbar .action-btn,
.estrutura-toolbar .btn-icon-only {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: 6px;
}

.estrutura-toolbar .btn-icon-only {
  width: 32px;
  padding: 0;
}

.estrutura-toolbar .action-btn:hover,
.estrutura-toolbar .btn-icon-only:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
}

.btn-icon-only i {
  width: 18px;
  height: 18px;
  stroke-width: 2px;
}

/* Botao Importar */
.btn-importar {
  background: var(--color-accent) !important;
  color: #111 !important;
  border: none !important;
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(var(--color-accent-rgb, 232, 210, 90), 0.3);
}

.btn-importar:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--color-accent-rgb, 232, 210, 90), 0.4);
}

.btn-importar i {
  width: 14px;
  height: 14px;
  stroke-width: 2.5px;
}

/* Selector PT / EN */
.idioma-control button {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 800;
  border-radius: 5px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.5);
}

.idioma-control button.active {
  background: #fff !important;
  color: #111 !important;
}


/* =====================================================
   13. TABELA DE ORCAMENTO - VERSÃO CORRIGIDA E COMPLETA
===================================================== */

.table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  background: white;
  border: 1px solid #ddd;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--color-secondary);
  color: white;
  padding: 12px;
  font-size: 10px;
  text-transform: uppercase;
  text-align: left;
  z-index: 30;
}

/* Base uniforme para todas as células para evitar linhas desencontradas */
tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
  font-size: 13px;
  height: 52px; /* Altura mínima consistente */
  box-sizing: border-box;
}

/* Linha de Grupo (Amarelo) */
tr.grupo-area,
tr.grupo-area td {
  height: 30px !important;
  max-height: 30px !important;
  padding: 0 12px !important;
  line-height: 30px !important;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 11px !important;
  vertical-align: middle !important;
  overflow: hidden;
  white-space: nowrap;
  background: var(--color-accent) !important;
}

/* Linha de Capitulo (Cinzento) */
tr.grupo-categoria,
tr.grupo-categoria td {
  height: 30px !important;
  max-height: 30px !important;
  padding: 0 12px !important;
  line-height: 30px !important;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 11px !important;
  vertical-align: middle !important;
  overflow: hidden;
  white-space: nowrap;
  background: #ededed !important;
  border-top: 1px solid #ddd !important;
  border-bottom: 1px solid #ddd !important;
}

tr.grupo-categoria td {
  color: #333 !important;
  letter-spacing: 0.3px;
}

tr.grupo-categoria:hover {
  background-color: #e8e8e8 !important;
}

/* Sliders nas linhas de header */
.grupo-area .ajuste-cell,
.grupo-categoria .ajuste-cell {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  height: 30px !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

tr.grupo-area:hover .ajuste-cell,
tr.grupo-categoria:hover .ajuste-cell {
  opacity: 1;
  pointer-events: auto;
}

/* Alinhamento de Inputs e Preços */
.input-euro {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
}

.input-euro-symbol {
  font-size: 13px;
  font-weight: 600;
  color: #666;
}

.table-input {
  height: 28px;
  padding: 0 8px;
  border: 1px solid #d6d6d6;
  border-radius: 6px;
  background: #f7f7f8;
  font-size: 12.5px;
  outline: none;
}

.table-input:focus {
  border-color: var(--color-accent);
  background: #fff;
}

.table-input-qty, 
.table-input-price {
  width: 100% !important;
  max-width: 65px;
  text-align: right;
}

/* Campo de Descrição (Largo) */
.table-input-desc {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  transition: all 0.2s;
}

.table-input-desc:hover {
  border-color: #eee;
  background: #fafafa;
}

.table-input-desc:focus {
  background: #fff;
  border-color: var(--color-accent);
}

/* FIX FINAL PARA OS BOTÕES DE ACÇÃO */
td.table-actions {
  display: table-cell !important; /* NÃO usar flex aqui, senão quebra a linha */
  text-align: center !important;
  vertical-align: middle !important;
  white-space: nowrap;
}

.table-btn {
  display: inline-flex !important; /* Os botões em si podem ser flex */
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #eee;
  background: white;
  cursor: pointer;
  margin: 0 2px;
  transition: all 0.2s;
  color: #555;
}

.table-btn:hover {
  border-color: #111;
  background: #f9f9f9;
  color: #111;
}

/* Estilo Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
  height: 14px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: var(--color-secondary);
  margin-top: -6px;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input[type="range"].slider-ajustado::-webkit-slider-thumb {
  background: var(--color-accent) !important;
  border-color: var(--color-accent) !important;
}

.ajuste-label {
  font-size: 7px !important;
  margin-top: -5px;
  font-weight: 900;
  line-height: 1 !important;
}

/* Utilitários IA (Recolocados) */
.price-hint {
  margin-top: 6px;
  font-size: 0.85rem;
  color: #666;
}

.quant-card        { display: flex; flex-direction: column; gap: 12px; }
.quant-intervalo   { font-size: 0.95rem; color: #333; }
.quant-recomendado { font-size: 1.1rem; font-weight: 600; color: var(--color-accent); }
.quant-nota        { font-size: 0.85rem; color: #666; font-style: italic; }


/* =====================================================
   14. RESUMO / SUMMARY BAR
===================================================== */

.summary-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 15px 0 25px 0;
}

@media (max-width: 1200px) {
  .summary-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

.summary-card {
  background: linear-gradient(135deg, var(--color-secondary) 0%, #222222 100%);
  color: white;
  padding: 14px 22px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-bottom: 3px solid var(--color-accent);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 80px;
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--color-accent-rgb, 212, 175, 55), 0.12);
}

.summary-card .label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #999;
  margin-bottom: 2px;
}

.summary-card .value {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-accent);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: -0.5px;
  line-height: 1.2;
}


/* =====================================================
   15. MODALS
===================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-overlay.show {
  display: flex !important;
}

.modal {
  background: #ffffff;
  border-radius: 16px;
  width: 520px;
  max-width: 92%;
  max-height: 85vh;
  overflow: hidden !important;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  padding: 0 !important;
  animation: modalIn 0.2s ease-out;
  display: flex !important;
  flex-direction: column !important;
}

@keyframes modalIn {
  from { transform: translateY(10px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-small {
  width: 400px;
  max-width: 90%;
}

.modal-header {
  background-color: var(--color-secondary) !important;
  color: #ffffff !important;
  padding: 12px 20px !important;
  margin-bottom: 0 !important;
  border-bottom: none !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.modal-header h3 {
  color: #ffffff !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  margin: 0 !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-close {
  background: transparent !important;
  color: #ffffff !important;
  border-radius: 0 !important;
  width: 46px !important;
  height: 44px !important;
  margin: -12px -20px -12px 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 18px !important;
  font-weight: 300 !important;
  transition: background-color 0.1s ease !important;
  border: none;
  cursor: pointer;
}

.modal-close:hover {
  background-color: #e81123 !important;
  color: white !important;
}

.modal-content {
  padding: 24px 20px !important;
  margin-bottom: 0 !important;
  flex: 1 !important;
  max-height: 65vh;
  overflow-y: auto;
  padding-right: 4px;
}

.modal-content button { margin-top: 6px; }

.modal-content > div {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}

.modal-actions,
.btn-row {
  padding: 16px 20px !important;
  background-color: #f7f9fc !important;
  margin-top: 0 !important;
  border-top: 1px solid #eeeeee !important;
  display: flex !important;
  justify-content: flex-end !important;
  gap: 12px !important;
}

.modal-actions button,
.btn-row button {
  margin-top: 0 !important;
}

#confirmBtnAction.danger-btn {
  background: #c0392b;
  color: white;
  border: none;
}

/* Modal de Preview */
.modal-preview {
  width: 800px;
  max-width: 95%;
  height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-content-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: #F5F5F5 !important;
  border-radius: 8px;
  padding: 20px !important;
}

.modal-content-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.modal-content-preview embed,
.modal-content-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.modal-content-preview audio {
  width: 100%;
}

/* modal descrição */

#modalDescricao .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: none; /* Retirar o uppercase se preferires mais moderno */
}

#modalDescricao .modal-header h3 i {
    width: 20px;
    height: 20px;
    color: var(--color-accent);
}

/* Melhoria da TextArea da Modal de Descrição */
#descricaoTextarea {
    width: 100%;
    height: 180px;            /* Altura fixa */
    min-height: 180px;        /* Garante que não encolhe */
    max-height: 1800px;        /* Garante que não cresce */
    resize: none;             /* Bloqueia o puxador no canto inferior */
    overflow-y: auto;         /* Ativa o scroll vertical automático */
    
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 12px;      /* Bordas mais arredondadas para combinar com a app */
    background-color: #f9f9f9;
    color: #1A1A1A;
    box-sizing: border-box;   /* Garante que o padding não aumenta a largura */
    transition: all 0.2s ease;
}

#descricaoTextarea:focus {
    background-color: #ffffff;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px rgba(var(--color-accent-rgb, 212, 175, 55), 0.1);
    outline: none;
}

/* Ajuste do contentor da modal para não ter scroll duplo */
#modalDescricao .modal-content {
    overflow: hidden !important; 
    padding: 20px !important;
}

/* Ajuste nos botões da modal para comportar ícones */
#modalDescricao .modal-actions .ghost-btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

#modalDescricao .modal-actions .ghost-btn i {
    width: 16px;
    height: 16px;
    stroke-width: 2.5px;
}

/* Animação para o ícone de re-análise */
.modal-actions .ghost-btn:active i {
    transform: rotate(180deg);
    transition: transform 0.3s ease;
}

/* Garante que o botão de re-analisar fica à esquerda e os outros à direita */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Modal de relatório de auditoria */
.ia-auditoria-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    padding: 10px 0;
}

.ia-card {
    background: #ffffff;
    border-radius: 8px; /* Menos arredondado = mais sério */
    padding: 24px;
    border: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: border-color 0.2s;
}

/* Acento discreto à esquerda em vez de card colorido */
.ia-card.danger    { border-left: 4px solid var(--color-secondary); }
.ia-card.gold      { border-left: 4px solid var(--color-accent); grid-column: span 2; background: #fffcf5; }
.ia-card.highlight { border-left: 4px solid #eeeeee; }

.ia-card-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ia-card-title i {
    width: 16px;
    color: var(--color-accent);
}

/* Formatação do conteúdo interno */
.ia-card-body {
    font-size: 13.5px;
    line-height: 1.7;
    color: #333;
}

.ia-card-body strong {
    color: #000;
    font-weight: 600;
}

/* Estilo para listas que a IA gera */
.ia-card-body ul {
    margin: 0;
    padding-left: 18px;
}

.ia-card-body li {
    margin-bottom: 8px;
}

.ia-card-body p {
    margin-bottom: 12px;
}

/* Listas de Auditoria IA */
.ia-bullet-list {
    margin: 0;
    padding-left: 18px;
    list-style-type: disc;
}

.ia-bullet-list li {
    margin-bottom: 12px; /* Espaço entre pontos para facilitar leitura */
    color: #333;
    line-height: 1.6;
}

.ia-data-list ul {
    margin: 0;
    padding-left: 0;
    list-style: none; /* Lista de custos sem pontos */
}

.ia-data-list li {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 13px;
}

.ia-data-list li strong {
    font-weight: 500;
}

/* Card Gold (Proposta de Valor) maior */
.ia-card.gold .ia-card-body {
    font-size: 14px;
}

/* Loader interno para a Modal de Auditoria - VERSÃO CENTRADA */
.modal-loader {
    display: flex;
    flex-direction: column;
    align-items: center;     /* Centra horizontalmente */
    justify-content: center;    /* Centra verticalmente */
    min-height: 450px;       /* Força a modal a ficar "aberta" */
    width: 100%;
    gap: 24px;
    padding: 40px;
    text-align: center;
}

.modal-loader .loader-text {
    font-size: 16px;
    font-weight: 500;
    color: #555;
    font-family: 'Montserrat', sans-serif;
    animation: pulseText 2s infinite ease-in-out;
    max-width: 80%;
}

/* ─── MODAL EXPORTAR PDF ──────────────────────────────── */
.opcao-btn {
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid #ddd;
  background: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  color: #555;
}

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

.opcao-btn-ativo {
  background: var(--color-secondary);
  color: white !important;
  border-color: var(--color-secondary);
}

.plano-card {
  border: 1.5px solid #eee;
  border-radius: 10px;
  padding: 18px 16px;
  cursor: pointer;
  transition: 0.15s;
}

.plano-card:hover {
  border-color: var(--color-accent);
}

.plano-card-ativo {
  border-color: var(--color-secondary);
  background: #f8f9fa;
}

.plano-titulo {
  font-size: 13px;
  font-weight: 700;
  color: #222;
  margin-bottom: 4px;
}

.plano-desc {
  font-size: 11px;
  color: #999;
  margin-bottom: 10px;
}

.plano-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.plano-pill {
  font-size: 11px;
  padding: 2px 8px;
  background: #f0f0f0;
  border-radius: 10px;
  color: #555;
  font-weight: 600;
}

/* ── Dashboard tabs ──────────────────────────────── */
.dash-tab {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #888;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  transition: color 0.15s, background 0.15s;
}

.dash-tab-active {
  background: #fff;
  color: #111;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.dash-periodo {
  display: flex;
  gap: 4px;
  background: #f0f0f0;
  border-radius: 8px;
  padding: 3px;
}


/* =====================================================
   16. TOAST / NOTIFICACOES
===================================================== */

.toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 20000;
}

.toast {
  min-width: 320px;
  max-width: 420px;
  padding: 16px 18px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
  background: #ffffff;
  color: #111;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  animation: toastIn 0.25s cubic-bezier(0.22, 0.9, 0.32, 1);
}

.toast span { display: flex; align-items: center; gap: 8px; }

.toast.success { border-left: 6px solid #27ae60; }
.toast.error   { border-left: 6px solid #c0392b; }
.toast.info    { border-left: 6px solid #2980b9; }

.toast-undo-btn {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: #3742fa;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.toast-undo-btn:hover {
  background: rgba(55, 66, 250, 0.08);
  text-decoration: underline;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) translateY(0) scale(1); }
}


/* =====================================================
   17. LOGIN
===================================================== */

.login-body {
  margin: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #3a3a3a 0%, #2a2a2a 40%, #1f1f1f 100%);
  font-family: system-ui, sans-serif;
}

.login-card {
  width: 420px;
  border-radius: 22px;
  overflow: hidden;
  background: #f9f9f9;
  box-shadow:
    0 60px 120px rgba(0, 0, 0, 0.35),
    0 15px 40px rgba(0, 0, 0, 0.25);
  animation: fadeIn 0.4s ease-out;
}

.login-header {
  background: linear-gradient(135deg, var(--color-secondary), #2a2a2a);
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 3px solid var(--color-accent);
}

.login-logo {
  height: 40px;
}

.login-body-content {
  padding: 35px 55px 40px 55px;
  text-align: center;
}

.login-body-content h2 {
  margin: 0 0 20px 0;
  font-weight: 500;
  font-size: 19px;
  color: #222;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
}

.login-form input {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 14px;
  transition: all 0.2s ease;
}

.login-form input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--color-accent-rgb, 212, 175, 55), 0.15);
}

.login-error {
  margin-top: 10px;
  color: #d9534f;
  font-size: 14px;
}

.login-form .primary-btn {
  width: 60%;
  align-self: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--color-secondary), #2a2a2a);
  color: white;
  font-weight: 600;
  padding: 12px;
  transition: all 0.2s ease;
}

.login-form .primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}


/* =====================================================
   18. BADGES, ANIMACOES E UTILITARIOS
===================================================== */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Classe de visibilidade */
.view-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Estado collapsed (legado) */
.collapsed {
  display: none;
}

/* Divisoes de estado */
.divisoes-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

@keyframes crownBounce {
  0%   { transform: translateX(-50%) translateY(0) scale(1); }
  40%  { transform: translateX(-50%) translateY(-6px) scale(1.2); }
  60%  { transform: translateX(-50%) translateY(-3px) scale(1.1); }
  80%  { transform: translateX(-50%) translateY(-5px) scale(1.15); }
  100% { transform: translateX(-50%) translateY(0) scale(1); }
}

.crown-icon {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  animation: crownBounce 0.6s ease forwards;
  animation-delay: 0.8s;
  pointer-events: none;
}

@keyframes artigoEntrada {
  from {
    opacity: 0;
    transform: translateY(-6px);
    background-color: #d6f5e3;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    background-color: transparent;
  }
}

.artigo-novo {
  animation: artigoEntrada 1s ease forwards;
}

.ia-overlay-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow: hidden;
  width: 480px;
  margin-top: 8px;
}

.ia-overlay-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #333;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.10);
  animation: cardEntrada 0.4s ease forwards;
}

.ia-overlay-card .card-zona {
  font-size: 11px;
  color: #888;
  margin-left: auto;
  white-space: nowrap;
}

.ia-overlay-card .card-preco {
  font-size: 12px;
  color: #1A4A6B;
  font-weight: 600;
  white-space: nowrap;
}

@keyframes cardEntrada {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}