/* ============================================
   MODERN CHATBOT UI WITH ANIMATIONS
   ============================================ */

:root {
  --primary-color: #667eea;
  --primary-dark: #5568d3;
  --secondary-color: #764ba2;
  --success-color: #48bb78;
  --warning-color: #f6ad55;
  --danger-color: #fc8181;
  --light-bg: #f7fafc;
  --dark-text: #2d3748;
  --border-color: #e2e8f0;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.15);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================
   FLOATING CHAT BUTTON
   ============================================ */
.chatbot-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border: none;
  color: white;
  font-size: 32px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
  z-index: 10000;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 2s infinite;
}

.chatbot-btn:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 12px 32px rgba(102, 126, 234, 0.6);
}

.chatbot-btn:active {
  transform: scale(0.95);
}

.notification-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  background: var(--danger-color);
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  animation: bounce 1s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4); }
  50% { box-shadow: 0 8px 32px rgba(102, 126, 234, 0.7); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ============================================
   CHAT WINDOW
   ============================================ */
.chat-window {
  position: fixed;
  bottom: 120px;
  right: 30px;
  width: 440px;
  max-height: 680px;
  border-radius: 24px;
  overflow: hidden;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: white;
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-window.d-none {
  animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
}

/* ============================================
   CHAT HEADER
   ============================================ */
.chat-header {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255,255,255,0.3);
}

.chat-avatar i {
  font-size: 24px;
  color: white;
}

.chat-header-text h6 {
  color: white;
  font-weight: 600;
  font-size: 18px;
  margin: 0;
}

.chat-header-text small {
  color: rgba(255,255,255,0.8);
  font-size: 13px;
}

.btn-back {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-right: 10px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-back:hover {
  background: rgba(255,255,255,0.3);
  transform: translateX(-3px);
}

.btn-close-chat {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-chat:hover {
  background: rgba(255,255,255,0.3);
  transform: rotate(90deg);
}

/* ============================================
   CHAT BODY
   ============================================ */
.chat-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
  background: var(--light-bg);
  max-height: 520px;
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 10px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* ============================================
   CATEGORY GRID
   ============================================ */
.subtitle {
  text-align: center;
  color: var(--dark-text);
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 20px;
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 16px 0;
}

.category-tile {
  background: white;
  border: 2px solid var(--border-color);
  border-radius: 16px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  animation: scaleIn 0.4s ease-out;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.category-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  opacity: 0;
  transition: var(--transition);
  z-index: 0;
}

.category-tile:hover::before {
  opacity: 0.1;
}

.category-tile:hover {
  border-color: var(--primary-color);
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.category-tile i {
  font-size: 2.5rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
  transition: var(--transition);
}

.category-tile:hover i {
  transform: scale(1.1) rotate(5deg);
}

.category-tile div {
  font-weight: 600;
  color: var(--dark-text);
  font-size: 15px;
  position: relative;
  z-index: 1;
}

/* ============================================
   SEARCH BAR & INPUTS
   ============================================ */
.search-bar,
textarea.form-control,
input.form-control {
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  transition: var(--transition);
  background: white;
}

.search-bar:focus,
textarea.form-control:focus,
input.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
  outline: none;
}

/* ============================================
   ACCORDION
   ============================================ */
.accordion-item {
  border: 2px solid var(--border-color);
  margin-bottom: 12px;
  border-radius: 12px;
  overflow: hidden;
  transition: var(--transition);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.accordion-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.accordion-button {
  font-weight: 500;
  font-size: 15px;
  padding: 16px;
  background: white;
  transition: var(--transition);
}

.accordion-button:not(.collapsed) {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  color: var(--primary-color);
}

.accordion-button:focus {
  box-shadow: none;
  border-color: var(--primary-color);
}

.accordion-body {
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
  background: var(--light-bg);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  border-radius: 12px;
  padding: 12px 24px;
  font-weight: 600;
  font-size: 15px;
  transition: var(--transition);
  border: none;
}

.btn-primary,
.btn-success {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover,
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.btn-outline-secondary,
.btn-outline-primary {
  border: 2px solid currentColor;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
  border-radius: 12px;
  border: none;
  padding: 16px;
  animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert-info {
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
  color: #0369a1;
  border-left: 4px solid #0ea5e9;
}

.alert-success {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  color: #15803d;
  border-left: 4px solid #22c55e;
}

.alert-warning {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  border-left: 4px solid #f59e0b;
}

.alert-danger {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #991b1b;
  border-left: 4px solid #ef4444;
}

/* ============================================
   AUTOCOMPLETE DROPDOWN
   ============================================ */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  margin-top: 8px;
  animation: dropDown 0.3s ease-out;
}

@keyframes dropDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.autocomplete-dropdown.show {
  display: block;
}

.autocomplete-item {
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
  padding-left: 20px;
}

/* ============================================
   SPELLING SUGGESTIONS
   ============================================ */
#spellingSuggestions .alert,
#customSpellingSuggestions .alert {
  animation: shakeIn 0.5s ease-out;
}

@keyframes shakeIn {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ============================================
   CHAT FOOTER
   ============================================ */
.chat-footer {
  padding: 12px 20px;
  background: white;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.chat-footer small {
  color: #718096;
  font-size: 12px;
}

/* ============================================
   LOADING SPINNERS
   ============================================ */
.spinner-border {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
  .chat-window {
    width: calc(100vw - 40px);
    right: 20px;
    bottom: 100px;
    max-height: calc(100vh - 140px);
  }
  
  .chatbot-btn {
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    font-size: 28px;
  }
  
  .category-grid {
    grid-template-columns: 1fr;
  }
  
  .chat-body {
    max-height: calc(100vh - 260px);
  }
}

@media (max-width: 480px) {
  .chat-window {
    width: 100vw;
    right: 0;
    left: 0;
    bottom: 0;
    border-radius: 0;
    max-height: 100vh;
  }
  
  .chat-body {
    max-height: calc(100vh - 180px);
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.position-relative {
  position: relative;
}

.text-start {
  text-align: left !important;
}

.badge {
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 600;
}

/* ============================================
   SMOOTH TRANSITIONS
   ============================================ */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.card {
  border-radius: 16px;
  border: none;
  box-shadow: var(--shadow-sm);
}

.card-header {
  border-radius: 16px 16px 0 0 !important;
  padding: 16px 20px;
}

.card-body {
  padding: 20px;
}

#appDropdown {
  max-width: 300px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}