* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; background: #f5f4f0; color: #1a1a1a; height: 100vh; display: flex; flex-direction: column; }

header { background: #fff; border-bottom: 0.5px solid #ddd; padding: 1rem 1.5rem; display: flex; align-items: center; gap: 12px; }
header h1 { font-size: 16px; font-weight: 500; }
header span { font-size: 13px; color: #888; }

.main { display: flex; flex: 1; overflow: hidden; }
.chat-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.message { max-width: 82%; }
.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; width: 82%; }
.bubble { padding: 0.75rem 1rem; border-radius: 12px; font-size: 14px; line-height: 1.6; }
.user .bubble { background: #1a1a1a; color: #fff; border-bottom-right-radius: 4px; }
.assistant .bubble { background: #fff; border: 0.5px solid #ddd; border-bottom-left-radius: 4px; }

.footer-block { margin-top: 0.5rem; padding: 0.75rem 1rem; background: #fafaf9; border: 0.5px solid #e8e8e4; border-radius: 8px; font-size: 12px; }
.footer-title { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: #888; margin-bottom: 10px; }

/* Fonts: article + badge de vigència (substitueix source-entry/page-strip d'actes) */
.source-entry { display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-bottom: 0.5px solid #eee; }
.source-entry:last-child { border-bottom: none; }
.source-entry:hover { background: #f5f4f0; border-radius: 6px; }
.source-index { font-weight: 600; font-size: 12px; color: #7c6fd0; flex-shrink: 0; }
.source-label { font-size: 13px; color: #333; flex: 1; }
.vigency-badge { font-size: 11px; border-radius: 10px; padding: 2px 9px; white-space: nowrap; }
.vigency-badge.vigent { background: #e7f6ec; color: #1e7e34; }
.vigency-badge.en_tramitacio { background: #fff8e1; color: #b45309; }
.vigency-badge.derogat { background: #fdecea; color: #c0392b; }
.vigency-badge.indefinit { background: #f0f0f0; color: #666; }
.superseded-note { font-size: 11px; color: #c0392b; }

.input-area { padding: 1rem 1.5rem; background: #fff; border-top: 0.5px solid #ddd; display: flex; gap: 8px; flex-shrink: 0; }
.input-area textarea { flex: 1; border: 0.5px solid #ddd; border-radius: 8px; padding: 0.6rem 0.75rem; font-size: 14px; resize: none; height: 42px; font-family: inherit; background: #fafaf9; }
.input-area textarea:focus { outline: none; border-color: #999; }
.input-area button { background: #1a1a1a; color: #fff; border: none; border-radius: 8px; padding: 0 1rem; font-size: 14px; cursor: pointer; }
.input-area button:disabled { opacity: 0.4; cursor: not-allowed; }

.loading { display: flex; gap: 4px; align-items: center; padding: 0.75rem 1rem; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #999; animation: bounce 1.2s infinite; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }

.welcome { text-align: center; padding: 3rem 1rem; color: #888; }
.welcome h2 { font-size: 18px; font-weight: 500; color: #444; margin-bottom: 0.5rem; }
.welcome p { font-size: 14px; }

/* Pantalla completa de bloqueig amb fons desenfocat (backdrop-blur) */
.gatekeeper-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(40, 58, 77, 0.5); /* Fons fosc semitransparent */
  backdrop-filter: blur(1px);          /* Efecte desenfocat estil fons de la landing */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  font-family: inherit;
}

/* Caixa central d'accés estil 'doc-panel' */
.gatekeeper-card {
  background: #1E2A38;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.gatekeeper-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: #ffffff;
}

.gatekeeper-text {
  font-size: 0.9rem;
  color: #a0a0ab;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

/* Camp d'entrada estilitzat per a codis monospaiats */
.gatekeeper-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #F1E9D8;
  color: #0d0d10;
  text-align: center;
  font-size: 1.25rem;
  font-family: monospace;
  letter-spacing: 4px;
  margin-bottom: 1rem;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gatekeeper-input:focus {
  outline: none;
  border-color: #3b82f6; /* Blau d'accent per als botons */
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Botó principal d'acció */
.gatekeeper-btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: #C4695C;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

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

.gatekeeper-btn:hover {
  background: #9A3D31;
}

/* Missatges d'error */
.gatekeeper-error {
  color: #f87171;
  font-size: 0.85rem;
  margin-top: 1rem;
  margin-bottom: 0;
  display: none;
}

.gatekeeper-privacy {
  font-size: 0.82rem;
  color: #666;
  line-height: 1.4;
  margin: 10px 0;
  text-align: left;
}

.gatekeeper-privacy a {
  color: #4a90d9;
  text-decoration: underline;
  cursor: pointer;
}

.gatekeeper-privacy a:hover {
  color: #3574b5;
}

.gatekeeper-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.85rem;
  color: #555;
  text-align: left;
  margin: 10px 0 16px;
  cursor: pointer;
}

.gatekeeper-consent input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: #4a90d9;
  cursor: pointer;
}

.privacy-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.privacy-modal-overlay.open {
  display: flex;
}

.privacy-modal-card {
  background: #fff;
  border-radius: 10px;
  max-width: 720px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.privacy-modal-card h3 {
  margin-top: 0;
  font-size: 1.1rem;
}

.privacy-modal-card p {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #444;
}

.privacy-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: #888;
}

.privacy-modal-close:hover {
  color: #333;
}

.feedback-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.fb-label { font-size: 12px; color: #888; }
.fb-btn {
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    padding: 3px 10px;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s, background 0.15s;
}
.fb-btn:hover { opacity: 1; background: #f5f4f0; }
.fb-btn.selected { opacity: 1; background: #e8e4f5; border-color: #7c6fd0; }
.feedback-bar.done .fb-btn:not(.selected) { opacity: 0.3; pointer-events: none; }

.feedback-bar { margin-top: 8px; position: relative; }

.fb-toggle {
    border: 1px solid #ddd; background: #fff; border-radius: 6px;
    padding: 4px 12px; cursor: pointer; font-size: 12px; color: #666;
    opacity: 0.7; transition: opacity 0.15s;
}
.fb-toggle:hover { opacity: 1; background: #f5f4f0; }

.fb-panel {
    display: none; flex-direction: column; gap: 6px; margin-top: 6px;
    padding: 8px; border: 1px solid #eee; border-radius: 8px; background: #fafafa;
    width: fit-content; min-width: 200px;
}
.feedback-bar.open .fb-panel { display: flex; }

.fb-opt {
    border: 1px solid #ddd; background: #fff; border-radius: 6px;
    padding: 5px 12px; cursor: pointer; font-size: 13px; text-align: left;
}
.fb-opt:hover { background: #f0eefb; border-color: #7c6fd0; }

.fb-reason { display: none; flex-direction: column; gap: 6px; margin-top: 4px; }
.feedback-bar.show-reason .fb-reason { display: flex; }

.fb-reason-input {
    border: 1px solid #ddd; border-radius: 6px; padding: 6px;
    font-family: inherit; font-size: 13px; resize: vertical;
}
.fb-reason-send {
    align-self: flex-end; border: none; background: #7c6fd0; color: #fff;
    border-radius: 6px; padding: 5px 14px; cursor: pointer; font-size: 13px;
}
.fb-reason-send:hover { background: #6a5cc0; }

.fb-done { font-size: 12px; color: #7c6fd0; }

