/* ============================================================
   E-BIKE SHOWROOM - ADMIN THEME
   White / Blue / Light Grey  +  Dark Mode
   ============================================================ */

:root {
  --eb-primary: #2b6cff;
  --eb-primary-dark: #1e56d4;
  --eb-primary-light: #eaf1ff;
  --eb-bg: #f4f6fb;
  --eb-card: #ffffff;
  --eb-border: #e6e9f2;
  --eb-text: #1f2937;
  --eb-text-muted: #6b7280;
  --eb-sidebar-bg: #ffffff;
  --eb-sidebar-text: #4b5563;
  --eb-sidebar-active: #eaf1ff;
  --eb-shadow: 0 4px 18px rgba(43, 108, 255, 0.08);
  --eb-shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.12);
  --eb-radius: 14px;
}

[data-bs-theme="dark"] {
  --eb-bg: #0f1420;
  --eb-card: #161d2e;
  --eb-border: #263046;
  --eb-text: #e5e7eb;
  --eb-text-muted: #94a3b8;
  --eb-sidebar-bg: #121826;
  --eb-sidebar-text: #cbd5e1;
  --eb-sidebar-active: #1e2b4f;
}

* { outline: none; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--eb-bg);
  color: var(--eb-text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: clamp(.85rem, .8rem + .25vw, .92rem);
  line-height: 1.5;
}

img { max-width: 100%; height: auto; }
svg, canvas { max-width: 100%; }
table { max-width: 100%; }

/* ---------- Premium Page Loader ---------- */
.eb-loader {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px;
  background: color-mix(in srgb, var(--eb-bg) 60%, transparent);
  transition: opacity .45s ease, visibility .45s ease;
}
.eb-loader.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.eb-loader.hide * { opacity: 0; visibility: hidden; }

.eb-loader-logo {
  width: 76px; height: 76px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  background: var(--eb-card);
  box-shadow: var(--eb-shadow-lg);
  padding: 12px;
}
.eb-loader-logo img { width: 100%; height: auto; }
.eb-loader-logo i { font-size: 2rem; color: var(--eb-primary); animation: ebPulse 1.4s ease-in-out infinite; }
.eb-loader-logo.ring-frame { content: ""; }

.eb-loader-ring {
  width: 118px; height: 118px; border-radius: 50%;
  position: absolute;
  background: conic-gradient(from 0deg, transparent 20%, var(--eb-primary) 60%, transparent 85%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  animation: ebSpin 1.1s linear infinite;
  filter: drop-shadow(0 0 12px color-mix(in srgb, var(--eb-primary) 60%, transparent));
}
.eb-loader-ring:after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 180deg, transparent 0 65%, color-mix(in srgb, var(--eb-primary) 35%, transparent) 90%, transparent 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
}

.eb-loader-name {
  font-size: 1rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--eb-text);
  background: linear-gradient(90deg, var(--eb-text-muted) 20%, var(--eb-primary) 50%, var(--eb-text-muted) 80%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: ebShimmer 2.2s linear infinite;
}
.eb-loader-dots { display: flex; gap: 6px; }
.eb-loader-dots span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--eb-primary);
  animation: ebBounce 1.2s ease-in-out infinite;
}
.eb-loader-dots span:nth-child(2) { animation-delay: .15s; }
.eb-loader-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes ebSpin { to { transform: rotate(360deg); } }
@keyframes ebShimmer { to { background-position: -200% 0; } }
@keyframes ebPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes ebBounce {
  0%, 100% { transform: translateY(0); opacity: .4; }
  50% { transform: translateY(-7px); opacity: 1; }
}

.eb-loader.eb-hide-brand .eb-loader-logo,
.eb-loader.eb-hide-brand .eb-loader-name { display: none; }

/* ---------- Layout ---------- */
.app-layout { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.app-sidebar {
  width: 262px; flex-shrink: 0;
  background:
    radial-gradient(120% 55% at 100% -8%, color-mix(in srgb, var(--eb-primary) 15%, transparent), transparent 62%),
    var(--eb-sidebar-bg);
  border-right: 1px solid var(--eb-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: hidden;
  transition: width .25s ease, margin-left .25s ease;
  z-index: 1040;
}
.app-sidebar::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--eb-primary), #7aa2ff, var(--eb-primary));
}
.app-main { flex-grow: 1; min-width: 0; height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }

.sidebar-brand {
  position: relative;
  display: flex; align-items: center; gap: .75rem;
  padding: 1.05rem 1.15rem 1rem;
  border-bottom: 1px solid var(--eb-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--eb-primary) 7%, transparent), transparent);
}
.sidebar-brand::after {
  content: ''; position: absolute; left: 1.15rem; right: 1.15rem; bottom: -1px; height: 2px;
  border-radius: 2px; background: linear-gradient(90deg, var(--eb-primary), transparent);
}
.brand-logo {
  width: 44px; height: 44px; border-radius: 13px;
  background: linear-gradient(135deg, var(--eb-primary), #7aa2ff);
  box-shadow: 0 6px 14px rgba(43,108,255,.35), inset 0 1px 0 rgba(255,255,255,.28);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
  overflow: hidden; flex-shrink: 0;
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { line-height: 1.25; overflow: hidden; }
.brand-text strong { display: block; font-size: 1rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.brand-text small { color: var(--eb-text-muted); font-size: .76rem; }

.sidebar-nav { flex-grow: 1; overflow-y: auto; padding: .6rem .75rem 1rem; scrollbar-width: thin; scrollbar-color: var(--eb-border) transparent; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--eb-border); border-radius: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-heading {
  font-size: .9rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--eb-text-muted);
  padding: 1.05rem .55rem .4rem;
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  cursor: pointer; user-select: none; transition: color .18s ease;
}
.sidebar-heading .sidebar-heading-label { display: inline-flex; align-items: center; gap: .5rem; }
.sidebar-heading .sidebar-heading-label i {
  font-size: .85rem; width: 22px; height: 22px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--eb-sidebar-active); color: var(--eb-primary);
  transition: all .18s ease;
}
.sidebar-heading:hover { color: var(--eb-primary); }
.sidebar-heading:hover .sidebar-heading-label i { background: var(--eb-primary); color: #fff; }
.sidebar-heading .bi-chevron-down { font-size: .72rem; opacity: .5; transition: transform .22s ease, opacity .18s ease; }
.sidebar-heading:hover .bi-chevron-down { opacity: 1; }
.sidebar-heading.collapsed .bi-chevron-down { transform: rotate(-90deg); }
.sidebar-group { display: none; }
.sidebar-group.show { display: block; }
.sidebar-link {
  position: relative;
  display: flex; align-items: center; gap: .7rem;
  color: var(--eb-sidebar-text); text-decoration: none;
  padding: .5rem .65rem; border-radius: 12px; margin-bottom: 3px;
  font-weight: 500; font-size: .8rem;
  transition: background .18s ease, color .18s ease, transform .12s ease, box-shadow .18s ease;
}
.sidebar-link i {
  font-size: 1.05rem; width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--eb-text-muted); transition: all .18s ease;
}
.sidebar-link:hover { background: var(--eb-sidebar-active); color: var(--eb-primary); transform: translateX(2px); }
.sidebar-link:hover i { color: var(--eb-primary); }
.sidebar-link:focus-visible { outline: 2px solid var(--eb-primary); outline-offset: 2px; }
.sidebar-link.active {
  background: linear-gradient(135deg, var(--eb-primary), var(--eb-primary-dark));
  color: #fff; box-shadow: 0 6px 16px rgba(43,108,255,.35);
}
.sidebar-link.active i { color: #fff; }
.sidebar-foot {
  padding: .85rem 1.15rem; border-top: 1px solid var(--eb-border);
  background: color-mix(in srgb, var(--eb-primary) 4%, transparent);
}
.sidebar-foot span { font-size: .74rem; letter-spacing: .02em; color: var(--eb-text-muted); }

/* Collapsed (icon-only) sidebar on desktop */
@media (min-width: 992px) {
  .app-sidebar.collapsed { width: 76px; }
  .app-sidebar.collapsed .sidebar-brand { justify-content: center; padding: 1rem .5rem; }
  .app-sidebar.collapsed .brand-text,
  .app-sidebar.collapsed .sidebar-link span,
  .app-sidebar.collapsed .sidebar-foot span { display: none; }
  .app-sidebar.collapsed .sidebar-heading {
    margin: .7rem .5rem .4rem; padding: 0; text-align: center; font-size: 0;
    display: flex; align-items: center; justify-content: center;
  }
  .app-sidebar.collapsed .sidebar-heading .sidebar-heading-label { display: none; }
  .app-sidebar.collapsed .sidebar-heading::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: var(--eb-border);
  }
  .app-sidebar.collapsed .sidebar-heading.heading-active::before { background: var(--eb-primary); }
  .app-sidebar.collapsed .sidebar-heading .bi-chevron-down { display: none; }
  .app-sidebar.collapsed .sidebar-group { display: block !important; }
  .app-sidebar.collapsed .sidebar-link { justify-content: center; gap: 0; padding: .5rem; width: 44px; margin: 0 auto 4px; position: relative; }
  .app-sidebar.collapsed .sidebar-link:hover { transform: none; }
  .app-sidebar.collapsed .sidebar-link i { width: 28px; height: 28px; font-size: 1.2rem; margin: 0; }
  .app-sidebar.collapsed .sidebar-link.active::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 24px; background: #fff; border-radius: 0 3px 3px 0;
  }
  .app-sidebar.collapsed .sidebar-nav { padding: .6rem .5rem; }
  .app-sidebar.collapsed .sidebar-foot { padding: .75rem .5rem; text-align: center; }
  .app-sidebar.collapsed .sidebar-foot span { font-size: .58rem; }
}

/* ---------- Topbar ---------- */
.app-topbar {
  position: sticky; top: 0; z-index: 1030;
  background: color-mix(in srgb, var(--eb-card) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--eb-border);
  padding: .55rem 1.25rem;
}
.topbar-inner { min-width: 0; }
.topbar-inner > .dropdown, .topbar-inner > .btn, .topbar-inner > a.btn { flex-shrink: 0; }
.btn-icon {
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--eb-border); background: var(--eb-card); color: var(--eb-text);
  border-radius: 10px; flex-shrink: 0;
}
.btn-icon:hover { color: var(--eb-primary); border-color: var(--eb-primary); }
.breadcrumb-bar { font-size: .85rem; }

.btn-profile {
  border: 1px solid var(--eb-border); background: var(--eb-card); border-radius: 12px; padding: .3rem .6rem;
  flex-shrink: 0;
}
.avatar-sm {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--eb-primary), #5b8cff);
  color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}

/* Mobile search toggle (hidden on desktop) */
.search-toggle-mobile { display: none; }

/* ---------- Global Search ---------- */
.global-search { position: relative; width: 320px; max-width: 100%; }
.global-search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--eb-text-muted); }
.global-search .form-control { padding-left: 34px; border-radius: 20px; background: var(--eb-bg); border: 1px solid var(--eb-border); }
.search-results {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--eb-card); border: 1px solid var(--eb-border); border-radius: 12px;
  max-height: 420px; overflow-y: auto; z-index: 1050;
}
.search-results.show { display: block; }
.search-group { padding: .5rem .9rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--eb-text-muted); }
.search-item { display: flex; gap: .6rem; align-items: center; padding: .55rem .9rem; text-decoration: none; color: var(--eb-text); min-width: 0; }
.search-item:hover { background: var(--eb-bg); }
.search-item .icon-box { width: 34px; height: 34px; border-radius: 9px; background: var(--eb-primary-light); color: var(--eb-primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.search-item > span:last-child { min-width: 0; }
.search-item span span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item small { display: block; color: var(--eb-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Notifications ---------- */
.notif-badge {
  position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; padding: 0 4px;
  background: #ef4444; color: #fff; font-size: .62rem; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
}
.notif-panel { width: 340px; max-width: calc(100vw - 24px); padding: 0; }
.notif-head { padding: .7rem 1rem; font-weight: 600; border-bottom: 1px solid var(--eb-border); }
.notif-body { max-height: min(340px, 60vh); overflow-y: auto; }
.notif-item { padding: .6rem 1rem; border-bottom: 1px solid var(--eb-border); font-size: .85rem; }
.notif-item div { min-width: 0; }
.notif-foot { padding: .5rem 1rem; border-top: 1px solid var(--eb-border); text-align: center; }

/* ---------- Content ---------- */
.app-content {
  padding: clamp(.9rem, 1.5vw, 1.25rem);
  flex-grow: 1; min-width: 0; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.app-content .container-fluid { padding-left: 0; padding-right: 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--eb-card); border: 1px solid var(--eb-border);
  border-radius: var(--eb-radius); box-shadow: var(--eb-shadow);
}
.card-header { background: transparent; border-bottom: 1px solid var(--eb-border); padding: .9rem 1.15rem; font-weight: 600; }
.card-body { padding: 1.15rem; }

/* ---------- Stat cards ---------- */
.stat-card {
  border-radius: var(--eb-radius); padding: 1.1rem 1.15rem;
  background: var(--eb-card); border: 1px solid var(--eb-border);
  box-shadow: var(--eb-shadow); position: relative; overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
  height: 100%;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--eb-shadow-lg); }
.stat-card .stat-icon {
  width: 46px; height: 46px; border-radius: 12px; font-size: 1.35rem;
  display: flex; align-items: center; justify-content: center; margin-bottom: .7rem;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { color: var(--eb-text-muted); font-size: .8rem; }
.stat-card .stat-trend { font-size: .75rem; }
.bg-soft-primary { background: var(--eb-primary-light); color: var(--eb-primary); }
.bg-soft-green { background: #e3f7ec; color: #16a34a; }
.bg-soft-red { background: #fdeaea; color: #dc2626; }
.bg-soft-amber { background: #fef3e2; color: #d97706; }
.bg-soft-purple { background: #f0e9fd; color: #7c3aed; }
.bg-soft-cyan { background: #e0f6fb; color: #0891b2; }
.bg-soft-slate { background: #eef1f6; color: #475569; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--eb-text-muted); border-bottom: 1px solid var(--eb-border); font-weight: 600;
}
.table td, .table th { vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--eb-bg); }
.table-actions .btn { padding: .2rem .4rem; font-size: .95rem; }

/* ---------- Forms ---------- */
.form-label { font-size: .8rem; font-weight: 600; color: var(--eb-text); margin-bottom: .3rem; }
.form-control, .form-select {
  background: var(--eb-card); border: 1px solid var(--eb-border); color: var(--eb-text);
  border-radius: 10px; font-size: .9rem; padding: .5rem .75rem;
}
.form-control:focus, .form-select:focus { border-color: var(--eb-primary); box-shadow: 0 0 0 .2rem rgba(43,108,255,.12); }
.form-control::placeholder { color: var(--eb-text-muted); }

/* ---------- Buttons ---------- */
.btn { border-radius: 10px; font-size: .88rem; }
.btn-primary { background: var(--eb-primary); border-color: var(--eb-primary); }
.btn-primary:hover { background: var(--eb-primary-dark); border-color: var(--eb-primary-dark); }
.btn-light { background: var(--eb-bg); border-color: var(--eb-border); color: var(--eb-text); }
.btn-outline-primary { color: var(--eb-primary); border-color: var(--eb-primary); }
.btn-soft { background: var(--eb-primary-light); color: var(--eb-primary); border: 0; }
.btn-soft:hover { background: var(--eb-primary); color: #fff; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; }
.text-available { color: #16a34a; }
.text-sold { color: #64748b; }
.text-reserved { color: #d97706; }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head h4 { font-weight: 700; margin: 0; }
.page-head > :nth-child(2) { margin-left: auto; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eaf1ff 0%, #f4f6fb 50%, #e6edff 100%);
  padding: 1rem;
}
.login-card { width: 100%; max-width: 420px; }
.login-logo {
  width: 62px; height: 62px; border-radius: 18px; font-size: 2rem;
  background: linear-gradient(135deg, var(--eb-primary), #5b8cff);
  color: #fff; display: flex; align-items: center; justify-content: center; margin: 0 auto;
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff !important; }
  .app-layout, .app-main { height: auto !important; overflow: visible !important; }
  .app-content { padding: 0 !important; height: auto !important; overflow: visible !important; }
  .app-sidebar, .app-topbar, .no-print, .app-content .alert { display: none !important; }
  .card { border: none !important; box-shadow: none !important; }
  .print-area { width: 100%; }
}

/* ---------- Animations ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stat-card, .card { animation: fadeUp .35s ease both; }
.stat-card:nth-child(2) { animation-delay: .05s; }
.stat-card:nth-child(3) { animation-delay: .1s; }
.stat-card:nth-child(4) { animation-delay: .15s; }

/* ---------- Misc ---------- */
.avatar-lg { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; }
.chart-box { position: relative; height: 280px; }
.chart-box-sm { position: relative; height: 220px; }
.text-primary { color: var(--eb-primary) !important; }
.cursor-pointer { cursor: pointer; }
.min-w-150 { min-width: 150px; }
.stock-cell.low { color: #dc2626; font-weight: 700; }

.pagination { margin-bottom: 0; }

/* Invoice preview modal */
.invoice-preview { background: #fff; color: #111; padding: 0; font-size: .85rem; }
.invoice-preview .table { color: #111; }
.invoice-preview .table th { color: #111; border-color: #ddd; }

/* print area (only hide everything when a print area actually exists) */
@media print {
  body:has(#printArea) * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea { position: absolute; left: 0; top: 0; width: 100%; }
}

/* ============================================================
   RESPONSIVE SYSTEM (mobile-first + enhancement breakpoints)
   ============================================================ */

/* ---------- Charts ---------- */
.chart-box { height: clamp(220px, 26vh, 300px); }
.chart-box-sm { height: clamp(180px, 22vh, 240px); }

/* ---------- Dropdowns stay in viewport ---------- */
.dropdown-menu {
  max-width: calc(100vw - 20px);
}
.dropdown-menu.dropdown-menu-end {
  right: 0; left: auto;
}
@media (max-width: 575.98px) {
  .dropdown-menu.dropdown-menu-end:not(.notif-panel) {
    right: 0; left: auto;
    transform: none;
  }
  /* Notification panel pins to viewport so it can never overflow */
  .dropdown-menu.notif-panel {
    position: fixed;
    left: 10px; right: 10px;
    top: 62px;
    width: auto;
    max-width: none;
    transform: none;
  }
}

/* ---------- Modals never overflow the viewport ---------- */
@media (max-width: 767.98px) {
  .modal-dialog { margin: .5rem auto; max-width: calc(100% - 1rem); }
  .modal-dialog.modal-fullscreen { max-width: 100%; margin: 0; }
  .modal-dialog-centered { margin: .5rem auto; }
}
@media (max-width: 991.98px) {
  .modal-xl, .modal-lg { max-width: calc(100vw - 1rem); }
}
.modal-header { gap: .5rem; }
.modal-title { word-break: break-word; }
.modal-dialog:not(.modal-dialog-scrollable) .modal-body { max-height: 70vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-footer { flex-wrap: wrap; }
.modal-footer .btn { margin-bottom: .25rem; }
.modal-content { min-width: 0; }

/* ---------- Forms & buttons ---------- */
.btn { white-space: normal; }
.form-control, .form-select { max-width: 100%; }

/* ---------- Premium date range filter ---------- */
.date-filter {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .4rem .55rem;
  background: var(--eb-card);
  border: 1px solid var(--eb-border);
  border-radius: .75rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  max-width: 100%;
}
.date-filter::before {
  content: "\f1e4";
  font-family: "bootstrap-icons";
  color: var(--eb-primary);
  font-size: 1.1rem;
  line-height: 1;
}
.date-filter .form-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--eb-text-muted);
  margin-bottom: 0;
}
.date-filter .df-range,
.date-filter .df-from,
.date-filter .df-to {
  height: auto;
  padding: .34rem .55rem;
  font-size: .85rem;
  color: var(--eb-text);
  background-color: var(--eb-bg);
  border: 1px solid var(--eb-border);
  border-radius: .45rem;
  min-width: 0;
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.date-filter .df-range { min-width: 9rem; }
.date-filter .df-from, .date-filter .df-to { width: 8.5rem; }
.date-filter .df-range:hover,
.date-filter .df-from:hover,
.date-filter .df-to:hover { border-color: #c6d2ea; }
.date-filter .df-range:focus,
.date-filter .df-from:focus,
.date-filter .df-to:focus {
  border-color: var(--eb-primary);
  box-shadow: 0 0 0 .18rem var(--eb-primary-light);
  outline: none;
}
.date-filter .text-secondary { font-size: .8rem; color: var(--eb-text-muted); }
@media (max-width: 575.98px) {
  .date-filter { width: 100%; }
  .date-filter .df-range { width: 100%; min-width: 0; }
  .date-filter .df-from, .date-filter .df-to { flex: 1 1 0; width: auto; min-width: 0; }
}

/* ---------- Table action buttons / export toolbar ---------- */
.export-toolbar { text-align: right; }
.table-actions { white-space: nowrap; }
.table-responsive { -webkit-overflow-scrolling: touch; }
.table-responsive table { min-width: 0; }
.table td, .table th { overflow-wrap: break-word; }

/* ---------- Filter/search inputs with inline min-width become fluid on mobile ---------- */
@media (max-width: 767.98px) {
  input.form-control[style*="min-width"] {
    min-width: 0 !important;
    width: 100%;
    max-width: 100%;
  }
  .row > .col-auto:has(input.form-control[style*="min-width"]),
  .row.g-2 > .col-auto:has(input.form-control[style*="min-width"]) {
    flex: 1 1 100%;
    max-width: 100%;
  }
}

/* ---------- Card headers wrap on small screens ---------- */
.card-header.d-flex, .modal-header, .page-head { flex-wrap: wrap; }

/* ============================================================
   TABLET (768px - 1024px)
   ============================================================ */
@media (max-width: 991.98px) {
  body.sidebar-open { overflow: hidden; }
  .app-sidebar { position: fixed; left: 0; top: 0; margin-left: -262px; box-shadow: var(--eb-shadow-lg); }
  .app-sidebar.open { margin-left: 0; }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }
  .sidebar-backdrop.show { display: block; }
  .global-search { width: 190px; }
  .app-topbar { padding: .55rem .9rem; }
}

/* ============================================================
   MOBILE (up to 767px)
   ============================================================ */
@media (max-width: 767.98px) {
  /* Touch-friendly controls */
  .btn-icon { width: 42px; height: 42px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 34px; }
  .form-control, .form-select { min-height: 42px; }
  .form-control-sm, .form-select-sm { min-height: 32px; }
  .input-group .form-control { min-height: 42px; }
  .pagination .page-link { min-width: 38px; text-align: center; }

  .stat-value { font-size: clamp(1.25rem, 1.1rem + 1vw, 1.45rem); }
  .page-head h4 { font-size: clamp(1.1rem, 1rem + 1.2vw, 1.3rem); }
  .global-search { width: 100%; }
}

/* ============================================================
   SMALL MOBILE (up to 575px)
   ============================================================ */
@media (max-width: 575.98px) {
  .app-content { padding: .8rem; }
  .app-topbar { padding: .5rem .7rem; }
  .topbar-inner { gap: .35rem !important; }
  .theme-toggle-btn { display: none; }

  /* Mobile search: hidden by default, expands below topbar when toggled */
  .search-toggle-mobile { display: inline-flex; }
  .global-search {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    width: 100%;
    padding: .65rem .75rem;
    background: var(--eb-card);
    border-bottom: 1px solid var(--eb-border);
    box-shadow: 0 10px 20px rgba(0,0,0,.10);
    z-index: 1032;
  }
  .app-topbar.search-open .global-search { display: block; }
  .app-topbar.search-open .search-toggle-mobile i { transform: rotate(90deg); }
  .search-results { top: calc(100% + 4px); }

  .notif-head, .notif-item, .notif-foot { padding-left: .75rem; padding-right: .75rem; }

  .card-header { padding: .75rem .9rem; }
  .card-body { padding: .95rem; }
  .stat-card { padding: .95rem 1rem; }

  .page-head { flex-direction: column; align-items: stretch; }
  .page-head > .btn { width: 100%; }
  .page-head > div { width: 100%; }
}

/* ============================================================
   DESKTOP (1025px and up)
   ============================================================ */
@media (min-width: 1025px) {
  .app-content { padding: 1.35rem; }
}

/* Keep `d-*-block`/`d-*-none` working with sticky topbar */
@media (min-width: 576px) and (max-width: 767.98px) {
  .global-search { display: block; width: 190px; position: relative; left: auto; right: auto; padding: 0; background: transparent; border: 0; box-shadow: none; }
  .search-toggle-mobile { display: none !important; }
  .global-search .search-results { top: calc(100% + 8px); }
}

/* Call log timeline */
.call-timeline { position: relative; padding-left: 22px; }
.call-timeline::before { content: ''; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--eb-border, #dee2e6); }
.call-item { position: relative; padding-bottom: 14px; }
.call-item:last-child { padding-bottom: 0; }
.call-item::before { content: ''; position: absolute; left: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #6c757d; }
.call-item.incoming::before { border-color: #0d6efd; }
.call-item.outgoing::before { border-color: #198754; }
.call-item.visit::before { border-color: #6f42c1; }
.call-item.whatsapp::before { border-color: #0dcaf0; }
.call-item.note::before { border-color: #adb5bd; }
.call-item .call-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.call-item .call-meta { font-size: .78rem; color: #6c757d; }

/* Hide modal header close (X) buttons */
.modal-header .btn-close { display: none; }

/* ============================================================
   SEARCHABLE SELECT
   (dropdown list is appended to <body> as .searchable-dropdown
   with position:fixed, so overflow:hidden/auto ancestors -
   filter cards, section cards, modals, app-content - can never
   clip it. It is positioned + flipped in JS to stay in viewport.)
   ============================================================ */
.searchable-select { min-width: 0; max-width: 100%; }
.searchable-select .form-control {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236c757d'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 1em;
  padding-right: 2.25rem;
  cursor: pointer;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.searchable-dropdown {
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--eb-card);
  border: 1px solid var(--eb-border);
  border-radius: 12px;
}
.searchable-dropdown .list-group-item {
  cursor: pointer;
  min-width: 0;
  border-left: 0;
  border-right: 0;
}
.searchable-dropdown .list-group-item:first-child { border-top: 0; border-top-left-radius: 12px; border-top-right-radius: 12px; }
.searchable-dropdown .list-group-item:last-child { border-bottom: 0; border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }
.searchable-dropdown .list-group-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.searchable-dropdown .list-group-item:hover,
.searchable-dropdown .list-group-item.active {
  background-color: var(--bs-primary-bg-subtle, #e7f1ff);
  color: var(--bs-emphasis-color);
}
/* legacy inline list (kept for compatibility) */
.searchable-select .list-group {
  max-height: 240px;
  overflow: auto;
  z-index: 1055;
  margin-top: 2px;
}
.searchable-select .list-group-item {
  cursor: pointer;
  min-width: 0;
}
.searchable-select .list-group-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.searchable-select .list-group-item:hover,
.searchable-select .list-group-item.active {
  background-color: var(--bs-primary-bg-subtle, #e7f1ff);
  color: var(--bs-emphasis-color);
}
/* Filter-bar selects must never push the layout wider than their column */
.filter-card { overflow: visible; }
.filter-card .searchable-select,
.filter-card select.form-select { max-width: 100%; }
.filter-card .row > div { min-width: 0; }
.searchable-enhanced { display: none !important; }

/* ---------- Job Card board (Kanban) ---------- */
.jc-board { scrollbar-width: thin; scrollbar-color: var(--eb-border) transparent; }
.jc-board::-webkit-scrollbar { height: 8px; }
.jc-board::-webkit-scrollbar-thumb { background: var(--eb-border); border-radius: 8px; }
.jc-col { border-radius: var(--eb-radius); }
.jc-col-body { max-height: 62vh; overflow-y: auto; scrollbar-width: thin; }
.jc-card { cursor: grab; }
.jc-card:active { cursor: grabbing; }
.jc-card.opacity-50 { opacity: .45; }
.jc-col-body.jc-dragover { background: var(--eb-primary-light); }
.jc-overdue td:first-child { box-shadow: inset 3px 0 0 #dc3545; }

/* ---------- Job Card list: status colours ---------- */
#jcHistTable tbody tr td:first-child { box-shadow: inset 3px 0 0 transparent; }
#jcHistTable tbody tr.st-open td:first-child { box-shadow: inset 3px 0 0 #2b6cff; }
#jcHistTable tbody tr.st-in_progress td:first-child { box-shadow: inset 3px 0 0 #f59f00; }
#jcHistTable tbody tr.st-ready td:first-child { box-shadow: inset 3px 0 0 #0dcaf0; }
#jcHistTable tbody tr.st-delivered td:first-child { box-shadow: inset 3px 0 0 #198754; }
#jcHistTable tbody tr.st-cancelled td:first-child { box-shadow: inset 3px 0 0 #6c757d; }

.st-text-open { color: #2b6cff; }
.st-text-in_progress { color: #b3540b; }
.st-text-ready { color: #0d8db0; }
.st-text-delivered { color: #198754; }
.st-text-cancelled { color: #6c757d; }

select.st-sel-open { color: #2b6cff; border-color: #b9d0ff; }
select.st-sel-in_progress { color: #b3540b; border-color: #fcd49a; }
select.st-sel-ready { color: #0d8db0; border-color: #a4e3f5; }
select.st-sel-delivered { color: #198754; border-color: #a5d6b8; }
select.st-sel-cancelled { color: #6c757d; border-color: #ced4da; }

/* ============================================================
   MODERN PAGE HERO & KPI SYSTEM (shared - like receipts)
   ============================================================ */
.modern-hero{
  background: linear-gradient(135deg, #2b6cff 0%, #5b8cff 55%, #7aa2ff 100%);
  border:0; border-radius:22px; color:#fff; position:relative; overflow:hidden;
  box-shadow: 0 12px 32px rgba(43,108,255,.25);
}
.modern-hero::before{
  content:''; position:absolute; inset:0;
  background:
    radial-gradient(320px 220px at 85% -10%, rgba(255,255,255,.22), transparent 60%),
    radial-gradient(420px 320px at -5% 110%, rgba(255,255,255,.14), transparent 65%);
  pointer-events:none;
}
.modern-hero .hero-icon{
  width:56px; height:56px; border-radius:16px; display:flex; align-items:center; justify-content:center;
  background:rgba(255,255,255,.18); backdrop-filter: blur(8px); border:1px solid rgba(255,255,255,.2);
  font-size:1.6rem; flex-shrink:0;
}
.modern-hero h4{ color:#fff; font-weight:800; letter-spacing:.01em; }
.modern-hero .text-white-75{ color:rgba(255,255,255,.86); }
.modern-hero .btn-light{ border:0; font-weight:600; border-radius:12px; padding:.6rem 1.1rem; box-shadow:0 6px 16px rgba(0,0,0,.12);}
.modern-hero .btn-light:hover{ transform:translateY(-1px); box-shadow:0 10px 22px rgba(0,0,0,.18); }
.kpi-card{
  border:1px solid var(--eb-border); border-radius:12px; background:var(--eb-card); box-shadow:var(--eb-shadow);
  padding:.5rem .6rem; position:relative; overflow:hidden; transition: transform .15s ease, box-shadow .15s ease;
}
.kpi-card:hover{ transform:translateY(-1px); box-shadow:var(--eb-shadow-lg); }
.kpi-card .kpi-icon{
  width:24px; height:24px; border-radius:7px; display:flex; align-items:center; justify-content:center; font-size:.78rem; margin-bottom:.3rem;
}
.kpi-card .kpi-value{ font-size:.88rem; font-weight:800; line-height:1.05; letter-spacing:-.02em;}
.kpi-card .kpi-label{ font-size:.58rem; color:var(--eb-text-muted); font-weight:700; text-transform:uppercase; letter-spacing:.05em; }
.kpi-card .kpi-sub{ font-size:.6rem; color:var(--eb-text-muted); line-height:1.2; }
.kpi-card::after{
  content:''; position:absolute; right:-10px; top:-10px; width:42px; height:42px; border-radius:50%;
  background:var(--eb-primary-light); opacity:.28; pointer-events:none;
}
.kpi-card.cyan::after{ background:#e0f6fb; } .kpi-card.amber::after{ background:#fef3e2; } .kpi-card.red::after{ background:#fdeaea; } .kpi-card.green::after{ background:#e3f7ec; }
.kpi-card.purple::after{ background:#f0e9fd; }
.section-card{ border-radius:18px; overflow:hidden; }
.section-card .card-header{
  background:linear-gradient(180deg, color-mix(in srgb, var(--eb-card) 92%, var(--eb-bg)), var(--eb-card));
  border-bottom:1px solid var(--eb-border); font-weight:700; font-size:.92rem;
}
.section-card .card-header .hdr-icon{
  width:28px; height:28px; border-radius:8px; display:inline-flex; align-items:center; justify-content:center;
  background:var(--eb-primary-light); color:var(--eb-primary); margin-right:.45rem; font-size:.95rem;
}
.avatar-initial{
  width:32px; height:32px; border-radius:9px; display:inline-flex; align-items:center; justify-content:center;
  background:linear-gradient(135deg, var(--eb-primary), #7aa2ff); color:#fff; font-weight:700; font-size:.78rem; flex-shrink:0;
}
.badge-dot{ width:7px; height:7px; border-radius:50%; display:inline-block; margin-right:4px; vertical-align:middle;}
.mode-badge{ border:1px solid var(--eb-border); background:var(--eb-bg); color:var(--eb-text); font-weight:600; border-radius:20px; padding:.28rem .55rem; font-size:.72rem; text-transform:capitalize; }
.status-pill{ border-radius:20px; padding:.28rem .6rem; font-size:.7rem; font-weight:700; letter-spacing:.04em; text-transform:uppercase; }
.status-linked{ background:#e3f7ec; color:#15803d; border:1px solid #bbf7d0; }
.status-partial{ background:#fef3e2; color:#b45309; border:1px solid #fde68a; }
.status-advance{ background:#eef1f6; color:#475569; border:1px solid #e2e8f0; }
[data-bs-theme="dark"] .status-linked{ background:#143026; color:#86efac; border-color:#1f4d2f;}
[data-bs-theme="dark"] .status-partial{ background:#2a2210; color:#fcd34d; border-color:#5a4310;}
[data-bs-theme="dark"] .status-advance{ background:#1e293b; color:#cbd5e1; border-color:#334155;}
.table-modern thead th{ background:var(--eb-bg); position:sticky; top:0; z-index:1; }
.table-modern tbody tr{ transition: background .12s ease; }
.table-modern tbody tr:hover{ background:color-mix(in srgb, var(--eb-primary) 4%, transparent); }
.empty-state{ padding:2.2rem 1rem; text-align:center; color:var(--eb-text-muted); }
.empty-state .empty-icon{ width:56px; height:56px; border-radius:16px; background:var(--eb-primary-light); color:var(--eb-primary); display:inline-flex; align-items:center; justify-content:center; font-size:1.6rem; margin-bottom:.7rem; }
.modal-modern .modal-content{ border-radius:18px; border:0; box-shadow:var(--eb-shadow-lg); overflow:hidden; }
.modal-modern .modal-header{ background:linear-gradient(180deg, var(--eb-primary) 0%, var(--eb-primary-dark) 100%); color:#fff; border:0; padding:1rem 1.2rem; }
.modal-modern .modal-header .modal-title{ font-weight:700; color:#fff; }
.modal-modern .modal-header .btn-close{ filter:invert(1) brightness(2); opacity:.85; }
.modal-modern .modal-header .btn-close:hover{ opacity:1; }
@media (max-width: 767.98px){
  .modern-hero{ border-radius:16px; }
  .kpi-card .kpi-value{ font-size:.82rem; }
  .kpi-card{ padding:.45rem .55rem; }
  .kpi-card .kpi-icon{ width:22px; height:22px; font-size:.72rem; }
}
