html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* ============================================
   DARK MODE STYLES
   ============================================ */

/* Dark mode CSS variables */
[data-theme="dark"] {
  --bs-body-bg: #1a1d21;
  --bs-body-color: #e1e1e1;
  --bs-card-bg: #2d3238;
  --bs-border-color: #495057;
  --bs-table-bg: #2d3238;
  --bs-table-border-color: #495057;
  --bs-input-bg: #3d4450;
  --bs-input-border-color: #495057;
  --bs-input-color: #e1e1e1;
}

/* Body and background */
[data-theme="dark"] body {
  background-color: #1a1d21 !important;
  color: #e1e1e1;
}

/* Navbar */
[data-theme="dark"] .navbar {
  background-color: #2d3238 !important;
  border-color: #495057 !important;
}

[data-theme="dark"] .navbar-brand,
[data-theme="dark"] .nav-link {
  color: #e1e1e1 !important;
}

[data-theme="dark"] .nav-link:hover {
  color: #7cb3f0 !important;
}

/* Cards */
[data-theme="dark"] .card {
  background-color: #2d3238;
  border-color: #495057;
  color: #e1e1e1;
}

[data-theme="dark"] .card-header {
  background-color: #343a40;
  border-color: #495057;
  color: #e1e1e1;
}

[data-theme="dark"] .card-header.bg-primary {
  background-color: #0d6efd !important;
}

[data-theme="dark"] .card-header.bg-info {
  background-color: #0dcaf0 !important;
  color: #000 !important;
}

/* Tables */
[data-theme="dark"] .table {
  color: #e1e1e1;
  --bs-table-bg: #2d3238;
  --bs-table-border-color: #495057;
}

[data-theme="dark"] .table-bordered {
  border-color: #495057;
}

[data-theme="dark"] .table-bordered td,
[data-theme="dark"] .table-bordered th {
  border-color: #495057;
}

[data-theme="dark"] .table-hover tbody tr:hover {
  background-color: #3d4450;
  color: #e1e1e1;
}

[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] thead.table-dark {
  background-color: #212529;
}

[data-theme="dark"] thead.table-light {
  background-color: #3d4450;
  color: #e1e1e1;
}

[data-theme="dark"] .table-secondary {
  --bs-table-bg: #3d4450;
  color: #adb5bd;
}

[data-theme="dark"] .table-primary {
  --bs-table-bg: #1e3a5f;
  color: #9ec5fe;
}

[data-theme="dark"] .table-success {
  --bs-table-bg: #1a4231;
  color: #a3cfbb;
}

[data-theme="dark"] .table-danger {
  --bs-table-bg: #4a1f24;
  color: #f1aeb5;
}

[data-theme="dark"] .table-warning {
  --bs-table-bg: #4a3f1f;
  color: #ffe69c;
}

/* Forms */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: #3d4450;
  border-color: #495057;
  color: #e1e1e1;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: #3d4450;
  border-color: #7cb3f0;
  color: #e1e1e1;
}

[data-theme="dark"] .form-control::placeholder {
  color: #8b949e;
}

[data-theme="dark"] .form-text {
  color: #8b949e;
}

[data-theme="dark"] .form-label {
  color: #e1e1e1;
}

/* Alerts */
[data-theme="dark"] .alert-info {
  background-color: #1a3a4a;
  border-color: #2d5a6a;
  color: #9ed5ea;
}

[data-theme="dark"] .alert-success {
  background-color: #1a4231;
  border-color: #2d6a4a;
  color: #a3cfbb;
}

[data-theme="dark"] .alert-warning {
  background-color: #4a3f1f;
  border-color: #6a5f2f;
  color: #ffe69c;
}

[data-theme="dark"] .alert-danger {
  background-color: #4a1f24;
  border-color: #6a2f34;
  color: #f1aeb5;
}

/* Modals */
[data-theme="dark"] .modal-content {
  background-color: #2d3238;
  border-color: #495057;
  color: #e1e1e1;
}

[data-theme="dark"] .modal-header {
  border-color: #495057;
}

[data-theme="dark"] .modal-footer {
  border-color: #495057;
}

[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Accordion */
[data-theme="dark"] .accordion-item {
  background-color: #2d3238;
  border-color: #495057;
}

[data-theme="dark"] .accordion-button {
  background-color: #343a40;
  color: #e1e1e1;
}

[data-theme="dark"] .accordion-button:not(.collapsed) {
  background-color: #3d4450;
  color: #7cb3f0;
}

[data-theme="dark"] .accordion-button::after {
  filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="dark"] .accordion-body {
  background-color: #2d3238;
  color: #e1e1e1;
}

/* Borders and dividers */
[data-theme="dark"] .border {
  border-color: #495057 !important;
}

[data-theme="dark"] .border-bottom {
  border-color: #495057 !important;
}

[data-theme="dark"] hr {
  border-color: #495057;
}

/* Footer */
[data-theme="dark"] .footer {
  background-color: #2d3238;
  border-color: #495057 !important;
  color: #8b949e;
}

/* Text colors */
[data-theme="dark"] .text-dark {
  color: #e1e1e1 !important;
}

[data-theme="dark"] .text-muted {
  color: #8b949e !important;
}

[data-theme="dark"] a:not(.btn):not(.nav-link):not(.badge) {
  color: #7cb3f0;
}

[data-theme="dark"] a:not(.btn):not(.nav-link):not(.badge):hover {
  color: #9ec5fe;
}

/* Badges - keep them visible */
[data-theme="dark"] .badge.bg-light {
  background-color: #495057 !important;
  color: #e1e1e1 !important;
}

/* Progress bars */
[data-theme="dark"] .progress {
  background-color: #3d4450;
}

/* Dropdown menus */
[data-theme="dark"] .dropdown-menu {
  background-color: #2d3238;
  border-color: #495057;
}

[data-theme="dark"] .dropdown-item {
  color: #e1e1e1;
}

[data-theme="dark"] .dropdown-item:hover {
  background-color: #3d4450;
  color: #e1e1e1;
}

/* Code blocks */
[data-theme="dark"] code {
  color: #f0a8a8;
  background-color: #3d4450;
}

[data-theme="dark"] pre {
  background-color: #3d4450;
  color: #e1e1e1;
}

/* Theme toggle button */
.theme-toggle {
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Smooth transition for theme switch */
body,
.card,
.navbar,
.table,
.form-control,
.modal-content,
.accordion-item,
.accordion-button,
.alert {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* ============================================
   INTERACTIVE PAGE TOUR STYLES
   ============================================ */

/* Tour active state */
body.tour-active {
  overflow: hidden;
}

/* Tour backdrop/overlay */
.tour-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9998;
  pointer-events: none;
}

.tour-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  pointer-events: all;
}

/* Tour highlight box */
.tour-highlight {
  position: absolute;
  z-index: 9999;
  border-radius: 8px;
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.6), 0 0 0 9999px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transition: all 0.3s ease;
}

/* Tour popover */
.tour-popover {
  position: absolute;
  z-index: 10000;
  width: 340px;
  max-width: 90vw;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  animation: tourFadeIn 0.3s ease;
}

@keyframes tourFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dark mode tour popover */
[data-theme="dark"] .tour-popover {
  background: #2d3238;
  color: #e1e1e1;
}

/* Tour popover header */
.tour-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 8px;
  border-bottom: 1px solid #e9ecef;
}

[data-theme="dark"] .tour-popover-header {
  border-color: #495057;
}

.tour-step-indicator {
  font-size: 12px;
  font-weight: 600;
  color: #0d6efd;
  background: rgba(13, 110, 253, 0.1);
  padding: 4px 10px;
  border-radius: 20px;
}

[data-theme="dark"] .tour-step-indicator {
  background: rgba(13, 110, 253, 0.2);
}

.tour-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #6c757d;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.tour-close:hover {
  color: #dc3545;
}

/* Tour popover title */
.tour-popover-title {
  font-size: 18px;
  font-weight: 600;
  padding: 12px 16px 4px;
  color: #212529;
}

[data-theme="dark"] .tour-popover-title {
  color: #e1e1e1;
}

/* Tour popover content */
.tour-popover-content {
  padding: 8px 16px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: #495057;
}

[data-theme="dark"] .tour-popover-content {
  color: #adb5bd;
}

/* Tour popover footer */
.tour-popover-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid #e9ecef;
  background: #f8f9fa;
  border-radius: 0 0 12px 12px;
}

[data-theme="dark"] .tour-popover-footer {
  background: #343a40;
  border-color: #495057;
}

.tour-btn-prev,
.tour-btn-skip,
.tour-btn-next {
  font-size: 13px;
}

.tour-btn-skip {
  color: #6c757d;
}

/* Tour popover arrow indicators */
.tour-popover::before {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border: 10px solid transparent;
}

.tour-popover-bottom::before {
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  border-bottom-color: #fff;
}

[data-theme="dark"] .tour-popover-bottom::before {
  border-bottom-color: #2d3238;
}

.tour-popover-top::before {
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  border-top-color: #f8f9fa;
}

[data-theme="dark"] .tour-popover-top::before {
  border-top-color: #343a40;
}

.tour-popover-left::before {
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  border-left-color: #fff;
}

[data-theme="dark"] .tour-popover-left::before {
  border-left-color: #2d3238;
}

.tour-popover-right::before {
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  border-right-color: #fff;
}

[data-theme="dark"] .tour-popover-right::before {
  border-right-color: #2d3238;
}

/* Tour button in navbar */
.tour-start-btn {
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.tour-start-btn:hover {
  opacity: 1;
}

/* ============================================
   LOADING OVERLAY STYLES
   ============================================ */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

[data-theme="dark"] .loading-overlay {
  background-color: rgba(26, 29, 33, 0.95);
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid #e9ecef;
  border-top-color: #0d6efd;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

[data-theme="dark"] .loading-spinner {
  border-color: #495057;
  border-top-color: #7cb3f0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin-top: 1.5rem;
  font-size: 1.25rem;
  font-weight: 500;
  color: #212529;
}

[data-theme="dark"] .loading-text {
  color: #e1e1e1;
}

.loading-subtext {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: #6c757d;
}

[data-theme="dark"] .loading-subtext {
  color: #8b949e;
}

/* Pulsing dots animation for the loading text */
.loading-dots {
  display: inline-block;
}

.loading-dots span {
  animation: loadingDots 1.4s infinite ease-in-out both;
  display: inline-block;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingDots {
  0%, 80%, 100% {
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
}

/* AI-specific loading animation */
.loading-ai-icon {
  font-size: 3rem;
  color: #0d6efd;
  animation: pulse 2s ease-in-out infinite;
  margin-bottom: 1rem;
}

[data-theme="dark"] .loading-ai-icon {
  color: #7cb3f0;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.7;
  }
}

/* Progress bar for loading */
.loading-progress {
  width: 200px;
  height: 4px;
  background-color: #e9ecef;
  border-radius: 2px;
  margin-top: 1rem;
  overflow: hidden;
}

[data-theme="dark"] .loading-progress {
  background-color: #495057;
}

.loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0d6efd, #6610f2, #0d6efd);
  background-size: 200% 100%;
  animation: progressSlide 1.5s ease-in-out infinite;
  border-radius: 2px;
}

@keyframes progressSlide {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* ============================================
   GLOBAL AI CHAT WIDGET STYLES
   ============================================ */

/* Chat Toggle Button */
.global-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(13, 110, 253, 0.4);
  transition: all 0.3s ease;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
}

.global-chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(13, 110, 253, 0.5);
}

.global-chat-toggle:active {
  transform: scale(0.95);
}

.chat-toggle-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #dc3545;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat Panel */
.global-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 9991;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s ease;
}

.global-chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

[data-theme="dark"] .global-chat-panel {
  background: #2d3238;
  border: 1px solid #495057;
}

/* Chat Header */
.chat-header {
  padding: 16px;
  background: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
  color: white;
  border-radius: 16px 16px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header .bi-robot {
  font-size: 20px;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  display: flex;
  max-width: 85%;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-message.assistant {
  align-self: flex-start;
}

.chat-message.error {
  align-self: center;
}

.message-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-message.user .message-content {
  background: #0d6efd;
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-content {
  background: #f0f2f5;
  color: #212529;
  border-bottom-left-radius: 4px;
}

[data-theme="dark"] .chat-message.assistant .message-content {
  background: #3d4450;
  color: #e1e1e1;
}

.chat-message.error .message-content {
  background: #fff3cd;
  color: #856404;
  font-size: 13px;
}

[data-theme="dark"] .chat-message.error .message-content {
  background: #4a3f1f;
  color: #ffe69c;
}

.message-content ul {
  margin-bottom: 0;
  padding-left: 20px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #6c757d;
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Chat Suggestions */
.chat-suggestions {
  padding: 8px 16px;
  border-top: 1px solid #e9ecef;
}

[data-theme="dark"] .chat-suggestions {
  border-color: #495057;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion-chip {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid #dee2e6;
  background: #fff;
  color: #495057;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.suggestion-chip:hover {
  background: #0d6efd;
  color: white;
  border-color: #0d6efd;
}

[data-theme="dark"] .suggestion-chip {
  background: #3d4450;
  border-color: #495057;
  color: #adb5bd;
}

[data-theme="dark"] .suggestion-chip:hover {
  background: #0d6efd;
  color: white;
}

/* Inline Suggestion Links */
.suggestion-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.1);
  margin-top: 8px;
}

.suggestion-link {
  color: #0d6efd;
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 0;
}

.suggestion-link::before {
  content: "→ ";
  opacity: 0.6;
}

.suggestion-link:hover {
  text-decoration: underline;
  color: #0a58ca;
}

[data-theme="dark"] .suggestion-links {
  border-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] .suggestion-link {
  color: #6ea8fe;
}

[data-theme="dark"] .suggestion-link:hover {
  color: #9ec5fe;
}

/* Chat Input Area */
.chat-input-area {
  padding: 12px 16px 16px;
  border-top: 1px solid #e9ecef;
}

[data-theme="dark"] .chat-input-area {
  border-color: #495057;
}

.chat-input-area .input-group {
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-input-area .form-control {
  border: none;
  padding: 12px 16px;
  font-size: 14px;
}

.chat-input-area .form-control:focus {
  box-shadow: none;
}

[data-theme="dark"] .chat-input-area .form-control {
  background: #3d4450;
  color: #e1e1e1;
}

.chat-input-area .btn {
  border-radius: 0;
  padding: 12px 20px;
}

.chat-input-hint {
  text-align: right;
  margin-top: 4px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .global-chat-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .global-chat-toggle {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
}

/* Product Card Hover Effects */
.product-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .product-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ============================================
   MODAL SCROLLING FIXES
   ============================================ */

/* Ensure modal bodies scroll with constrained height */
.modal-dialog-scrollable .modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

/* Table inside scrollable modal should not have its own scroll */
.modal-dialog-scrollable .modal-body .table-responsive {
  overflow: visible;
  max-height: none;
}

/* Clickable cards hover effect */
.card-clickable {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}
