/* =============================================================================
   CHATBOT.CSS — Modal chatbot IA pour conventions collectives
   ============================================================================= */

/* ===== OVERLAY MODAL ===== */
.chat-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 300;
  backdrop-filter: blur(2px);
}
.chat-overlay.open {
  display: block;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== MODAL ===== */
.chat-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 301;
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 60px);
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.chat-modal.open {
  display: flex;
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* ===== MODAL HEADER ===== */
.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg2);
  flex-shrink: 0;
}
.chat-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent-bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-header-icon svg {
  width: 18px;
  height: 18px;
  color: var(--accent-dark);
}
.chat-header-text {
  flex: 1;
  min-width: 0;
}
.chat-header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.chat-header-sub {
  font-size: 11.5px;
  color: var(--text3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-header-source {
  font-size: 10px;
  color: var(--text3);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 2px;
  display: inline-block;
}
.chat-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  transition: all var(--transition);
  flex-shrink: 0;
}
.chat-close:hover {
  background: var(--bg);
  color: var(--text);
}

/* ===== MESSAGES ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 200px;
  max-height: 50vh;
}

.chat-msg {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
}
.chat-msg.bot {
  align-self: flex-start;
  background: var(--bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.bot strong {
  color: var(--accent-dark);
}
.chat-msg.bot ul {
  margin: 6px 0 6px 18px;
  padding: 0;
}
.chat-msg.bot li {
  margin-bottom: 3px;
}
.chat-msg.bot code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12.5px;
}
.chat-msg.bot table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12.5px;
}
.chat-msg.bot table th {
  background: var(--text);
  color: #fff;
  padding: 5px 10px;
  text-align: left;
  font-size: 11.5px;
}
.chat-msg.bot table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.chat-msg.bot table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
.chat-msg.bot table td {
  padding: 5px 10px;
  border: 1px solid var(--border);
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  align-self: flex-start;
  background: var(--bg);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}
.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text3);
  animation: chatBounce 1.4s infinite ease-in-out;
}
.chat-typing span:nth-child(1) { animation-delay: 0s; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-7px); }
}

/* Welcome message */
.chat-welcome {
  text-align: center;
  padding: 24px 20px;
  color: var(--text3);
  font-size: 13.5px;
  line-height: 1.5;
}
.chat-welcome .title {
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  font-size: 15px;
}

/* Suggestions */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 14px;
  justify-content: center;
}
.chat-suggestion {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  font-family: var(--font);
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.chat-suggestion:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-bg);
}

/* ===== INPUT ===== */
.chat-input-area {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--bg2);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  padding: 11px 16px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--card);
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  resize: none;
  max-height: 120px;
  line-height: 1.45;
  transition: border-color var(--transition);
}
.chat-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg2);
}
.chat-input::placeholder {
  color: var(--text3);
}
.chat-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.chat-send:hover {
  background: var(--accent-dark);
}
.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.chat-send svg {
  width: 18px;
  height: 18px;
}

/* ===== DISCLAIMER ===== */
.chat-disclaimer {
  padding: 8px 20px 10px;
  font-size: 10.5px;
  color: var(--text3);
  text-align: center;
  background: var(--bg2);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

/* ===== RECHERCHE PLEIN TEXTE ===== */
.search-bar-wrapper {
  flex: 1;
  max-width: 320px;
  position: relative;
}
.search-bar-wrapper .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text3);
  pointer-events: none;
}
.search-bar-input {
  width: 100%;
  padding: 6px 10px 6px 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--text);
  transition: all var(--transition);
}
.search-bar-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 0 0 2px var(--accent-bg2);
}
.search-bar-input::placeholder {
  color: var(--text3);
}

/* Highlights in content */
.search-highlight {
  background: rgba(66, 216, 15, 0.25);
  border-radius: 2px;
  padding: 0 1px;
}
.search-results-count {
  font-size: 11px;
  color: var(--text3);
  margin-left: 8px;
  white-space: nowrap;
}
.search-nav-btns {
  display: flex;
  gap: 2px;
  margin-left: 4px;
}
.search-nav-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text3);
  transition: all var(--transition);
}
.search-nav-btn:hover {
  background: var(--bg);
  color: var(--text);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .chat-modal {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 32px);
    top: 50%;
    left: 50%;
  }
  .search-bar-wrapper {
    max-width: 180px;
  }
}

/* ===== PRINT ===== */
@media print {
  .chat-overlay,
  .chat-modal {
    display: none !important;
  }
}
