:root {
  --bg: #f7f8fc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, .10);
  --brand: #4f46e5;
  --brand-weak: rgba(79, 70, 229, .12);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 14px 40px rgba(15, 23, 42, .08);
  --radius: 16px;

  /* Legacy style.css aliases */
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --secondary-color: #10b981;
  --secondary-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --bg-color: var(--bg);
  --text-primary: var(--text);
  --text-secondary: var(--muted);
  --border-radius: var(--radius);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
  --font-heading: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg-light: #f8fafc;
  --card-shadow: var(--shadow);
  --text-muted: var(--muted);
  --chat-border: var(--border);
  --chat-radius: var(--radius);
}

/* Fix Tom Select dropdown visibility */
.ts-dropdown {
  z-index: 9999 !important;
}

/* Ensure cards don't clip dropdowns */
.card,
.card-body {
  overflow: visible !important;
}

body {
  background-color: var(--bg-color);
  font-family: var(--font-body);
  color: var(--text-primary);
  min-height: 100vh;
}

.driver-popover,
.driver-popover * {
  font-family: var(--font-body) !important;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: 600;
}

/* Navbar */
.navbar {
  background: rgba(255, 255, 255, 0.8) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  z-index: 1100 !important;
}

.navbar-brand {
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-link {
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary-color) !important;
}

/* Cards */
.card {
  background-color: var(--surface);
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Let TomSelect dropdowns overflow containers */
.card:has(.ts-wrapper),
.card-body:has(.ts-wrapper),
.accordion:has(.ts-wrapper),
.accordion-item:has(.ts-wrapper),
.accordion-body:has(.ts-wrapper),
.accordion-collapse:has(.ts-wrapper) {
  overflow: visible !important;
}

/* Ensure the dropdown itself is always on top */
.ts-dropdown {
  z-index: 10000 !important;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  z-index: 10;
  position: relative;
}

.card-header {
  background-color: transparent;
  border-bottom: 1px solid #f3f4f6;
  font-weight: 600;
  padding: 1.25rem;
}

/* Buttons */
.btn-primary {
  background: var(--primary-gradient);
  border: none;
  border-radius: 8px;
  padding: 0.625rem 1.25rem;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(79, 70, 229, 0.3);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-outline-primary {
  color: var(--primary-color);
  border-color: var(--primary-color);
  border-radius: 8px;
  font-weight: 500;
}

.btn-outline-primary:hover {
  background: var(--primary-gradient);
  border-color: transparent;
  color: white;
}

/* Progress Bars */
.progress {
  border-radius: 6px;
  height: 8px;
  background-color: #f1f5f9;
}

.progress-bar {
  background: var(--primary-gradient);
  border-radius: 6px;
}

.progress-bar.bg-success {
  background: var(--secondary-gradient) !important;
}

.h-24 {
  height: 24px !important;
}

/* Badges */
.badge {
  border-radius: 6px;
  padding: 0.35em 0.8em;
  font-weight: 600;
}

/* Floating Action Button (Chat) */
#chat-widget-container {
  position: fixed !important;
  bottom: 25px !important;
  right: 25px !important;
  left: auto !important;
  z-index: 100000 !important;
}

#chat-toggle-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.2s;
}

#chat-toggle-btn:hover {
  transform: scale(1.05);
}

#chat-window {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 350px;
  height: 500px;
  background: white;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: opacity 0.3s, transform 0.3s;
}

#chat-window.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.chat-header {
  background: var(--primary-gradient);
  color: white;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 15px;
  background: #f8fafc;
}

.chat-footer {
  padding: 10px;
  background: white;
  border-top: 1px solid #eef2f6;
}

/* Chat Bubbles in Widget */
.msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 85%;
  font-size: 0.9rem;
  line-height: 1.4;
  position: relative;
  display: inline-block;
  word-wrap: break-word;
}

.msg-user {
  background-color: #4f46e5 !important;
  background: var(--brand, #4f46e5) !important;
  color: white !important;
  border-bottom-right-radius: 2px !important;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.msg-assistant {
  background: white !important;
  color: #0f172a !important;
  border-bottom-left-radius: 2px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.navbar-nav .nav-link {
  padding: 0.6rem 1.25rem;
  margin: 0 0.125rem;
  border-radius: 8px;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
  background-color: var(--primary-weak, rgba(99, 102, 241, 0.08));
}

.num {
  font-variant-numeric: tabular-nums;
}

.text-muted {
  color: var(--muted) !important;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid rgba(15, 23, 42, .08);
  font-weight: 650;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover {
  filter: brightness(.96);
}

.btn-outline-primary {
  color: var(--brand);
  border-color: rgba(79, 70, 229, .35);
}

.btn-outline-primary:hover {
  background: var(--brand-weak);
  border-color: rgba(79, 70, 229, .45);
  color: var(--brand);
}

.page-kicker {
  font-size: .85rem;
  color: var(--muted);
}

.page-title {
  font-weight: 850;
  letter-spacing: .2px;
  font-size: 2.25rem;
}

.table thead th {
  background: rgba(15, 23, 42, .03);
}

.table> :not(caption)>*>* {
  border-color: rgba(15, 23, 42, .08);
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .5rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, .06);
  color: #334155;
  font-weight: 650;
  font-size: .78rem;
}

.badge-dot {
  width: .45rem;
  height: .45rem;
  border-radius: 999px;
  display: inline-block;
}

.dot-breakfast {
  background: #f59e0b;
}

.dot-lunch {
  background: #2563eb;
}

.dot-dinner {
  background: #111827;
}

.dot-snacks {
  background: #64748b;
}

.accordion-item {
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 14px;
  overflow: hidden;
}

.accordion-button {
  font-weight: 750;
}

.accordion-button:not(.collapsed) {
  background: rgba(79, 70, 229, .08);
  color: var(--text);
}

.accordion-button:focus {
  box-shadow: 0 0 0 .25rem rgba(79, 70, 229, .18);
}

.accordion-item+.accordion-item {
  margin-top: .75rem;
}

/* Planner Shopping List Styles */
.shopping-row {
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.shopping-row.checked-out {
  opacity: 0;
  transform: translateX(40px);
  pointer-events: none;
}

.shopping-check {
  width: 1.15em;
  height: 1.15em;
  cursor: pointer;
  accent-color: var(--bs-success, #198754);
}

.shopping-status-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.shopping-progress {
  height: 6px;
  border-radius: 3px;
  flex: 1;
  min-width: 120px;
  background: var(--bs-gray-200, #e9ecef);
  overflow: hidden;
}

.shopping-progress-fill {
  height: 100%;
  background: var(--bs-success, #198754);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Feedback Form Styles */
.border-dashed {
  border: 2px dashed rgba(79, 70, 229, 0.2);
  transition: all 0.3s ease;
  background: rgba(79, 70, 229, 0.02);
}

.border-dashed:hover {
  border-color: var(--brand);
  background: rgba(79, 70, 229, 0.05);
  cursor: pointer;
}

.border-dashed.dragover {
  border-color: var(--brand);
  background: var(--brand-weak);
  transform: scale(1.02);
}

.text-brand {
  color: var(--brand);
}

.feedback-form textarea {
  border-radius: 12px;
  padding: 1.25rem;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.08);
  transition: all 0.2s ease;
}

.feedback-form textarea:focus {
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.page-header {
  animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

/* Admin Feedbacks Styles */
.avatar-sm {
  font-size: 0.75rem;
}

.extra-small {
  font-size: 0.7rem;
}

.text-wrap {
  word-break: break-word;
}

.table-hover tbody tr:hover {
  background-color: rgba(79, 70, 229, 0.02);
}

/* Table View Styles */
.table-scroll {
  max-height: 70vh;
  overflow: auto;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(15, 23, 42, .03);
}

.sticky-col {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 2;
}

.sticky-col-th {
  z-index: 3;
}
