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

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

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

/* ===== 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;
}

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

.login-header {
  background: linear-gradient(135deg, #000000, #1a1a1a);
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 3px solid #d4af37;
}


.login-logo {
  height: 40px;
  filter: brightness(0) invert(1);
}

.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: #d4af37;
  box-shadow: 0 0 0 3px rgba(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, #000000, #1a1a1a);
  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);
}

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

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

.section{
  margin-bottom:24px;
}

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

/* ================= HEADER ================= */

header {
  background: #1A1A1A;
  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;
}

/* Container da Ã¡rea do utilizador */
.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Perfil do utilizador */
.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: rgba(212, 175, 55, 0.15); /* Dourado muito transparente */
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-avatar i {
  width: 16px;
  height: 16px;
  color: #d4af37; /* Dourado */
}

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

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

/* BotÃ£o Sair Moderno */
.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; /* Vermelho sÃ³ no hover para ser discreto */
  border-color: #c0392b;
  color: white;
  box-shadow: 0 4px 12px rgba(192, 57, 43, 0.2);
}

.logout-btn:hover i {
  transform: translateX(3px); /* Pequena animaÃ§Ã£o do Ã­cone ao sair */
}

/* ================= AI TOGGLE ================= */

.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: #e8d25a;
}

/* =====================================================
   4. 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: #d4af37; }

.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: #111;
  color: white;
  border-color: #111;
}

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

.action-btn.secondary {
  background: #e8d25a;
  border-color: #e8d25a;
  color: #111;
}

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

/* =====================================================
   4. 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:#111;
  color:white;

  padding:12px 18px;

  border-radius:12px 12px 0 0;
}

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

.collapsed{
  display:none;
}

.card-toggle{
  font-size:16px;
  opacity:.8;
  transition: transform .2s ease;
}

.card-title h3, 
.tab-btn {
  display: flex;
  align-items: center;
  gap: 10px; /* EspaÃ§o entre o Ã­cone e o texto */
}

/* Tamanho especÃ­fico para Ã­cones em tÃ­tulos */
.card-title h3 i {
  width: 20px;
  height: 20px;
  stroke-width: 2px;
  color: #d4af37; /* MantÃ©m o toque dourado nos tÃ­tulos */
}

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

.card-toggle{
  font-size:18px;
  opacity:0.7;
  cursor:pointer;
}

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

.card-content {
  padding: 20px 22px;
  position:relative;
}

/* Garante que o fechar/abrir Ã© suave */
.card-content {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 2000px; /* Um valor alto para permitir expansÃ£o */
  opacity: 1;
  overflow: hidden;
}

.card-content.collapsed {
  display: block !important; /* Sobrescreve o display:none antigo para permitir animaÃ§Ã£o */
  max-height: 0;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  opacity: 0;
  pointer-events: none;
}

/* Estilo da Tooltip "ComeÃ§a por aqui" - AGORA ABAIXO DO CAMPO */
.start-tooltip {
  position: absolute;
  background: #111;
  color: #e8d25a;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  
  /* Posicionamento abaixo do input */
  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;
}

/* Seta da tooltip - Agora a apontar para CIMA */
.start-tooltip::after {
  content: "";
  position: absolute;
  bottom: 100%; /* Seta no topo da tooltip */
  left: 15px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent #111 transparent; /* Seta preta para cima */
}

@keyframes bounceTooltip {
  from { transform: translateY(0); }
  to { transform: translateY(5px); } /* Salta para baixo */
}

.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;
}

/* =====================================================
   5. FORMS
===================================================== */

.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: #e8d25a;
  box-shadow: 0 0 0 2px rgba(232, 210, 90, 0.15);
  outline: none;
}

/* =====================================================
   6. BUTTONS
===================================================== */

.primary-btn {
  /* 1. Base SÃ³lida: Eliminamos o gradiente que causava o flash */
  background-color: #111;
  color: white;
  
  /* 2. Estrutura Flex: Alinhamento idÃªntico ao botÃ£o Sair */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  
  /* 3. DimensÃµes EstÃ¡veis: Altura fixa evita que o botÃ£o "salte" */
  padding: 0 20px;
  height: 42px; 
  border-radius: 10px;
  
  /* Borda invisÃ­vel mas presente para o layout nÃ£o mexer 1px no hover */
  border: 1px solid transparent; 
  
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  
  /* 4. TransiÃ§Ãµes EspecÃ­ficas: Evitamos 'all' para nÃ£o haver conflitos */
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  
  /* Garante nitidez sem "shimmy" de pixels */
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
}

.primary-btn:hover {
  background-color: #2a2a2a; /* MudanÃ§a de cor sÃ³lida Ã© instantÃ¢nea e suave */
  transform: translateY(-1px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Quando o botÃ£o Ã© clicado */
.primary-btn:active {
  transform: translateY(0);
}

/* Ãcone estÃ¡vel */
.primary-btn i {
  width: 18px;
  height: 18px;
  stroke-width: 2.5px;
  display: block; /* Evita desalinhamentos de linha de texto */
  transition: transform 0.2s ease;
}

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

/* Estado Desativado (IA a processar) */
.primary-btn:disabled {
  background-color: #444;
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.secondary-btn {
  background: #e8d25a;
  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;
}

.dark-btn {
  background: #1c1c1e;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
}

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

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

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

.danger-btn:hover {
  background: #a93226;
}
/* =====================================================
   7. SUMMARY
===================================================== */

.summary-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 18px 0;
}

.summary-card {
  background: linear-gradient(135deg, #0f0f0f, #222);
  color: white;
  border-radius: 14px;
  padding: 14px 18px;
}

.summary-card .label {
  font-size: 12px;
  opacity: 0.7;
}

.summary-card .value {
  font-size: 18px;
  font-weight: 700;
}

/* =====================================================
   8. TABLE
===================================================== */

.table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
}

.table-wrapper table thead th {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #e5e5e5;
}

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

thead th {
  position: sticky;
  top: 0;
  background: #111;
  color: white;
  padding: 10px;
}

tbody tr:hover {
  background: #f9fbff;
}

.grupo-area {
  background: #f2e04f;
  font-weight: bold;
}

.grupo-categoria {
  background: #f5f5f5;
  font-weight: bold;
}

.table-input{
  height: 34px;
  padding: 6px 8px;
  border: 1px solid #d6d6d6;
  border-radius: 8px;
  background: #f7f7f8;
  color: #222;
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.table-input:hover{
  background: #fff;
  border-color: #c8c8c8;
}

.table-input:focus{
  background: #fff;
  border-color: #2b6cb0;
  box-shadow: 0 0 0 3px rgba(43,108,176,0.10);
}

.table-input-qty{
  width: 92px;
  text-align: right;
}

.input-euro{
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-input-price{
  width: 92px;
  text-align: right;
}

.input-euro-symbol{
  color: #666;
  font-size: 14px;
  line-height: 1;
}

.ajuste-cell{
  min-width: 150px;
}

.ajuste-cell input[type="range"]{
  width: 100%;
}

.ajuste-label{
  font-size: 12px;
  text-align: center;
  color: #555;
  margin-top: 2px;
}

.table-input-desc{
  width: 100%;
  min-width: 260px;
  text-align: left;
  font-size: 14px;
  padding: 6px 10px;
}

.table-input-desc:focus{
  background: #fff;
  border-color: #2b6cb0;
  box-shadow: 0 0 0 2px rgba(43,108,176,0.08);
}

/* Tabela: BotÃµes de AÃ§Ã£o */
.table-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

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

.table-btn i { width: 14px; height: 14px; }

.table-btn.edit:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.table-btn.delete:hover { border-color: #c0392b; color: #c0392b; background: #fef2f2; }

/* Custom Range Slider (Ajuste de PreÃ§o) */
.ajuste-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 120px;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}

/* A calha do slider */
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: #eee;
  border-radius: 3px;
  cursor: pointer;
}

/* O botÃ£o do slider */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: #111;
  cursor: pointer;
  margin-top: -6px; /* Centra o botÃ£o na calha */
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  border: 2px solid white;
  transition: transform 0.1s ease;
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.2);
  background: #d4af37; /* Fica dourado ao arrastar */
}

.ajuste-label {
  font-size: 11px;
  font-weight: 700;
  color: #888;
}

/* =====================================================
   MODALS
===================================================== */

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

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

.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;
  /* acima da tabela */
}

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

.modal {
  background: #ffffff;
  border-radius: 16px;
  width: 520px;
  max-width: 92%;
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  padding: 20px;
  animation: modalIn .2s ease-out;
}

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

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

.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;
}

.quant-recomendado {
  font-size: 1.1rem;
  font-weight: 600;
  color: #d4af37;
}

.quant-nota {
  font-size: 0.85rem;
  color: #666;
}

/* =====================================================
   MODAL INTERNAL STRUCTURE
===================================================== */

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  background: #f2f2f2;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 16px;
  transition: 0.2s;
}

.modal-close:hover {
  background: #e0e0e0;
}

.modal-content {
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
}

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

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

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


/* ================= PREVIEW UPLOADS ================= */

/* Modal de Preview maior */
.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: #f9f9f9;
  border-radius: 8px;
  padding: 10px;
}

/* Ajustes para diferentes tipos */
.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%;
}




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

/* O container das tabs deve ocupar a largura toda e nÃ£o flutuar */
.tabs {
  display: flex;
  width: 100%;
  border-bottom: 2px solid #eee;
  margin-bottom: 20px;
  background: white;
}

/* Garante que o conteÃºdo que nÃ£o Ã© ativo fica mesmo escondido */
.tab-content {
  display: none !important; /* ForÃ§amos o ocultamento */
  width: 100%;
}

/* SÃ³ a tab com a classe .active Ã© que aparece */
.tab-content.active {
  display: block !important;
}

/* BotÃ£o de Tab individual */
.tab-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px; /* Aumentamos o tamanho consideravelmente */
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #777; /* Cor discreta para desativado */
  border-radius: 8px 8px 0 0; /* Arredondado sÃ³ no topo */
  border-bottom: 3px solid transparent; /* Reserva espaÃ§o para a linha ativa */
  transition: all 0.2s ease;
}

/* Hover - quando o rato passa */
.tab-btn:hover {
  background: #f5f5f5;
  color: #333;
}

/* ESTADO ATIVO - A Tab Selecionada */
.tab-btn.active {
  color: #111; /* Texto mais escuro */
  background: #f9f9f9; /* Um fundo muito suave para destacar */
  border-bottom: 3px solid #d4af37; /* Linha dourada grossa em baixo */
  font-weight: 700; /* Texto mais "gordo" */
}

/* Ajuste nos Ã­cones dentro das tabs */
.tab-btn i {
  width: 18px;
  height: 18px;
  stroke-width: 2.2px; /* Ãcone um pouco mais visÃ­vel */
  opacity: 0.7;
}

.tab-btn.active i {
  opacity: 1;
  color: #d4af37; /* Ãcone dourado na tab ativa */
}

/* ================= IA TAB ================= */

.ia-layout{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:20px;
  margin-top:10px;
  align-items:start;

  height:520px;
}

.ia-estrutura{
  border:1px solid #eee;
  border-radius:10px;
  padding:16px;
  min-width:760px;
  min-height:320px;
  overflow:auto;
  overflow-y:auto;
  scrollbar-width:thin;
}

/* =========================
   TAB ARTICULADO
========================= */

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

/* Aplicar o mesmo efeito Ã  zona do articulado */
#dropZoneArticulado.drag-over::after {
  content: "Largar Articulado aqui ðŸ“„";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  border: 2px dashed #d4af37;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #d4af37;
  z-index: 100;
  opacity: 1;
}

.articulado-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 600px; /* Define um limite para a coluna da esquerda */
  margin: 0 auto;   /* Centra se sobrar espaÃ§o */
}

/* Garante que as observaÃ§Ãµes nÃ£o cresÃ§am infinitamente */
.articulado-observacoes {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  background: #fafafa;
  max-height: 250px;
  overflow-y: auto;
}

/* Estilo para o botÃ£o ocupar a largura toda da coluna esquerda */
.full-width {
  width: 100%;
  justify-content: center;
}

.observacoes-header{
  font-weight:600;
  font-size:13px;
  margin-bottom:8px;
  color:#444;
}

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

#listaObservacoes li{
  font-size:13px;
  margin-bottom:6px;
  color:#555;
}

.articulado-actions{
  display:flex;
  justify-content:flex-end;
}

/* =========================
   TOOLBAR
========================= */

.estrutura-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 12px 16px;
  background: #f8f9fa; /* Cinza muito claro para distinguir do fundo */
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 10;
  border-radius: 12px 12px 0 0;
}

/* sombra sÃ³ quando expandido */
.ia-layout.estrutura-expandida .estrutura-toolbar{
  box-shadow:0 2px 6px rgba(0,0,0,0.06);
}


/* =========================
   ACTIONS (direita)
========================= */

/* Container das aÃ§Ãµes Ã  direita */
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px; /* EspaÃ§o entre os dois botÃµes */
}


/* =========================
   BASE BOTÃ•ES
========================= */

.estrutura-toolbar button{
  height:36px;
  padding:0 12px;
  border-radius:8px;
  border:1px solid #ddd;
  background:#fff;
  color:#333;
  font-size:13px;
  font-weight:500;
  cursor:pointer;
  transition: all 0.15s ease;
}

.estrutura-toolbar button:hover{
  background:#f3f3f3;
  border-color:#ccc;
}

.estrutura-toolbar button:active{
  transform:translateY(1px);
}


/* =========================
   SEGMENTED CONTROL
========================= */

/* Controlos Segmentados (Pills) */
.segmented-control, .idioma-control {
  display: flex;
  background: #eee;
  padding: 3px;
  border-radius: 10px;
}

.segmented-control button, .idioma-control button {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.segmented-control button i { width: 14px; height: 14px; }

/* Estado Ativo dos Segmentos */
.segmented-control button.active, .idioma-control button.active {
  background: white;
  color: #111;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.idioma-control{
  display:flex;
  gap:4px;
  background:#f3f4f6;
  padding:4px;
  border-radius:10px;
}

.idioma-control button{
  border:none;
  background:transparent;
  padding:6px 10px;
  border-radius:8px;
  font-size:13px;
  color:#444;
  cursor:pointer;
}

.idioma-control button.active{
  background:#fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  color:#111;
}

/* =========================
   BOTÃƒO IMPORTAR
========================= */

/* --- BOTÃƒO IMPORTAR --- */
.btn-importar {
  background: #111; /* Cor sÃ³lida para match com os botÃµes primÃ¡rios da app */
  color: white;
  border: none;
  padding: 0 16px;
  height: 36px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap; /* Impede que o texto quebre */
}

.btn-importar:hover {
  background: #2563eb; /* Muda para azul no hover para dar feedback de aÃ§Ã£o */
  transform: translateY(-1px);
}

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

/* --- BOTÃƒO EXPANDIR (Icon Only) --- */
.btn-icon-only {
  background: white;
  border: 1px solid #ddd;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #666;
  transition: all 0.2s ease;
  padding: 0; /* Remove padding que possa deslocar o Ã­cone */
}

.btn-icon-only:hover {
  border-color: #111;
  color: #111;
  background: #f8f9fa;
}

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

/* =========================
   BOTÃƒO EXPANDIR
========================= */

/* BotÃ£o Expandir (Icon Only) */
.btn-icon-only {
  background: white;
  border: 1px solid #ddd;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #666;
  transition: all 0.2s;
}

.btn-icon-only:hover {
  border-color: #111;
  color: #111;
  background: #f0f0f0;
}

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


.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;
}


.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;
}

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

/* audio overlay */
.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 .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,.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-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;
}

.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 styles */
.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:.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 .1s linear;
}

/* */

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

#descricaoObraInput {
  resize: none;
  overflow-y: auto;
  min-height: 36px;
  max-height: 120px;   /* ðŸ”¥ limite */
  line-height: 1.4;
}

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

.ai-message-user {
    align-self: flex-end;
    background: #111;
    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;
}

.ai-input-area{
  border-top:1px solid #eee;
  padding:10px;
  background:white;
}

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

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

.upload-btn{
  background:#f3f3f3;
  border-radius:8px;
  padding:6px 10px;
  font-size:13px;
  cursor:pointer;
}

.ia-contexto {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid #eee;
}

/* TÃ­tulos dentro dos containers laterais */
.contexto-header h5 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;           /* Texto mais pequeno e elegante */
  font-weight: 700;
  color: #555;
  text-transform: uppercase; /* DÃ¡ um ar de "Ficha TÃ©cnica" profissional */
  letter-spacing: 0.8px;     /* Melhora a leitura em fontes pequenas */
}

/* Ajuste do Ã­cone Lucide ao lado do tÃ­tulo */
.contexto-header h5 i {
  width: 16px;
  height: 16px;
  color: #d4af37;            /* O dourado caracterÃ­stico da tua app */
  stroke-width: 2.5px;       /* Linha um pouco mais grossa para nÃ£o sumir */
}

/* EspaÃ§amento extra para nÃ£o colar nos cards em baixo */
.contexto-header {
  display: flex;
  justify-content: space-between; /* Empurra o tÃ­tulo para a esquerda e o botÃ£o para a direita */
  align-items: center;           /* Alinha-os verticalmente pelo centro */
  width: 100%;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 15px;
}

.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: #111;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0; /* Impede que o botÃ£o encolha se o tÃ­tulo for longo */
}

.upload-btn-circ:hover {
  background: #d4af37;
  transform: scale(1.1);
}

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

.contexto-grid {
  display: flex;
  flex-direction: column; /* Lista vertical de items horizontais */
  gap: 8px;
  overflow-y: auto;
  padding: 4px;
  flex: 1;
}

.file-card {
  position: relative;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: row; /* Ãcone ao lado do nome */
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
  height: 54px; /* Altura fixa para manter ordem */
}

.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;
}

.ia-contexto {
  position: relative; /* NecessÃ¡rio para o overlay funcionar */
  transition: all 0.2s ease;
  border: 1px solid #eee;
}

/* A "mÃ¡gica": um overlay que aparece apenas durante o drag */
.ia-contexto::after {
  content: "Largar ficheiros aqui ðŸ“Ž";
  position: absolute;
  inset: 0; /* Ocupa todo o espaÃ§o da div */
  background: rgba(255, 255, 255, 0.9);
  border: 2px dashed #d4af37;
  border-radius: 12px;
  
  display: flex;
  align-items: center;
  justify-content: center;
  
  font-weight: 600;
  color: #d4af37;
  font-size: 14px;
  
  opacity: 0;
  pointer-events: none; /* Importante: nÃ£o bloqueia cliques normais */
  transition: opacity 0.2s ease;
  z-index: 100;
}

/* Quando a classe drag-over Ã© aplicada via JS */
.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 da IA */
.file-card.ai-context-card {
  background: linear-gradient(135deg, #fffcf0 0%, #fff 100%);
  border: 1px solid #e8d25a;
  box-shadow: 0 4px 10px rgba(232, 210, 90, 0.2);
}

.file-card.ai-context-card .file-icon {
  color: #d4af37;
}

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

/* Dentro do styles.css */

.ia-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); /* Ajuste automÃ¡tico */
    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; /* Amarelo */
    background: #fffdf0;
}

.card-construir { 
    border-left-color: #e74c3c; /* Vermelho */
    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;
}

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

.view-visible{
  opacity:1;
  transform: translateY(0);
}

.audio-transcribing{
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn{
  from{opacity:0}
  to{opacity:1}
}

.divisoes-actions{
  display:flex;
  gap:10px;
  margin-top:12px;
}

/* estrutura */

.estrutura-workspace{
  display:grid;
  gap:16px;
  height:100%;
  min-height:0;
  transition:grid-template-columns 0.2s ease;
  position:relative;
}

.estrutura-left{
  min-width:0;
  display:flex;
  flex-direction:column;
  min-height:0;
}

.estrutura-workspace.modo-ia{
  grid-template-columns: minmax(760px, 1.25fr) minmax(700px, 860px);
}

.estrutura-workspace.modo-articulado{
  grid-template-columns: minmax(520px, 1fr) minmax(760px, 920px);
}

.estrutura-workspace.modo-manual{
  grid-template-columns: 1fr;
}

/* expandido: ocupa o card todo */
.estrutura-workspace.estrutura-expandida{
  display:block;
}

.estrutura-workspace.estrutura-expandida > .estrutura-left{
  display:none;
}

.estrutura-workspace.estrutura-expandida > .ia-estrutura{
  width:100%;
  max-width:none;
  min-width:0;
  height:100%;
}


/* resposta IA */

.estrutura-ia{
  transition: opacity .18s ease, transform .18s ease;
}

.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;
}

.estrutura-ia.anim-out{
  opacity:0;
  transform: translateY(6px);
}

.estrutura-ia.anim-in{
  opacity:0;
  transform: translateY(-6px);
}

#estruturaResultado{
  position:relative;
}

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

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


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

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

.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;
}

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

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

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

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

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

.capitulo-titulo{
  cursor:text;
}

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

.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;
}

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

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

.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:#111;
  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:"";
}

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

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

.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{
  flex: 1;
  min-height: 20px;
  outline: none;
}

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

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

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

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

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

.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; /* laranja suave */
  color: #9a3412;
  font-size: 13px;
  min-width: 52px;
  text-align: right;
}

.artigo-preco.missing{
  background: #f3f4f6;
  color: #aaa;
}

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

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

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

.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: #111;
  color: white;
  font-size: 13px;
  font-weight: 600;
}

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

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

.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;
}

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

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


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

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

.ia-box {
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.6;
  max-height:500px;
  overflow:visible;
}

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

.ai-spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #e0e0e0;
  border-top: 3px solid #1f3a8a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

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

/* Cada secÃ§Ã£o vira um cartÃ£o */
.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-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:50;
}

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


/* TÃ­tulo do cartÃ£o */
.ia-card-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
  color: #111;
  border-left: 4px solid #e0c44c;
  padding-left: 8px;
}

/* Corpo */
.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;
}


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

.hidden{
  display: none !important;
}

/* =====================================================
   TOAST
===================================================== */

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

.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 .25s cubic-bezier(.22,.9,.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 .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);
  }
}

/* =====================================================
   OVERRIDES MODAIS (ESTILO WINDOWS E HEADER ESCURO)
   Adicionado no final para não quebrar o código original
===================================================== */

/* 1. Remover o padding do modal para o header colar às bordas */
.modal {
  padding: 0 !important;
  overflow: hidden !important; /* Corta os cantos do header arredondado */
  display: flex !important;
  flex-direction: column !important;
}

/* 2. O Header Preto (Dark Header) */
.modal-header {
  background-color: #111111 !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;
}

/* 3. O Botão de Fechar "Tipo Windows" */
.modal-close {
  background: transparent !important;
  color: #ffffff !important;
  border-radius: 0 !important; /* Remove cantos redondos */
  width: 46px !important;
  height: 44px !important;
  margin: -12px -20px -12px 0 !important; /* Estica o botão para preencher o canto */
  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;
}

.modal-close:hover {
  background-color: #e81123 !important; /* Vermelho exato do Windows */
  color: white !important;
}

/* 4. O Corpo do Modal (Espaço interno) */
.modal-content {
  padding: 24px 20px !important;
  margin-bottom: 0 !important;
  flex: 1 !important;
}

/* 5. Rodapé consistente (Botões) */
.modal-actions, .btn-row {
  padding: 16px 20px !important;
  background-color: #f7f9fc !important; /* Fundo ligeiramente cinza */
  margin-top: 0 !important;
  border-top: 1px solid #eeeeee !important;
  display: flex !important;
  justify-content: flex-end !important;
  gap: 12px !important;
}

/* Garantir que os botões não têm margens estranhas herdadas */
.modal-actions button, .btn-row button {
  margin-top: 0 !important;
}

/* Ajuste específico para o modal Preview para manter altura */
.modal-preview .modal-content-preview {
  padding: 20px !important;
  background: #F5F5F5 !important;
}

/* =====================================================
   AJUSTE SUBTIL DAS LINHAS DE CAPÍTULO
===================================================== */

/* 1. Definir a cor de fundo e a altura da linha */
.grupo-categoria {
  background-color: #ededed !important; /* Um cinza ligeiramente mais profundo que o anterior */
  border-top: 1px solid #ddd !important;   /* Linha superior para separar do bloco anterior */
  border-bottom: 1px solid #ddd !important;/* Linha inferior para "fechar" o título */
}

/* 2. Aumentar a altura interna das células do capítulo */
.grupo-categoria td {
  padding-top: 14px !important;    /* Mais espaço no topo */
  padding-bottom: 14px !important; /* Mais espaço em baixo */
  color: #333 !important;          /* Cor de texto mais forte para o título */
  font-size: 14px !important;      /* Ligeiramente maior que os artigos */
  letter-spacing: 0.3px;           /* Melhorar a legibilidade técnica */
  vertical-align: middle !important;
}

/* Opcional: Efeito de sombra muito leve para dar profundidade ao capítulo */
.grupo-categoria:hover {
  background-color: #e8e8e8 !important;
}

/* =====================================================
   ESTADO DINÂMICO DO SLIDER (BOLA AMARELA)
===================================================== */

/* 1. Quando o valor é diferente de 1 (classe aplicada por JS) */
input[type="range"].slider-ajustado::-webkit-slider-thumb {
  background: #d4af37 !important;
  border-color: #d4af37 !important;
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.4) !important;
}

/* 2. Garantir que a bola fica amarela enquanto clicamos (feedback táctil) */
input[type="range"]:active::-webkit-slider-thumb {
  background: #d4af37 !important;
  transform: scale(1.3);
}

/* 3. Transição suave para a mudança de cor */
input[type="range"]::-webkit-slider-thumb {
  transition: background-color 0.2s ease, transform 0.1s ease !important;
}


/* =====================================================
   Botões de tab Manual
===================================================== */

/* Botão Quadrado do Robô (Sugestão de Quantidade) */
.btn-icon-square {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 1px solid #ddd;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-icon-square:hover {
  border-color: #d4af37;
  background-color: #fdfdfd;
  color: #d4af37;
}

.btn-icon-square i {
  width: 18px;
  height: 18px;
}

/* Ajuste para botões ghost-btn com ícone */
.ghost-btn {
  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;
}