/* ==========================================================================
   Rachita AI Assistant - Fully Responsive & Premium Stylesheet
   Author: PT Rachita (Rachita Apps)
   ========================================================================== */

:root {
  --ai-primary: #4f46e5;
  --ai-primary-hover: #4338ca;
  --ai-primary-light: #eef2ff;
  --ai-accent: #8b5cf6;
  --ai-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%);
  --ai-bg-card: #ffffff;
  --ai-border: #e2e8f0;
  --ai-border-light: #f1f5f9;
  --ai-text-main: #0f172a;
  --ai-text-muted: #64748b;
  --ai-bubble-user: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  --ai-bubble-ai: #ffffff;
  --ai-bubble-ai-border: #e2e8f0;
  --ai-shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --ai-shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --ai-shadow-lg: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
}

/* --- Dedicated AI Workspace Full Page --- */
.ai-workspace {
  min-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  padding-top: 15px !important;
  margin-bottom: 25px;
}

.ai-hero-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 45%, #3730a3 100%);
  color: #ffffff;
  border-radius: 18px;
  padding: 24px 28px;
  margin-bottom: 22px;
  box-shadow: 0 12px 30px -5px rgba(30, 27, 75, 0.35);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.ai-hero-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.3) 0%, rgba(99, 102, 241, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.ai-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 4px 14px;
  border-radius: 30px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fbcfe8;
  margin-bottom: 12px;
}

.ai-hero-info-pill {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 6px 14px;
}

.ai-chat-card {
  background: var(--ai-bg-card);
  border-radius: 18px;
  border: 1px solid var(--ai-border);
  box-shadow: var(--ai-shadow-md);
  display: flex;
  flex-direction: column;
  height: clamp(520px, 72vh, 780px);
  overflow: hidden;
}

.ai-chat-header {
  padding: 14px 22px;
  border-bottom: 1px solid var(--ai-border);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.ai-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.15rem;
  box-shadow: 0 4px 10px rgba(30, 27, 75, 0.2);
  flex-shrink: 0;
}

.user-row .ai-avatar {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #f8fafc;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.ai-message-row {
  display: flex;
  gap: 12px;
  max-width: 88%;
  animation: aiFadeIn 0.3s ease-in-out;
}

.ai-message-row.user-row {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-message-row.ai-row {
  align-self: flex-start;
}

.ai-message-content {
  padding: 14px 20px;
  border-radius: 18px;
  font-size: 0.93rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.user-row .ai-message-content {
  background: var(--ai-bubble-user);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.22);
}

.ai-row .ai-message-content {
  background: var(--ai-bg-card);
  color: var(--ai-text-main);
  border: 1px solid var(--ai-bubble-ai-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

/* Markdown typography inside AI responses */
.ai-message-content h1,
.ai-message-content h2,
.ai-message-content h3,
.ai-message-content h4 {
  color: #1e1b4b;
  font-weight: 700;
  margin-top: 14px;
  margin-bottom: 8px;
}

.ai-message-content h3 {
  font-size: 1.1rem;
  border-bottom: 2px solid #e0e7ff;
  padding-bottom: 4px;
}

.ai-message-content h4 {
  font-size: 0.98rem;
}

.ai-message-content p {
  margin-bottom: 8px;
}

.ai-message-content p:last-child {
  margin-bottom: 0;
}

.ai-message-content ul,
.ai-message-content ol {
  padding-left: 20px;
  margin-bottom: 10px;
}

.ai-message-content li {
  margin-bottom: 4px;
}

.ai-message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.86rem;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.ai-message-content th {
  background: #4f46e5;
  color: #ffffff;
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
}

.ai-message-content td {
  padding: 8px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
}

.ai-message-content tr:nth-child(even) td {
  background: #f8fafc;
}

.ai-message-content tr:hover td {
  background: #f1f5f9;
}

.ai-message-content blockquote {
  border-left: 4px solid #6366f1;
  padding: 8px 14px;
  background: #eef2ff;
  border-radius: 0 8px 8px 0;
  margin: 10px 0;
  color: #3730a3;
  font-style: italic;
}

.ai-message-content code {
  background: #f1f5f9;
  color: #db2777;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.86rem;
}

.ai-message-content pre {
  background: #1e293b;
  color: #f8fafc;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
}

.ai-message-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

/* Quick Suggestion Chips */
.ai-suggestions-bar {
  padding: 10px 22px;
  background: #ffffff;
  border-top: 1px solid #edf2f7;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.ai-suggestions-bar::-webkit-scrollbar {
  display: none;
}

.ai-chip {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ai-chip:hover {
  background: #4f46e5;
  color: #ffffff;
  border-color: #4f46e5;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

/* Chat Input Bar */
.ai-chat-input-wrapper {
  padding: 14px 22px;
  background: #ffffff;
  border-top: 1px solid var(--ai-border);
}

.ai-chat-input-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 14px;
  padding: 5px 12px;
  transition: all 0.2s ease;
}

.ai-chat-input-box:focus-within {
  border-color: #6366f1;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.ai-input-field {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.92rem;
  color: var(--ai-text-main);
  padding: 7px 4px;
  resize: none;
  max-height: 120px;
}

.ai-send-btn {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
  flex-shrink: 0;
}

.ai-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.45);
}

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

/* Dropdown Model Selector in Input Bar */
.ai-input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ai-model-dropdown-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 7px 14px;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.ai-model-dropdown-btn:hover, 
.ai-model-dropdown-btn:focus,
.ai-model-dropdown-btn.show {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.ai-model-dropdown-menu {
  border-radius: 14px;
  box-shadow: 0 14px 35px -5px rgba(15, 23, 42, 0.22);
  min-width: 270px;
  z-index: 1050;
  margin-bottom: 8px !important;
  border: 1px solid #e2e8f0;
}

.ai-model-dropdown-menu .dropdown-item {
  border-radius: 8px;
  transition: all 0.2s ease;
}

.ai-model-dropdown-menu .dropdown-item:hover {
  background: #f8fafc;
}

.ai-dropdown-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.bg-warning-light {
  background: #fef3c7 !important;
  color: #d97706 !important;
}

.bg-primary-light {
  background: #e0e7ff !important;
  color: #4f46e5 !important;
}

.bg-success-light {
  background-color: #ecfdf5 !important;
  color: #059669 !important;
  border: 1px solid #a7f3d0 !important;
}

/* Typing indicator wave */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 16px;
  background: #ffffff;
  border: 1px solid var(--ai-border);
  border-radius: 18px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
  width: fit-content;
}

.ai-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #6366f1;
  opacity: 0.6;
  animation: aiTypingBounce 1.4s infinite ease-in-out both;
}

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

@keyframes aiTypingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

@keyframes aiFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   FLOATING ACTION BUTTON (FAB) & FLOATING MODAL WIDGET
   ========================================================================== */

.ai-fab-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1060;
}

.ai-fab-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45);
  cursor: pointer;
  position: relative;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-fab-btn:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 12px 30px rgba(79, 70, 229, 0.6);
  color: #ffffff;
}

.ai-fab-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: aiPulse 2s infinite;
  pointer-events: none;
}

@keyframes aiPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Floating Modal Dialog */
.ai-modal-widget {
  position: fixed;
  bottom: 86px;
  right: 24px;
  width: 420px;
  height: 590px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 105px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(226, 232, 240, 0.9);
  display: flex;
  flex-direction: column;
  z-index: 1060;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.92) translateY(20px);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-modal-widget.active {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto !important;
}

/* Widget Header Action Buttons */
.ai-header-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  font-size: 0.8rem;
  transition: all 0.2s ease;
  text-decoration: none !important;
}

.ai-header-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(1.08);
  color: #ffffff !important;
}

/* Widget Segmented Switcher Controls */
.ai-widget-switcher {
  display: inline-flex;
  align-items: center;
  background: #e2e8f0;
  padding: 2px;
  border-radius: 20px;
  gap: 2px;
}

.ai-widget-switcher button {
  border: none;
  background: transparent;
  border-radius: 16px;
  padding: 3px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #475569;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.ai-widget-switcher button:hover {
  color: #0f172a;
}

.ai-widget-switcher button.active-gemini {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35) !important;
}

.ai-widget-switcher button.active-openrouter {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35) !important;
}

.ai-widget-switcher button.active-groq {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.35) !important;
}

/* Navbar Button Enhancement */
.ai-navbar-btn {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%) !important;
  color: #ffffff !important;
  border-radius: 20px !important;
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  padding: 5px 12px !important;
  height: 34px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  border: none !important;
  text-decoration: none !important;
  white-space: nowrap !important;
  box-shadow: 0 3px 8px rgba(79, 70, 229, 0.35) !important;
  transition: all 0.25s ease-in-out !important;
}

.ai-navbar-btn:hover {
  transform: translateY(-1px) scale(1.03) !important;
  box-shadow: 0 5px 15px rgba(79, 70, 229, 0.5) !important;
  color: #ffffff !important;
}

.ai-navbar-btn i {
  font-size: 0.88rem !important;
  animation: aiPulseSlow 3s infinite ease-in-out;
}

@keyframes aiPulseSlow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES (Mobile, Tablet, Desktop)
   ========================================================================== */

@media (max-width: 991.98px) {
  .ai-hero-banner {
    padding: 18px 22px;
  }
  .ai-chat-card {
    height: clamp(460px, 68vh, 650px);
  }
  .ai-message-row {
    max-width: 92%;
  }
}

@media (max-width: 767.98px) {
  .ai-workspace {
    min-height: auto;
    padding-top: 10px !important;
  }
  .ai-hero-banner {
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 16px;
  }
  .ai-chat-card {
    height: calc(100vh - 210px);
    min-height: 440px;
    border-radius: 14px;
  }
  .ai-chat-header {
    padding: 10px 14px;
  }
  .ai-chat-messages {
    padding: 14px;
    gap: 14px;
  }
  .ai-message-row {
    max-width: 96%;
    gap: 8px;
  }
  .ai-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
    border-radius: 8px;
  }
  .ai-message-content {
    padding: 10px 14px;
    font-size: 0.88rem;
  }
  .ai-suggestions-bar {
    padding: 8px 12px;
  }
  .ai-chip {
    padding: 4px 10px;
    font-size: 0.75rem;
  }
  .ai-chat-input-wrapper {
    padding: 10px 12px;
  }
  .ai-input-field {
    font-size: 0.86rem;
  }
  .ai-send-btn {
    width: 36px;
    height: 36px;
  }

  .ai-modal-widget {
    width: calc(100vw - 20px);
    height: calc(100vh - 90px);
    bottom: 74px;
    right: 10px;
    left: 10px;
    border-radius: 16px;
  }
  .ai-fab-container {
    bottom: 16px;
    right: 16px;
  }
  .ai-fab-btn {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
}

@media (max-width: 575.98px) {
  .ai-navbar-btn span {
    display: none;
  }
  .ai-navbar-btn {
    padding: 6px 10px !important;
    border-radius: 50% !important;
    width: 32px !important;
    height: 32px !important;
    justify-content: center !important;
  }
}
