* { 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; }
header .doc-status { font-size: 12px; color: #888; margin-left: auto; display: flex; align-items: center; gap: 10px; }

.status-bar { width: 120px; height: 5px; background: #eee; border-radius: 3px; overflow: hidden; display: flex; }
.status-bar-fill { height: 100%; background: #7c6fd0; }
.status-bar-process { height: 100%; background: #fbbf24; }

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

.tab-bar { display: flex; border-bottom: 0.5px solid #ddd; background: #fff; flex-shrink: 0; }
.tab-btn { padding: 0.5rem 1.5rem; font-size: 13px; border: none; background: none; cursor: pointer; color: #888; border-bottom: 2px solid transparent; }
.tab-btn.active { color: #1a1a1a; border-bottom-color: #1a1a1a; }
.tab-content { display: none; flex: 1; flex-direction: column; overflow: hidden; min-height: 0; }
.tab-content.active { display: flex; }

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

.source-entry { display: flex; align-items: center; gap: 12px; padding: 7px 6px; border-bottom: 0.5px solid #eee; border-radius: 6px; }
.source-entry:last-child { border-bottom: none; }
.source-entry:hover { background: #f5f4f0; }
.source-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.source-info .s-session { font-weight: 500; color: #333; font-size: 12px; }
.source-info .s-date { color: #666; font-size: 11px; }
.source-info .s-file { color: #aaa; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-info .s-context { color: #888; font-size: 11px; font-style: italic; margin-top: 2px; }
.split-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; background: #fff8e1; color: #b45309; border: 0.5px solid #fcd34d; border-radius: 3px; padding: 1px 5px; margin-top: 3px; }
.list-badge { display: inline-block; font-size: 10px; background: #f0eeff; color: #7c6fd0; border-radius: 3px; padding: 1px 5px; margin-left: 4px; }
.chunk-index { font-size: 10px; color: #aaa; margin-left: 4px; }

.page-strip { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.page-strip-item { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.page-strip-item img { border-radius: 3px; border: 0.5px solid #ddd; background: #eee; object-fit: cover; transition: border-color 0.15s; }
.page-strip-item.main-page img { width: 40px; height: 52px; border-color: #999; }
.page-strip-item.adj-page img { width: 28px; height: 36px; opacity: 0.55; }
.page-strip-item:hover img { border-color: #555; opacity: 1; }
.page-strip-item.active img { border-color: #7c6fd0 !important; box-shadow: 0 0 0 2px #c0b8f0; opacity: 1; }
.page-strip-item span { font-size: 9px; color: #aaa; }
.page-strip-item.main-page span { color: #555; font-weight: 500; }
.page-strip-sep { color: #ddd; font-size: 12px; }

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

.list-context-bar { padding: 0.6rem 1.5rem; background: #fff; border-bottom: 0.5px solid #eee; flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.context-tag { font-size: 11px; background: #f0eeff; color: #7c6fd0; border: 0.5px solid #d4cef7; border-radius: 20px; padding: 3px 10px; cursor: pointer; white-space: nowrap; transition: background 0.1s; }
.context-tag:hover { background: #e0d8ff; }
.context-tag.active { background: #7c6fd0; color: #fff; border-color: #7c6fd0; }
.context-tag-count { font-size: 10px; opacity: 0.7; margin-left: 3px; }

.list-search-total { padding: 0.5rem 1.5rem; font-size: 12px; color: #888; background: #fff; border-bottom: 0.5px solid #eee; flex-shrink: 0; }
.list-results { flex: 1; overflow-y: auto; padding: 1rem 1.5rem; display: flex; flex-direction: column; gap: 0.75rem; }
.list-card { background: #fff; border: 0.5px solid #ddd; border-radius: 8px; padding: 0.75rem 1rem; }
.list-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.list-card-session { font-weight: 500; font-size: 13px; }
.list-card-date { font-size: 11px; color: #888; }
.list-card-context { font-size: 11px; color: #7c6fd0; font-style: italic; margin-bottom: 0.5rem; background: #f0eeff; display: inline-block; padding: 1px 8px; border-radius: 10px; }
.list-card-body { display: flex; gap: 12px; align-items: flex-start; }
.list-card-items { flex: 1; font-size: 11px; color: #444; line-height: 1.6; max-height: 120px; overflow-y: auto; }
.list-card-items div { padding: 2px 0; border-bottom: 0.5px solid #f0f0f0; }
.list-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 0.5rem; }
.list-card-count { font-size: 10px; color: #aaa; }
.list-search-area { padding: 1rem 1.5rem; background: #fff; border-top: 0.5px solid #ddd; display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.list-search-area input { flex: 1; border: 0.5px solid #ddd; border-radius: 8px; padding: 0.6rem 0.75rem; font-size: 14px; font-family: inherit; background: #fafaf9; }
.list-search-area input:focus { outline: none; border-color: #999; }
.list-search-area button { background: #1a1a1a; color: #fff; border: none; border-radius: 8px; padding: 0 1rem; font-size: 14px; cursor: pointer; }
#active-filter { width: 100%; margin-bottom: 6px; }

.image-panel { width: 50%; border-left: 0.5px solid #ddd; background: #1a1a1a; display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
.image-panel.hidden { display: none; }
.image-panel-header { padding: 0.6rem 1rem; border-bottom: 0.5px solid #333; font-size: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #222; }
.image-panel-header span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #ccc; }
.panel-actions { display: flex; gap: 6px; flex-shrink: 0; }
.panel-btn { background: none; border: 0.5px solid #444; border-radius: 5px; cursor: pointer; padding: 3px 8px; font-size: 11px; color: #aaa; }
.panel-btn:hover { background: #333; color: #fff; }
.close-btn { background: none; border: none; cursor: pointer; font-size: 20px; color: #666; padding: 0 2px; line-height: 1; }
.close-btn:hover { color: #fff; }
.image-viewport { flex: 1; overflow: hidden; position: relative; }
.image-viewport img { display: block; max-width: 100%; user-select: none; }
.zoom-hint { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.6); color: #ccc; font-size: 11px; padding: 4px 10px; border-radius: 20px; pointer-events: none; transition: opacity 0.5s; }
.zoom-hint.hidden { opacity: 0; }
.zoom-controls { position: absolute; bottom: 12px; right: 12px; display: flex; flex-direction: column; gap: 4px; }
.zoom-btn { width: 30px; height: 30px; background: rgba(0,0,0,0.6); border: 0.5px solid #444; border-radius: 6px; color: #ccc; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.zoom-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

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

.results-section-title {
  font-size: 11px; font-weight: 500; color: #888;
  padding: 8px 0 4px; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 0.5px solid #eee; margin-bottom: 4px;
}
.results-section-title.fuzzy { color: #b45309; }


/* 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: 1999;
  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: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #F1E9D8;
  color: #0d0d10;
  text-align: center;
  font-size: 1.1rem;
  font-family: monospace;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gatekeeper-input-mail {
  width: 100%;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #F1E9D8;
  color: #0d0d10;
  text-align: center;
  font-size: 1rem;
  font-family: monospace;
  margin-bottom: 0.5rem;
  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-mail {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: #C4695C;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s ease;
}

.gatekeeper-btn-mail:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.gatekeeper-btn-mail:not(:disabled) {
  cursor: pointer;
}

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

.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: 5px 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-left: 8px; 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; }

.privacy-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 11px;
    color: #aaa;
    background: rgba(255, 255, 255, 0.92);
    padding: 5px 10px;
    border-top: 1px solid #eee;
    z-index: 500;
    pointer-events: none;   /* que no bloquegi clics al que hi ha a sota */
}

.mobile-warning {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;          /* per sobre de tot, inclòs el gatekeeper */
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.mobile-warning.show { display: flex; }

.mobile-warning-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.mobile-warning-card h3 { margin-top: 0; font-size: 1.1rem; }
.mobile-warning-card p { font-size: 0.9rem; color: #555; line-height: 1.5; }
.mobile-warning-card button {
    margin-top: 12px; border: none; background: #7c6fd0; color: #fff;
    border-radius: 8px; padding: 8px 18px; cursor: pointer; font-size: 0.9rem;
}

.gatekeeper-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: #a0a0ab;
  font-size: 11px;
  text-decoration: none;
  cursor: pointer;
  margin-top: 14px;
  opacity: 0.8;
}

.gatekeeper-link:hover {
  opacity: 1;
  color: whitesmoke;
}

.gatekeeper-request-panel {
  display: none;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(241, 233, 216, 0.14);
  text-align: left;
}

.gatekeeper-request-panel.open {
  display: block;
}

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

.gatekeeper-btn-secondary {
  flex: 1;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--paper);
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.gatekeeper-request-msg {
  font-size: 12px;
  margin-top: 10px;
color: #a0a0ab;
text-align: left;
}

.gatekeeper-request-msg.error {
  color: var(--seal-light);
  text-align: left;
}

.gatekeeper-microcopy {
  font-size: 12px;
  color: #888;
  margin: 10px 0 0;
  line-height: 1.5;
}

