/* ================================================================
   MÒDUL D'ANONIMITZACIÓ — Estils complementaris
   Únicament cobreix elements específics de l'eina que no aporta
   la maqueta DIBA (diba-maqueta.min.css / Bootstrap).
   ================================================================ */

/* ── CLASSES AUXILIARS (seguint formularis.html DIBA) ─────────── */
.help-block {
  display: block;
  color: #6b7280;
  font-size: 12px;
  margin: 6px 6px 12px 0;
}

.help {
  display: block;
  color: #374151;
  font-size: 14px;
  margin: 12px 0 18px 0;
  padding: 12px;
  background-color: #f0f0f0;
  border-radius: 6px;
}

.result-box {
  background: white;
  border-left: 4px solid #003676;
  padding: 20px;
  border-radius: 6px;
  margin: 20px 0;
  font-family: monospace;
  white-space: pre-wrap;
  line-height: 1.6;
}

.disabled-clause {
  opacity: 0.5;
  pointer-events: none;
}

/* ── TOKENS DE CATEGORIA ─────────────────────────────────────── */
:root {
  --anon-cat-id:         #5046E5;
  --anon-cat-id-bg:      #EEF0FF;
  --anon-cat-contact:    #0077B6;
  --anon-cat-contact-bg: #E3F4FF;
  --anon-cat-eco:        #1A7840;
  --anon-cat-eco-bg:     #E8F5EE;
}

/* ── INSÍGNIA "PROCESSAMENT LOCAL" ───────────────────────────── */
.anon-local-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #E8F5EE;
  border: 1px solid rgba(26,120,64,0.25);
  border-radius: 100px;
  padding: 4px 12px;
  font-size: 0.78rem;
  color: #1A7840;
  font-weight: 400;
}

.anon-badge-dot {
  width: 7px;
  height: 7px;
  background: #1A7840;
  border-radius: 50%;
  flex-shrink: 0;
  animation: anonPulse 2.4s ease-in-out infinite;
}

@keyframes anonPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.45; transform: scale(0.7); }
}

/* ── NUMERACIÓ DE PASSOS ──────────────────────────────────────── */
.anon-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: #003676;
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 400;
  flex-shrink: 0;
}

/* ── ZONA D'UPLOAD ────────────────────────────────────────────── */
.anon-upload-zone {
  border: 2px dashed #adb5bd;
  border-radius: 8px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: #f8f9fa;
}

.anon-upload-zone:hover,
.anon-upload-zone.drag-over {
  border-color: #003676;
  background: #e8f0fb;
}

.anon-upload-zone.drag-over { border-color: #1A7840; background: #E8F5EE; }

/* Chip del format que coincideix amb el fitxer arrossegat */
.badge.badge-drag-match {
  background-color: #1A7840 !important;
  color: #fff !important;
  transform: scale(1.12);
  box-shadow: 0 0 0 3px rgba(26, 120, 64, 0.25);
  transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.anon-upload-icon { font-size: 2.6rem; margin-bottom: 12px; }

.anon-file-selected { text-align: center; }

/* ── PES DE PUNTS DE LLEGENDA ─────────────────────────────────── */
.anon-cat-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── COLORS PER CATEGORIA (estadístiques) ────────────────────── */
.anon-id-color      { color: var(--anon-cat-id); }
.anon-contact-color { color: var(--anon-cat-contact); }
.anon-eco-color     { color: var(--anon-cat-eco); }

/* ── PANELL DE REGLES ─────────────────────────────────────────── */
.rule-category { margin-bottom: 20px; }

.cat-heading {
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6c757d;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #dee2e6;
}

.rules-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rule-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px 6px 10px;
  border: 1.5px solid #dee2e6;
  border-radius: 100px;
  background: #f8f9fa;
  cursor: pointer;
  font-size: 0.83rem;
  color: #495057;
  transition: all 0.15s ease;
  user-select: none;
}

.rule-item:hover { border-color: #003676; background: #e8f0fb; color: #003676; }

.rule-item.active {
  background: #e8f0fb;
  border-color: #003676;
  color: #003676;
}

.rule-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #003676;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 400;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.rule-item:not(.active) .rule-check {
  background: #adb5bd;
}

.rule-icon  { font-size: 0.95rem; }
.rule-label { font-weight: 500; }

.global-controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ── SORTIDA DE TEXT ANONIMITZAT ─────────────────────────────── */
.anon-text-output {
  background: #fff;
  border: 1px solid #003676;
  border-left-width: 4px;
  border-radius: 6px;
  padding: 16px 20px;
  font-family: 'Courier New', monospace;
  font-size: 0.84rem;
  white-space: pre-wrap;
  line-height: 1.7;
  max-height: 420px;
  overflow-y: auto;
  color: #212529;
}

/* ── LLISTAT DE DETECCIONS ───────────────────────────────────── */
.anon-detection-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 9px 13px;
  margin-bottom: 6px;
  animation: anonFadeUp 0.18s ease both;
}

@keyframes anonFadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.anon-det-cat {
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 3px;
  flex-shrink: 0;
  min-width: 76px;
  text-align: center;
}

.anon-det-cat.identificativa { background: var(--anon-cat-id-bg);      color: var(--anon-cat-id); }
.anon-det-cat.contacte       { background: var(--anon-cat-contact-bg);  color: var(--anon-cat-contact); }
.anon-det-cat.economica      { background: var(--anon-cat-eco-bg);      color: var(--anon-cat-eco); }

.anon-det-original {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: #dc3545;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anon-det-arrow { color: #adb5bd; font-size: 0.78rem; flex-shrink: 0; }

.anon-det-masked {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: #1A7840;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anon-no-detections {
  text-align: center;
  padding: 32px 20px;
  color: #adb5bd;
}

/* ── ZONA DE PLANTILLA ───────────────────────────────────────── */
.anon-template-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.5px dashed #adb5bd;
  border-radius: 6px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
}

.anon-template-zone:hover,
.anon-template-zone.drag-over {
  border-color: #003676;
  background: #e8f0fb;
}

.anon-template-info { display: flex; }

/* ── TOASTS ──────────────────────────────────────────────────── */
.anon-toast {
  background: #fff;
  border: 1px solid #dee2e6;
  border-left: 4px solid #003676;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 0.84rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: anonToastIn 0.25s ease;
  min-width: 260px;
  max-width: 340px;
  margin-bottom: 6px;
}

.anon-toast.success { border-left-color: #1A7840; }
.anon-toast.error   { border-left-color: #dc3545; }
.anon-toast.warning { border-left-color: #856404; }
.anon-toast.info    { border-left-color: #0077B6; }

@keyframes anonToastIn {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0); }
}

.anon-toast-title { font-weight: 400; font-size: 0.85rem; margin-bottom: 2px; }
.anon-toast-msg   { font-size: 0.78rem; color: #6c757d; }

/* ── BADGE MODE PDF ──────────────────────────────────────────── */
.anon-badge-pdf {
  background: #1a1a1a;
  color: #fff;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 4px;
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 576px) {
  .anon-upload-zone { padding: 28px 16px; }
  .anon-detection-item { flex-wrap: wrap; gap: 6px; }
  .anon-det-cat { min-width: 60px; }
  .global-controls { flex-direction: column; }
}
/* ── VISOR DE REVISIÓ ────────────────────────────────────────── */
#revDocumentViewer {
  position: relative;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 24px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #333;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.03);
  max-height: 650px;
  overflow-y: auto;
  user-select: text;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── CURSOR PARPADEANT ────────────────────────────────────────── */
.anon-text-cursor {
  position: absolute;
  width: 2px;
  background: #333;
  pointer-events: none;
  animation: anonCursorBlink 1s step-end infinite;
  z-index: 50;
}

@keyframes anonCursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

#revDocumentViewer mark, 
#revDocumentViewer span {
  transition: all 0.2s ease;
  padding: 1px 0;
}

.anon-highlight-flash {
  animation: anonFlash 2s ease;
}

.anon-highlight-blacklist {
  background-color: rgba(220, 53, 69, 0.18) !important;
  color: #842029 !important;
  border: 1px solid rgba(220, 53, 69, 0.45);
  padding: 1px 3px;
}

.anon-highlight-whitelist {
  background-color: rgba(25, 135, 84, 0.15) !important;
  color: #0a3622 !important;
  border: 1px solid rgba(25, 135, 84, 0.4);
  padding: 1px 3px;
}

@keyframes anonFlash {
  0% { outline: 3px solid #ffc107; outline-offset: 2px; background-color: #ffc107 !important; }
  100% { outline: 3px solid transparent; outline-offset: 10px; }
}

.rev-filter-highlight {
  text-decoration: underline;
  text-decoration-color: #0d6efd;
  text-decoration-thickness: 4px;
  text-underline-offset: 2px;
  animation: revFilterPulse 1.2s ease-in-out infinite;
}

@keyframes revFilterPulse {
  0%, 100% { text-decoration-color: #0d6efd; }
  50%       { text-decoration-color: #ffc107; }
}

#revDetectionsList .form-check:hover {
  background-color: #e9ecef !important;
  border-color: #003676 !important;
}

#revDetectionsList .form-check.transition-all {
  transition: all 0.2s ease;
}

/* ── NANS D'AJUST (HANDLES) ─────────────────────────────────── */
.anon-adj-handle {
  position: absolute;
  width: 2px;
  height: 18px;
  background: #007bff;
  cursor: ew-resize;
  z-index: 10000;
  transform: translate(-50%, -50%);
}

/* Serifes superior i inferior del cursor */
.anon-adj-handle::before {
  content: '';
  position: absolute;
  top: 0; left: -3px;
  width: 8px;
  height: 2px;
  background: inherit;
}

.anon-adj-handle::after {
  content: '';
  position: absolute;
  bottom: 0; left: -3px;
  width: 8px;
  height: 2px;
  background: inherit;
}

/* Zona d'interacció invisible més gran per facilitar l'arrossegament */
.anon-adj-hitbox {
  position: absolute;
  top: -10px; left: -10px; right: -10px; bottom: -10px;
  cursor: col-resize;
}

.anon-dragging {
  user-select: none !important;
  cursor: ew-resize !important;
}

#revDocumentViewer [data-uuid] {
  position: relative;
}

#revDocumentViewer [data-uuid]:hover {
  outline: 2px solid rgba(0, 54, 118, 0.4);
}

#revDocumentViewer mark[data-uuid][style*="background-color: var(--bs-warning-bg-subtle)"],
#revDocumentViewer mark.bg-warning {
  /* Millorem el contrast del groc */
  background-color: #ffda6a !important;
}

/* Pestanyes de revisió — estat no visitat */
.nav-pills .nav-link.tab-unvisited {
  opacity: 0.45;
  font-style: italic;
}
.nav-pills .nav-link.tab-unvisited::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  margin-left: 5px;
  vertical-align: middle;
  opacity: 0.8;
}

/* Pestanyes de revisió — estat visitat però no actiu */
.nav-pills .nav-link.tab-touched:not(.active) {
  background-color: #e8f4ec;
  color: #2d7a4f;
  border: 1px solid #a3d4b5;
  font-style: normal;
  opacity: 1;
}
.nav-pills .nav-link.tab-touched:not(.active)::before {
  content: '✓';
  font-size: .65rem;
  margin-right: 4px;
  vertical-align: middle;
  opacity: 0.85;
}

.anon-rev-sidebar {
  width: 100%;
  max-width: 400px;
  box-shadow: 2px 0 10px rgba(0,0,0,0.05);
}

#revDetectionsList .form-check {
  padding: 15px !important;
  padding-left: 45px !important;
  background-color: #fff !important;
  border: 1px solid #e9ecef !important;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: all 0.2s ease;
}

#revDetectionsList .form-check:hover {
  background-color: #f8f9fa !important;
  border-color: #003676 !important;
  transform: translateX(4px);
}

#revDetectionsList .form-check-label div:last-child {
  white-space: normal !important;
  overflow: visible !important;
  max-width: none !important;
  display: block;
  font-family: monospace;
  background: #f1f3f5;
  padding: 4px 8px;
  border-radius: 4px;
  margin-top: 8px;
}
/* ── DETECCIONS DESCARTADES (REVISIÓ) ───────────────────────── */
.anon-excluded {
  opacity: 0.6;
  background-color: #f1f3f5 !important;
  filter: grayscale(0.4);
}
/* ── MENÚ DE CATEGORITZACIÓ MANUAL ────────────────────────── */
#categorizeMenu {
  background: white;
  border: 1px solid #003676;
  min-width: 200px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25) !important;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  animation: anonMenuIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes anonMenuIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#categorizeMenu .dropdown-item {
  font-size: 0.88rem;
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  width: 100%;
  text-align: left;
  background: transparent;
  transition: all 0.1s ease;
}

#categorizeMenu .dropdown-item:hover {
  background-color: #f0f4f8;
  color: #003676;
}

#categorizeMenu .dropdown-header {
  font-weight: 700;
  font-size: 0.7rem;
  color: #6c757d;
  background: #f8f9fa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #eee;
  margin-bottom: 0;
  padding: 8px 16px;
}

#reviewTip {
  animation: anonSlideDown 0.4s ease forwards;
  box-shadow: 0 4px 12px rgba(0,54,118,0.08);
}

@keyframes anonSlideDown {
  from { opacity: 0; transform: translateY(-15px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* ── BOTÓ CORPORATIU (BLAU DIBA) ─────────────────────────────── */
.btn-corporate-blue {
  background-color: #003676;
  color: #fff;
  border-color: #003676;
}

.btn-corporate-blue:hover, 
.btn-corporate-blue:focus {
  background-color: #002a5c;
  color: #fff;
  border-color: #002a5c;
}
/* ── REQUADRE D'INTRODUCCIÓ ─────────────────────────────────── */
.anon-intro-box {
  background-color: #f0f7ff;
  border: 1px solid #e0efff;
  border-left: 4px solid #003676;
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #374151;
  margin-bottom: 1rem;
}

.anon-intro-box strong {
  color: #003676;
  font-weight: 600;
}

/* ── SELECTOR DE POSICIONS DNI/NIE ───────────────────────────── */
.dni-pos-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 52px;
  border: 1.5px solid #dee2e6;
  border-radius: 6px;
  background: #f8f9fa;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  gap: 2px;
  user-select: none;
}

.dni-pos-btn:hover {
  border-color: #003676;
  background: #e8f0fb;
}

.dni-pos-btn.active {
  border-color: #dc3545;
  background: #fff5f5;
  color: #dc3545;
}

.dni-pos-num {
  font-size: 0.6rem;
  font-weight: 600;
  color: #adb5bd;
  line-height: 1;
  letter-spacing: 0.02em;
}

.dni-pos-btn.active .dni-pos-num {
  color: #e38e98;
}

.dni-pos-char {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.dni-pos-btn.active .dni-pos-char {
  color: #dc3545;
}

/* Chevron animat al col·lapsar */
#dniMaskCollapse.show ~ h3 .dni-chevron,
[aria-expanded="true"] .dni-chevron {
  transform: rotate(180deg);
}

/* Preview */
.dni-preview {
  font-size: 0.82rem !important;
  letter-spacing: 0.02em;
  border-color: #dee2e6 !important;
}
