/* ===== CSS VARIABLES ===== */
:root {
  --primary: #FF6B2B;
  --primary-dark: #e05420;
  --primary-light: #FF8C57;
  --secondary: #FFC107;
  --accent: #7C3AED;
  --bg-dark: #0D0D1A;
  --bg-card: #16162A;
  --bg-sidebar: #111124;
  --bg-input: #1E1E35;
  --border: rgba(255, 255, 255, 0.08);
  --text-primary: #F0F0FF;
  --text-secondary: #9999BB;
  --text-muted: #6666AA;
  --bot-bubble: #1E1E38;
  --user-bubble: linear-gradient(135deg, #FF6B2B, #FF4500);
  --font: 'Outfit', sans-serif;
  --radius: 18px;
  --radius-sm: 10px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
}

/* ===== BACKGROUND BLOBS ===== */
.bg-blobs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.12;
  animation: blobFloat 8s ease-in-out infinite;
}

.blob-1 {
  width: 600px;
  height: 600px;
  background: var(--primary);
  top: -200px;
  left: -100px;
  animation-delay: 0s;
}

.blob-2 {
  width: 500px;
  height: 500px;
  background: var(--accent);
  bottom: -150px;
  right: -100px;
  animation-delay: 3s;
}

.blob-3 {
  width: 350px;
  height: 350px;
  background: var(--secondary);
  top: 50%;
  left: 40%;
  animation-delay: 1.5s;
}

@keyframes blobFloat {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(20px, -30px) scale(1.05);
  }

  66% {
    transform: translate(-15px, 20px) scale(0.95);
  }
}

/* ===== APP WRAPPER ===== */
.app-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  height: 100dvh; /* mobile fix: excludes browser chrome */
  width: 100vw;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  gap: 28px;
  overflow-y: auto;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.sidebar-header {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 50px;
  height: 50px;
  background: var(--user-bubble);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 8px 20px rgba(255, 107, 43, 0.4);
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.logo-text span {
  color: var(--primary);
}

.logo-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-info h3,
.sidebar-faculties h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.features-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.features-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  transition: background var(--transition);
  cursor: default;
}

.features-list li:hover {
  background: rgba(255, 107, 43, 0.08);
  border-color: rgba(255, 107, 43, 0.2);
  color: var(--text-primary);
}

.feat-icon {
  font-size: 1.1rem;
}

.faculty-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.faculty-tag {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition);
}

.faculty-tag:hover {
  background: rgba(255, 107, 43, 0.15);
  border-color: var(--primary);
  color: var(--primary-light);
  transform: translateY(-1px);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(255, 107, 43, 0.2));
  border: 1px solid rgba(124, 58, 237, 0.3);
  color: #C4A8FF;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
}

.made-by {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ===== CHAT AREA ===== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(13, 13, 26, 0.5);
  backdrop-filter: blur(20px);
  min-width: 0;
}

/* ===== CHAT HEADER ===== */
.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(17, 17, 36, 0.8);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Hamburger: hidden on desktop */
.menu-toggle {
  display: none;
  background: var(--user-bubble);
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px 11px;
  border-radius: 10px;
  transition: all var(--transition);
  line-height: 1;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(255, 107, 43, 0.3);
}

.menu-toggle:hover {
  opacity: 0.85;
}

.header-avatar {
  width: 44px;
  height: 44px;
  background: var(--user-bubble);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(255, 107, 43, 0.3);
  flex-shrink: 0;
}

.chat-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.status-dot-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #22C55E;
  border-radius: 50%;
  animation: pulseDot 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulseDot {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(34, 197, 94, 0);
  }
}

.status-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.clear-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.clear-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
}

/* ===== MESSAGES ===== */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
  width: 5px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: msgIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 100%;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.bot-message .message-avatar {
  background: var(--bot-bubble);
  border: 1px solid var(--border);
}

/* User message: avatar right, bubble left — using flex-end + column */
.user-message {
  flex-direction: row-reverse;
  align-self: flex-end;
  max-width: 75%;
}

.user-message .message-avatar {
  background: var(--user-bubble);
  box-shadow: 0 4px 12px rgba(255, 107, 43, 0.3);
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.user-message .message-content {
  align-items: flex-end;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 0.93rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.bot-message .message-bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-top-left-radius: 5px;
  color: var(--text-primary);
}

.user-message .message-bubble {
  background: var(--user-bubble);
  border-top-right-radius: 5px;
  color: #fff;
  box-shadow: 0 4px 16px rgba(255, 107, 43, 0.25);
}

.message-bubble p {
  margin-bottom: 6px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble strong {
  color: var(--primary-light);
}

.user-message .message-bubble strong {
  color: #fff;
  font-weight: 700;
}

/* Tables inside bubbles */
.message-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.85rem;
  display: block;
  overflow-x: auto;
}

.message-bubble th {
  background: rgba(255, 107, 43, 0.15);
  color: var(--primary-light);
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 107, 43, 0.3);
  font-weight: 600;
  white-space: nowrap;
}

.message-bubble td {
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  white-space: nowrap;
}

.message-bubble tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 4px;
  white-space: nowrap;
}

/* ===== QUICK REPLIES ===== */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-left: 50px;
}

.quick-reply {
  background: rgba(255, 107, 43, 0.08);
  border: 1px solid rgba(255, 107, 43, 0.25);
  color: var(--primary-light);
  font-family: var(--font);
  font-size: 0.83rem;
  padding: 9px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition);
}

.quick-reply:hover {
  background: rgba(255, 107, 43, 0.2);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 43, 0.2);
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  animation: msgIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.typing-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.typing-bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-top-left-radius: 5px;
  padding: 14px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }

  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ===== INPUT AREA ===== */
.chat-input-area {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  background: rgba(17, 17, 36, 0.8);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 12px 12px 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
  border-color: rgba(255, 107, 43, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 107, 43, 0.1);
}

textarea#userInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.94rem;
  line-height: 1.6;
  resize: none;
  max-height: 140px;
  overflow-y: auto;
  min-width: 0;
}

textarea#userInput::placeholder {
  color: var(--text-muted);
}

textarea#userInput::-webkit-scrollbar {
  width: 3px;
}

textarea#userInput::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--user-bubble);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  box-shadow: 0 4px 12px rgba(255, 107, 43, 0.35);
}

.send-btn:hover {
  transform: scale(1.05) translateY(-1px);
  box-shadow: 0 8px 20px rgba(255, 107, 43, 0.4);
}

.send-btn:active {
  transform: scale(0.97);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.send-icon {
  font-size: 1.1rem;
  color: #fff;
  line-height: 1;
}

.input-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 8px;
  padding-left: 4px;
}

/* ===== ERROR BUBBLE ===== */
.error-bubble {
  background: rgba(239, 68, 68, 0.1) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  color: #FCA5A5 !important;
}

/* ===== FALLBACK MENU BUTTONS ===== */
.fb-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.fb-btn {
  background: rgba(255, 107, 43, 0.1);
  border: 1.5px solid rgba(255, 107, 43, 0.35);
  color: var(--primary-light);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  line-height: 1.3;
}

.fb-btn:hover:not(:disabled) {
  background: rgba(255, 107, 43, 0.22);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 43, 0.2);
}

.fb-btn:active:not(:disabled) {
  transform: translateY(0);
}

.fb-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}

.fb-btn-sm {
  font-size: 0.78rem;
  padding: 6px 12px;
}

.fb-faculty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 8px;
  width: 100%;
}

.fb-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 7px;
  width: 100%;
}

/* ===== OVERLAY (mobile sidebar backdrop) ===== */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 999;
  cursor: pointer;
}

.overlay.active {
  display: block;
}

/* ===== RESPONSIVE — MOBILE ===== */
@media (max-width: 900px) {

  /* Sidebar hidden off-screen by default */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 280px;
    min-width: 280px;
    z-index: 1000;
    transform: translateX(-110%);
    box-shadow: 6px 0 40px rgba(0, 0, 0, 0.8);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Show hamburger button — prominent orange style */
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
  }

  /* Chat fills full width */
  .chat-area {
    width: 100%;
    min-width: 0;
  }

  /* Hide user avatar to prevent overflow artifact */
  .user-message .message-avatar {
    display: none;
  }

  .user-message {
    max-width: 85%;
  }

  /* Smaller padding on mobile */
  .chat-header {
    padding: 12px 14px;
  }

  .messages-container {
    padding: 12px;
  }

  .chat-input-area {
    padding: 10px 12px 14px;
  }

  .quick-replies {
    padding-left: 0;
    gap: 6px;
  }

  .quick-reply {
    font-size: 0.76rem;
    padding: 6px 11px;
  }

  .message-bubble {
    font-size: 0.88rem;
    padding: 10px 13px;
  }

  .fb-faculty-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .fb-product-grid {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 100vw;
    min-width: 100vw;
  }

  .clear-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .message-bubble {
    font-size: 0.84rem;
  }
}