/* Agentic Assistant Widget Styles - Students Valley */
.agent-widget-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-primary, #2563eb);
  color: #ffffff;
  border: none;
  font-size: 19px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(37, 99, 235, 0.38), 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, background 0.2s ease;
  outline: none;
}

.agent-widget-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 26px rgba(37, 99, 235, 0.5), 0 3px 8px rgba(0, 0, 0, 0.12);
  background: var(--color-primary-hover, #1d4ed8);
}

.agent-widget-btn:active {
  transform: translateY(-1px) scale(0.98);
}

.agent-widget-btn i {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat Modal */
.agent-chat-modal {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: var(--bg-surface, #ffffff);
  border-radius: var(--radius-xl, 18px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.06);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9995;
  border: 1px solid var(--border-color, rgba(226, 232, 240, 0.9));
  animation: agentModalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-sans, inherit);
}

@keyframes agentModalIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.agent-chat-modal.active {
  display: flex;
}

.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--color-primary, #0f172a);
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.agent-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-title-text {
  display: flex;
  flex-direction: column;
}

.agent-main-title {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.2;
}

.agent-subtitle {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.2;
}

.agent-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.agent-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.agent-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.agent-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-body, #f8fafc);
}

.agent-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  font-size: 13px;
  line-height: 1.5;
}

.agent-msg.user {
  align-self: flex-end;
}

.agent-msg.user .agent-bubble {
  background: var(--color-primary, #2563eb);
  color: #ffffff;
  border-radius: 14px 14px 2px 14px;
  padding: 10px 14px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}

.agent-msg.assistant {
  align-self: flex-start;
}

.agent-msg.assistant .agent-bubble {
  background: var(--bg-surface, #ffffff);
  color: var(--text-primary, #1e293b);
  border-radius: 14px 14px 14px 2px;
  padding: 12px 14px;
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.agent-msg-gap {
  height: 8px;
}

.agent-ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.agent-li {
  margin-bottom: 4px;
}

.agent-loading-state {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-muted, #64748b);
  font-size: 12.5px;
  font-weight: 500;
}

.agent-loading-text {
  transition: opacity 0.15s ease;
  display: inline-block;
}

.agent-loading-state i {
  color: var(--color-primary, #2563eb);
  font-size: 13px;
}

.agent-cursor {
  display: inline-block;
  width: 2px;
  height: 13px;
  background-color: var(--color-primary, #2563eb);
  vertical-align: -1px;
  margin-left: 2px;
  animation: agentCursorBlink 0.75s infinite;
}

@keyframes agentCursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

[data-theme="dark"] .agent-cursor {
  background-color: #60a5fa;
}

.agent-fade-in {
  animation: agentFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.agent-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.agent-chip {
  background: var(--bg-muted, #e2e8f0);
  color: var(--text-primary, #334155);
  border: none;
  border-radius: 12px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.agent-chip:hover {
  background: var(--color-primary, #2563eb);
  color: #ffffff;
  transform: translateY(-1px);
}

.agent-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.agent-result-card {
  display: block;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.agent-result-card.has-image {
  display: flex;
  gap: 12px;
  align-items: center;
}

.agent-card-img-wrap {
  width: 68px;
  height: 68px;
  min-width: 68px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-muted, #f1f5f9);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.agent-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.agent-card-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.agent-result-card:hover {
  border-color: var(--color-primary, #3b82f6);
  box-shadow: 0 3px 10px rgba(59, 130, 246, 0.14);
  transform: translateY(-1px);
}

.agent-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.agent-card-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary, #0f172a);
  line-height: 1.3;
}

.agent-card-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  background: var(--bg-muted, #dbeafe);
  color: var(--color-primary, #1d4ed8);
  border-radius: 4px;
  white-space: nowrap;
}

.agent-card-desc {
  font-size: 11px;
  color: var(--text-secondary, #64748b);
  margin-bottom: 6px;
  line-height: 1.35;
}

.agent-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.agent-card-price {
  font-size: 13px;
  font-weight: 700;
  color: #059669;
}

.agent-card-seller {
  color: var(--text-muted, #64748b);
  font-size: 10px;
}

.agent-input-container {
  padding: 12px 14px;
  background: var(--bg-surface, #ffffff);
  border-top: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-input {
  flex: 1;
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 13px;
  outline: none;
  background: var(--bg-surface, #ffffff);
  color: var(--text-primary, #1e293b);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.agent-input:focus {
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.agent-send-btn {
  background: var(--color-primary, #2563eb);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.agent-send-btn:hover {
  background: var(--color-primary-hover, #1d4ed8);
  transform: scale(1.05);
}

/* ==========================================================================
   Dark Theme Overrides
   ========================================================================== */
[data-theme="dark"] .agent-widget-btn {
  background: var(--color-primary, #3b82f6);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .agent-chat-modal {
  background: #0f172a;
  border-color: #334155;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .agent-header {
  background: #0b1120;
  border-bottom-color: #1e293b;
}

[data-theme="dark"] .agent-messages {
  background: #1e293b;
}

[data-theme="dark"] .agent-msg.assistant .agent-bubble {
  background: #0f172a;
  color: #f1f5f9;
  border-color: #334155;
}

[data-theme="dark"] .agent-loading-state {
  color: #94a3b8;
}

[data-theme="dark"] .agent-chip {
  background: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .agent-chip:hover {
  background: #3b82f6;
  color: #ffffff;
}

[data-theme="dark"] .agent-result-card {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

[data-theme="dark"] .agent-result-card:hover {
  border-color: #60a5fa;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .agent-card-title {
  color: #f8fafc;
}

[data-theme="dark"] .agent-card-badge {
  background: #1e3a8a;
  color: #93c5fd;
}

[data-theme="dark"] .agent-card-desc {
  color: #94a3b8;
}

[data-theme="dark"] .agent-card-seller {
  color: #94a3b8;
}

[data-theme="dark"] .agent-card-price {
  color: #34d399;
}

[data-theme="dark"] .agent-input-container {
  background: #0f172a;
  border-top-color: #334155;
}

[data-theme="dark"] .agent-input {
  background: #1e293b;
  color: #f8fafc;
  border-color: #475569;
}

[data-theme="dark"] .agent-input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

@media (max-width: 640px) {
  .agent-widget-btn {
    bottom: 18px;
    right: 18px;
    left: auto;
    width: 48px;
    height: 48px;
    font-size: 17px;
  }

  .agent-chat-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    z-index: 99999 !important;
  }

  .agent-header {
    border-radius: 0 !important;
    padding: 14px 16px !important;
  }

  .agent-messages {
    flex: 1 1 auto !important;
    height: auto !important;
    padding: 14px !important;
  }

  .agent-input-container {
    padding: 12px 14px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    border-radius: 0 !important;
  }
}
