html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* Modern Chat Interface Styles */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  max-height: 800px;
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-header-info h4 {
  margin: 0;
  font-weight: 600;
  font-size: 1.2rem;
}

.chat-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-actions {
  display: flex;
  gap: 8px;
}

.chat-actions .btn {
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  transition: all 0.3s ease;
}

.chat-actions .btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.message {
  display: flex;
  margin-bottom: 20px;
  animation: messageSlideIn 0.4s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-user {
  flex-direction: row-reverse;
}

.message-assistant {
  flex-direction: row;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  margin: 0 12px;
  flex-shrink: 0;
}

.message-user .message-avatar {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.message-assistant .message-avatar {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.message-content {
  max-width: 70%;
  position: relative;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: #64748b;
}

.message-sender {
  font-weight: 600;
}

.message-text {
  padding: 16px 20px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message-user .message-text {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-assistant .message-text {
  background: white;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.message-assistant .message-reasoning {
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  margin-bottom: 12px;
  color: #0f172a;
}

.message-assistant .message-reasoning-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0f172a;
}

.message-assistant .message-reasoning-header i {
  color: #0ea5e9;
}

.message-assistant .message-reasoning-text {
  margin-top: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #475569;
}

.markdown-body {
  color: inherit;
  font-size: 0.95rem;
}

.markdown-body p {
  margin: 0 0 0.75rem 0;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 0.75rem 1.25rem;
  padding: 0;
}

.markdown-body li {
  margin-bottom: 0.25rem;
  color: inherit;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 0 0 0.75rem 0;
  font-weight: 700;
  line-height: 1.3;
  color: inherit;
}

.markdown-body h1 { font-size: 1.35rem; }
.markdown-body h2 { font-size: 1.2rem; }
.markdown-body h3 { font-size: 1.05rem; }
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 { font-size: 0.95rem; }

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.9rem;
}

.markdown-body th,
.markdown-body td {
  padding: 8px 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: inherit;
}

.markdown-body th {
  background: rgba(148, 163, 184, 0.12);
  font-weight: 600;
}

.message-user .markdown-body th,
.message-user .markdown-body td {
  border-color: rgba(255, 255, 255, 0.25);
}

.message-user .markdown-body th {
  background: rgba(255, 255, 255, 0.18);
}

.markdown-body code {
  font-family: "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 4px;
  padding: 2px 6px;
  color: inherit;
}

.message-user .markdown-body code {
  background: rgba(255, 255, 255, 0.2);
}

.markdown-body pre {
  margin: 0 0 0.75rem 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.08);
  overflow-x: auto;
  font-family: "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  color: inherit;
}

.message-user .markdown-body pre {
  background: rgba(255, 255, 255, 0.2);
}

.markdown-body pre code {
  display: block;
  white-space: pre;
  overflow-x: auto;
  padding: 0;
  background: transparent;
  color: inherit;
}

.markdown-body .hljs {
  background: transparent;
  color: inherit;
}

.markdown-body .hljs-comment,
.markdown-body .hljs-quote {
  color: #64748b;
}

.markdown-body .hljs-keyword,
.markdown-body .hljs-selector-tag,
.markdown-body .hljs-addition {
  color: #2563eb;
}

.markdown-body .hljs-string,
.markdown-body .hljs-built_in,
.markdown-body .hljs-literal {
  color: #0ea5e9;
}

.message-user .markdown-body .hljs-comment,
.message-user .markdown-body .hljs-quote {
  color: rgba(255, 255, 255, 0.7);
}

.message-user .markdown-body .hljs-keyword,
.message-user .markdown-body .hljs-selector-tag,
.message-user .markdown-body .hljs-addition {
  color: #c4b5fd;
}

.message-user .markdown-body .hljs-string,
.message-user .markdown-body .hljs-built_in,
.message-user .markdown-body .hljs-literal {
  color: #a5f3fc;
}

.markdown-body a {
  color: #2563eb;
  text-decoration: underline;
}

.message-user .markdown-body a {
  color: #bfdbfe;
}

.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.message:hover .message-actions {
  opacity: 1;
}

.message-actions .btn {
  border: none;
  background: transparent;
  color: #64748b;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.message-actions .btn:hover {
  background: #f1f5f9;
  color: #334155;
  transform: scale(1.1);
}

.typing-indicator {
  animation: messageSlideIn 0.4s ease-out;
}

.typing-animation {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
  background: white;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Admin dashboard grid fixes */
.app-shell .app-content .panel-grid {
  /* Prevent overflow on narrow containers while keeping auto-fit behavior */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)) !important;
  align-items: stretch !important;
}
.app-shell .app-content .panel-card {
  /* Make cards stretch uniformly within the grid */
  display: flex;
  flex-direction: column;
  height: 100%;
}
.app-shell .app-content .panel-card .card-body {
  flex: 1 1 auto;
}
@media (max-width: 600px) {
  .app-shell .app-content .panel-grid {
    grid-template-columns: 1fr !important;
  }
}

.typing-animation span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-animation span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-animation span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingPulse {
  0%, 80%, 100% {
    transform: scale(0.8);
    background: #cbd5e1;
  }
  40% {
    transform: scale(1);
    background: #64748b;
  }
}

.chat-input-container {
  background: white;
  border-top: 1px solid #e2e8f0;
  padding: 20px 24px;
}

.chat-form {
  position: relative;
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 24px;
  padding: 8px;
  transition: all 0.3s ease;
}

.chat-input-wrapper:focus-within {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.attachment-btn {
  border: none !important;
  background: transparent !important;
  color: #64748b;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.attachment-btn:hover {
  background: #e2e8f0 !important;
  color: #334155;
  transform: scale(1.1);
}

.chat-input-field {
  flex: 1;
  position: relative;
}

.chat-input-field textarea {
  border: none;
  background: transparent;
  resize: none;
  padding: 12px 16px;
  padding-right: 60px;
  font-size: 0.95rem;
  line-height: 1.4;
  max-height: 120px;
  overflow-y: auto;
}

.chat-input-field textarea:focus {
  box-shadow: none;
  outline: none;
}

.char-counter {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.7rem;
  color: #94a3b8;
  pointer-events: none;
}

.send-btn {
  border: none !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
  padding: 12px;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.send-btn:active {
  transform: translateY(0);
}

.send-btn:disabled {
  background: #cbd5e1 !important;
  box-shadow: none;
  transform: none;
}

.chat-input-footer {
  margin-top: 8px;
  text-align: center;
}

.welcome-message {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  background: white;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  margin: 20px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.welcome-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.3rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.welcome-content h5 {
  margin: 0 0 8px 0;
  color: #334155;
  font-weight: 600;
}

.welcome-content p {
  margin: 0;
  color: #64748b;
  line-height: 1.5;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  height: 100%;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  font-size: 2rem;
  color: #9ca3af;
}

.empty-state h3 {
  color: #374151;
  font-weight: 600;
  margin-bottom: 12px;
}

.empty-state p {
  color: #6b7280;
  max-width: 400px;
  margin-bottom: 24px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-container {
    height: calc(100vh - 160px);
    border-radius: 0;
  }
  
  .chat-header {
    padding: 16px 20px;
  }
  
  .chat-header-info h4 {
    font-size: 1.1rem;
  }
  
  .chat-messages {
    padding: 16px;
  }
  
  .message-content {
    max-width: 85%;
  }
  
  .chat-input-container {
    padding: 16px 20px;
  }
  
  .chat-input-wrapper {
    padding: 6px;
  }
  
  .chat-input-field textarea {
    padding: 10px 14px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .send-btn {
    width: 42px;
    height: 42px;
  }
  
  .chat-avatar {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
  
  .welcome-avatar {
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .chat-header {
    padding: 12px 16px;
  }
  
  .chat-messages {
    padding: 12px;
  }
  
  .message-content {
    max-width: 90%;
  }
  
  .chat-input-container {
    padding: 12px 16px;
  }
  
  .message-text {
    padding: 12px 16px;
    font-size: 0.9rem;
  }
}
