:root {
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.4);
  --secondary: #ec4899;
  --bg-dark: #0f172a;
  --glass-bg: rgba(15, 23, 42, 0.6);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --bot-msg-bg: rgba(30, 41, 59, 0.7);
  --user-msg-bg: #6366f1;
}

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

body {
  font-family: "Outfit", sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

/* Background Effects */
.background-glow {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 50% 50%, #1e1b4b 0%, #0f172a 50%);
  z-index: -1;
  pointer-events: none;
}

.background-glow::after {
  content: "";
  position: absolute;
  top: 20%;
  right: 20%;
  width: 400px;
  height: 400px;
  background: var(--primary-glow);
  filter: blur(100px);
  opacity: 0.3;
  animation: float 10s infinite alternate;
}

@keyframes float {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(50px, 50px);
  }
}

/* Layout */
/* Layout */
.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(20px);
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: rgba(15, 23, 42, 0.6);
  border-right: 1px solid var(--glass-border);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex-shrink: 0;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: linear-gradient(to right, #818cf8, #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--glass-border);
}

.nav-group label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  letter-spacing: 1px;
  font-weight: 600;
}

.custom-select-wrapper {
  position: relative;
}

.custom-select-wrapper select {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 0.8rem;
  border-radius: 12px;
  appearance: none;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.custom-select-wrapper select:hover {
  border-color: var(--primary);
  background: rgba(0, 0, 0, 0.4);
}

.arrow-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
}

.footer-group {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--glass-border);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 10%;
  padding-bottom: 120px;
  scroll-behavior: smooth;
}

/* Ensure messages don't overflow */
.message {
  max-width: 800px;
  /* Constrain message width */
  margin: 0 auto 1.5rem auto;
  /* Center messages if wanted, or align left/right */
  width: fit-content;
}

.bot-message {
  margin-left: 0;
  max-width: 85%;
}

.user-message {
  margin-right: 0;
  max-width: 70%;
  margin-left: auto;
}

/* Input Area Redesign */
.input-container {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 800px;
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 0.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

header {
  display: none;
}

/* Hide old header styles if referenced anywhere */

/* Intro Message */
.intro-message .content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.intro-message h2 {
  font-size: 1.5rem;
  font-weight: 500;
}

.chips {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.chips button {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.chips button:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  color: #fff;
}

/* Messages */
.message {
  display: flex;
  gap: 1rem;
  max-width: 85%;
  opacity: 0;
  animation: fadeIn 0.4s forwards;
  /* Ensure flex item doesn't overflow parent */
  min-width: 0;
}

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

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.2rem;
}

.bot-message .avatar {
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  color: white;
}

.user-message .avatar {
  background: var(--text-muted);
  /* Fallback */
  display: none;
  /* Hide user avatar usually cleaner */
}

.content {
  padding: 1rem 1.25rem;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.6;
  position: relative;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);

  /* Text Overflow Fix */
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}

.bot-message .content {
  background: var(--bot-msg-bg);
  border: 1px solid var(--glass-border);
  border-top-left-radius: 4px;
}

.user-message .content {
  background: var(--user-msg-bg);
  color: white;
  border-top-right-radius: 4px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }

  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* Input Area */
.input-container {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 800px;
  border-radius: 16px;
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.model-selector select {
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  font-family: "Inter", sans-serif;
}

.model-selector select:hover {
  border-color: var(--accent-color);
}

.input-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.2);
}

.input-wrapper {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
}

input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.8rem 1rem;
  color: white;
  font-size: 1rem;
  outline: none;
  font-family: inherit;
}

input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

#sendBtn {
  background: var(--primary);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.2s;
}

#sendBtn:hover {
  transform: scale(1.05);
  background: #4f46e5;
}

/* Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

/* Loader */
.thinking-dots {
  display: flex;
  gap: 4px;
  padding: 0.5rem 0;
}

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

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

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

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

  40% {
    transform: scale(1);
  }
}

/* Debug SQL Pill */
.debug-pill {
  font-size: 0.7rem;
  margin-top: 0.5rem;
  padding: 0.2rem 0.6rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  cursor: pointer;
  display: inline-block;
  color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
  border: 1px solid transparent;
}

.debug-pill:hover {
  border-color: var(--glass-border);
  color: var(--text-main);
}

.debug-content {
  display: none;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #000;
  border-radius: 6px;
  color: #4ade80;
  /* Matrix green */
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
}

/* Product Cards */
.product-carousel {
  display: flex;
  overflow-x: auto;
  gap: 1.2rem;
  padding: 0.8rem 0.5rem;
  margin-top: 1.5rem;
  width: 100%;
  max-width: 100%;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scroll-padding-left: 0.5rem;
}

.product-carousel::-webkit-scrollbar {
  height: 6px;
  /* Visible scrollbar for desktop usability */
}

.product-carousel::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.product-carousel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

.product-card {
  flex-shrink: 0;
  width: 260px;
  /* Fixed width */
  background: linear-gradient(
    160deg,
    rgba(30, 41, 59, 0.9) 0%,
    rgba(15, 23, 42, 0.95) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  /* Suggest interaction */
}

/* Glow effect on hover */
.product-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: radial-gradient(
    circle at top right,
    rgba(99, 102, 241, 0.15),
    transparent 60%
  );
  opacity: 0.5;
  transition: opacity 0.3s;
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
  border-color: rgba(99, 102, 241, 0.4);
}

.product-card:hover::before {
  opacity: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 1;
}

.brand {
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.score-badge {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.score-badge.high {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
}

.score-badge.med {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
}

.product-card h3 {
  position: relative;
  z-index: 1;
  font-size: 1.25rem;
  font-weight: 600;
  color: #f1f5f9;
  /* Limit to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  height: 3.5rem;
  /* Consistent height */
  margin: 0;
}

.price {
  position: relative;
  z-index: 1;
  font-size: 1.2rem;
  color: #818cf8;
  font-weight: 700;
}

.specs {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.8rem;
  border-radius: 12px;
  margin-top: auto;
  /* Push to bottom */
}

.specs span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #cbd5e1;
}

/* --- MODAL & BUTTONS --- */
.glow-btn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  color: white;
  padding: 0.8rem 1.5rem;
  border-radius: 30px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--primary-glow);
  transition: transform 0.2s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.glow-btn-small {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.glow-btn-small:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  color: #fff;
}

.glow-btn:hover {
  transform: scale(1.05);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s;
}

.modal-content {
  background: #1e293b;
  width: 90%;
  max-width: 600px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
}

.modal-header h2 {
  font-size: 1.25rem;
  margin: 0;
  color: #fff;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.comp-table {
  width: 100%;
  border-collapse: collapse;
}

.comp-table th,
.comp-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.comp-table th {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  font-weight: 600;
}

.comp-table td {
  color: #e2e8f0;
  font-size: 0.95rem;
}

.comp-table tr:last-child td {
  border-bottom: none;
}

.text-green {
  color: #4ade80;
  font-weight: 600;
}

.text-red {
  color: #ef4444;
  opacity: 0.8;
}

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

.specs i {
  color: #64748b;
}

/* --- COMPARISON MODE STYLES --- */
.comparison-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
  position: relative;
  padding-bottom: 1rem;
}

.comparison-card {
  width: 250px;
  /* Slightly narrower to fit side-by-side */
  border-color: rgba(255, 255, 255, 0.08);
}

.vs-badge {
  background: #000;
  color: #fff;
  font-weight: 800;
  font-style: italic;
  padding: 0.8rem;
  border-radius: 50%;
  border: 2px solid var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
  z-index: 10;
  font-size: 1.2rem;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.comp-win {
  color: #4ade80 !important;
  /* Green */
  text-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

.comp-lose {
  color: #ef4444 !important;
  /* Red */
  opacity: 0.8;
}

/* Mobile responsive for comparison */
@media (max-width: 600px) {
  .comparison-container {
    flex-direction: column;
    gap: 2rem;
  }

  .vs-badge {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
  }
}

/* --- DASHBOARD STYLES --- */

/* Sidebar Navigation */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--glass-border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.3);
}

.nav-item i {
  font-size: 1.2rem;
}

/* View Container */
.view-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.view-container.hidden {
  display: none;
}

/* Dashboard Header */
.dashboard-header {
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border-bottom: 1px solid var(--glass-border);
}

.dashboard-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-main);
}

.refresh-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  padding: 2rem;
}

.stat-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  opacity: 0.7;
}

.stat-card h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.stat-card .label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Recent Runs Table */
.recent-runs {
  flex: 1;
  margin: 0 2rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
}

.recent-runs h3 {
  padding: 1.5rem;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--glass-border);
  margin: 0;
  background: rgba(255, 255, 255, 0.02);
}

.table-wrapper {
  flex: 1;
  overflow: auto;
}

.runs-table {
  width: 100%;
  border-collapse: collapse;
}

.runs-table th,
.runs-table td {
  padding: 1rem 1.5rem;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

.runs-table th {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  backdrop-filter: blur(5px);
}

.runs-table td {
  font-size: 0.95rem;
  color: #e2e8f0;
}

.runs-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge.success {
  background: rgba(74, 222, 128, 0.1);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.2);
}

.status-badge.partial {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.status-badge.running {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

.status-badge.failed {
  background: rgba(248, 113, 113, 0.1);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.2);
}
