/* Custom CSS for LégalBot Tunisie */

:root {
  /* Colors */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-sidebar: #0d131f;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(31, 41, 55, 0.8);
  --bg-card-active: rgba(16, 185, 129, 0.06);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-color-hover: rgba(255, 255, 255, 0.15);
  
  --accent-emerald: #10b981;
  --accent-emerald-light: #34d399;
  --accent-emerald-glow: rgba(16, 185, 129, 0.15);
  
  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(245, 158, 11, 0.15);
  
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  
  --user-bubble-bg: #1e293b;
  --bot-bubble-bg: rgba(17, 24, 39, 0.6);
  --system-bubble-bg: rgba(31, 41, 55, 0.4);
  
  /* Fonts */
  --font-main: 'Outfit', sans-serif;
  --font-mono: 'Fira Code', monospace;
  
  /* Dimensions */
  --sidebar-width: 360px;
  --header-height: 70px;
  
  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

a {
  color: var(--accent-emerald-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--accent-emerald);
  text-decoration: underline;
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* App Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  transition: transform var(--transition-normal);
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--accent-emerald);
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.3));
}

.logo-text h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.logo-text span {
  font-size: 11px;
  color: var(--accent-emerald-light);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.close-sidebar-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* Sidebar Sections */
.sidebar-section {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 600;
}

.section-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.4;
}

/* Config Box */
.config-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.input-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.input-group input {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-main);
  transition: all var(--transition-fast);
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.helper-text {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.3;
}

.status-indicator-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  margin-top: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.connected {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.status-dot.disconnected {
  background-color: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

.status-dot.connecting {
  background-color: #3b82f6;
  box-shadow: 0 0 8px #3b82f6;
  animation: pulse-blue 1.5s infinite;
}

/* Domain Grid Selection & Search */
.domain-search-box {
  position: relative;
  margin-bottom: 14px;
}

.domain-search-box input {
  width: 100%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px 8px 32px;
  font-size: 13px;
  color: var(--text-main);
  transition: all var(--transition-fast);
}

.domain-search-box input:focus {
  outline: none;
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.domain-search-box .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.domain-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.domain-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.domain-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-hover);
  transform: translateY(-1px);
}

.domain-card.active {
  background: var(--bg-card-active);
  border-color: var(--accent-emerald);
  box-shadow: 0 0 16px var(--accent-emerald-glow);
}

.domain-icon {
  font-size: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.domain-card.active .domain-icon {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

.domain-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.domain-info h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.domain-card.active .domain-info h3 {
  color: var(--accent-emerald-light);
}

.domain-info p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Session controls & buttons */
.session-controls {
  margin-top: auto;
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-id-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
}

.session-id-row code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-color-hover);
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

/* Chat Wrapper */
.chat-wrapper {
  flex-grow: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  position: relative;
}

/* Chat Header */
.chat-header {
  height: var(--header-height);
  padding: 0 32px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 14, 23, 0.7);
  backdrop-filter: blur(12px);
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color var(--transition-fast);
}

.menu-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.chat-title-info h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.active-domain-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.badge {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.connection-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}

.connection-status-badge.success {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald-light);
}

.connection-status-badge.info {
  background: rgba(59, 130, 246, 0.06);
  border-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.connection-status-badge.loading {
  background: rgba(245, 158, 11, 0.06);
  border-color: rgba(245, 158, 11, 0.15);
  color: var(--accent-gold);
}

.status-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: pulse-opacity 1.5s infinite;
}

/* Messages stream */
.messages-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Welcome Box styling */
.welcome-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 32px;
  max-width: 680px;
  margin: 0 auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.welcome-box h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--accent-emerald-light);
  text-align: center;
}

.welcome-box p {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.6;
}

.steps-guide {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.steps-guide h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-main);
  margin-bottom: 12px;
}

.steps-guide ol {
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.warning-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: 10px;
  padding: 14px;
  font-size: 12px;
  color: #fcd34d;
}

.warning-alert svg {
  flex-shrink: 0;
  margin-top: 2px;
}

/* Chat bubble structures */
.message {
  display: flex;
  width: 100%;
  animation: slide-up 0.3s ease-out;
}

.message.user-message {
  justify-content: flex-end;
}

.message.bot-message {
  justify-content: flex-start;
}

.message.system-message {
  justify-content: center;
}

.message-content {
  max-width: 75%;
  border-radius: 18px;
  padding: 16px 20px;
  font-size: 14.5px;
  line-height: 1.6;
}

.user-message .message-content {
  background-color: var(--user-bubble-bg);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom-right-radius: 4px;
  color: var(--text-main);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.bot-message .message-content {
  background-color: var(--bot-bubble-bg);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
  color: var(--text-main);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Bot response content styling */
.bot-response-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Markdown parsing output classes */
.legal-p {
  margin-bottom: 8px;
}
.legal-p:last-child {
  margin-bottom: 0;
}

.legal-heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-emerald-light);
  margin-top: 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 4px;
}
.legal-heading:first-child {
  margin-top: 0;
}

.legal-list {
  padding-left: 20px;
  margin-bottom: 10px;
}

.legal-list-item {
  margin-bottom: 4px;
}

.legal-bold {
  font-weight: 600;
  color: #fff;
}

/* Sources section on bot bubbles */
.sources-container {
  margin-top: 16px;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

.sources-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.source-pill:hover {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-emerald-light);
}

.source-pill svg {
  width: 12px;
  height: 12px;
  color: var(--text-dim);
}

.source-pill:hover svg {
  color: var(--accent-emerald);
}

/* Typing / Loading state */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-muted);
  border-radius: 50%;
  animation: bounce-dot 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Suggestions chips */
.suggestions-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 32px;
  overflow-x: auto;
  white-space: nowrap;
}

.suggestion-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-muted);
}

.suggestion-chip:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--border-color-hover);
  color: var(--text-main);
  transform: translateY(-1px);
}

/* Chat Input styling */
.chat-input-area {
  padding: 16px 32px 24px;
  background: linear-gradient(180deg, transparent 0%, var(--bg-primary) 30%);
}

.input-form {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-container {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 12px 60px 12px 16px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.input-container:focus-within {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15), 0 4px 20px rgba(0, 0, 0, 0.2);
}

.input-container textarea {
  width: 100%;
  background: transparent;
  border: none;
  resize: none;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  max-height: 200px;
  height: 24px;
  line-height: 1.5;
}

.send-btn {
  position: absolute;
  right: 12px;
  bottom: 8px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--accent-emerald);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: all var(--transition-fast);
}

.send-btn:hover {
  background: var(--accent-emerald-light);
  transform: scale(1.05);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn svg {
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
  margin-left: -2px;
  margin-top: 1px;
}

.input-footer-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 4px;
}

.input-footer-info strong {
  color: var(--accent-emerald-light);
}

/* Animations */
@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse-opacity {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes pulse-blue {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

@keyframes bounce-dot {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Responsive adjustments */
@media (max-width: 992px) {
  .close-sidebar-btn {
    display: block;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 20px 0 30px rgba(0, 0, 0, 0.3);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .menu-toggle-btn {
    display: block;
  }
  
  .chat-header {
    padding: 0 16px;
  }
  
  .messages-container {
    padding: 16px;
  }
  
  .chat-input-area {
    padding: 12px 16px 16px;
  }
  
  .message-content {
    max-width: 88%;
  }
}
