/* ═══════════════ OLIVE CRM — UI ENHANCEMENTS / ANIMATIONS ═══════════════ */

/* ─── Defaults ─── */
html { scroll-behavior: smooth; }
* { transition: background-color .2s ease, border-color .2s ease, color .15s ease; }
button, a, .sb-link, .stat-card, .card, .modal-box, input, select, textarea, .btn {
  transition: transform .25s cubic-bezier(.2,.7,.2,1),
              box-shadow .25s ease,
              background .25s ease,
              border-color .25s ease,
              color .15s ease;
}

/* ═══════════════ LOGIN — AURORA ANIMATED BACKGROUND ═══════════════ */
#login-screen {
  position: relative;
  overflow: hidden;
  background: #050f02 !important;
}
#login-screen::before,
#login-screen::after {
  content: "";
  position: absolute;
  inset: -20%;
  pointer-events: none;
  will-change: transform;
  z-index: 0;
}
#login-screen::before {
  background:
    radial-gradient(ellipse 50% 50% at 30% 30%, rgba(34,197,94,.8), transparent 60%),
    radial-gradient(ellipse 40% 50% at 75% 65%, rgba(200,151,42,.6), transparent 60%),
    radial-gradient(ellipse 55% 55% at 50% 90%, rgba(74,222,128,.7), transparent 60%);
  filter: blur(70px);
  animation: aurora-move 16s ease-in-out infinite;
}
#login-screen::after {
  background:
    radial-gradient(ellipse 45% 45% at 80% 20%, rgba(16,185,129,.65), transparent 60%),
    radial-gradient(ellipse 50% 50% at 20% 80%, rgba(132,204,22,.55), transparent 60%);
  filter: blur(80px);
  animation: aurora-move 22s ease-in-out infinite reverse;
  opacity: .9;
}
@keyframes aurora-move {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  25%      { transform: translate3d(3%, -4%, 0) rotate(8deg) scale(1.05); }
  50%      { transform: translate3d(-2%, 3%, 0) rotate(-5deg) scale(.95); }
  75%      { transform: translate3d(-4%, -2%, 0) rotate(6deg) scale(1.03); }
}

/* Glass login card */
.login-card {
  position: relative;
  z-index: 1;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  background: rgba(255,255,255,.88) !important;
  border: 1px solid rgba(255,255,255,.5);
  box-shadow:
    0 30px 80px rgba(0,0,0,.4),
    0 0 0 1px rgba(255,255,255,.1) inset,
    0 0 60px rgba(34,197,94,.15);
  animation: card-rise .7s cubic-bezier(.2,.9,.2,1) both;
}
@keyframes card-rise {
  from { opacity: 0; transform: translateY(30px) scale(.95); filter: blur(10px); }
  to   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

/* ═══════════════ MAIN APP — SUBTLE GRID BACKGROUND ═══════════════ */
#main {
  background:
    linear-gradient(rgba(245,246,250,.92), rgba(245,246,250,.92)),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(34,197,94,.06) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(34,197,94,.06) 39px 40px),
    #f5f6fa;
}

/* ═══════════════ STAT CARDS — HOVER LIFT + GLOW + GRADIENT TEXT ═══════════════ */
.stat-card {
  position: relative;
  overflow: hidden;
  cursor: default;
  border: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #ffffff, #fafdfa);
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(34,197,94,.10) 100%);
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
}
.stat-card::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(34,197,94,.12), transparent);
  transform: rotate(45deg) translateX(-100%);
  transition: transform .9s ease;
  pointer-events: none;
}
.stat-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow:
    0 20px 40px rgba(15,42,6,.18),
    0 0 0 1px rgba(34,197,94,.3),
    0 0 30px rgba(34,197,94,.15);
  border-color: rgba(34,197,94,.4);
}
.stat-card:hover::before { opacity: 1; }
.stat-card:hover::after { transform: rotate(45deg) translateX(100%); }
.stat-icon {
  transition: transform .4s cubic-bezier(.34,1.56,.64,1);
}
.stat-card:hover .stat-icon { transform: scale(1.15) rotate(-8deg); }

.stat-value {
  background: linear-gradient(135deg, #1e4d0f 0%, #22c55e 50%, #84cc16 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 2px 4px rgba(34,197,94,.2));
}

/* ═══════════════ CARDS — UNIVERSAL HOVER ═══════════════ */
.card {
  border: 1px solid #e5e7eb;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15,42,6,.10);
  border-color: rgba(34,197,94,.25);
}

/* ═══════════════ BUTTONS — RIPPLE + DRAMATIC HOVER ═══════════════ */
.btn { position: relative; overflow: hidden; }
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,.5) 0%, transparent 65%);
  opacity: 0;
  transform: scale(.3);
  transition: opacity .6s ease, transform .6s ease;
  pointer-events: none;
}
.btn:active::after { opacity: 1; transform: scale(2.5); transition: 0s; }
.btn-primary {
  box-shadow: 0 6px 16px rgba(30,77,15,.3);
  background: linear-gradient(135deg, #1e4d0f, #2d6b18) !important;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(30,77,15,.45), 0 0 20px rgba(34,197,94,.25);
}
.btn-primary:active { transform: translateY(0); }

.btn-lg {
  position: relative;
}
.btn-lg::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, #22c55e, #84cc16, #22c55e);
  border-radius: inherit;
  opacity: 0;
  z-index: -1;
  filter: blur(8px);
  transition: opacity .3s ease;
}
.btn-lg:hover::before { opacity: .6; }

/* ═══════════════ SIDEBAR LINKS — ANIMATED ═══════════════ */
.sb-link {
  position: relative;
  overflow: hidden;
}
.sb-link::before {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 4px;
  height: 0;
  background: linear-gradient(180deg, #22c55e, #84cc16);
  border-radius: 4px;
  transform: translateY(-50%);
  transition: height .3s cubic-bezier(.2,.9,.2,1);
  box-shadow: 0 0 12px rgba(34,197,94,.5);
}
.sb-link.active::before { height: 70%; }
.sb-link:hover {
  transform: translateX(-3px);
  background: rgba(255,255,255,.08) !important;
}
.sb-link.active {
  background: linear-gradient(90deg, rgba(34,197,94,.25), rgba(34,197,94,.05)) !important;
  border: 1px solid rgba(34,197,94,.35) !important;
  box-shadow:
    0 4px 16px rgba(0,0,0,.2),
    0 0 0 1px rgba(34,197,94,.2);
}
.sb-link-icon {
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.sb-link:hover .sb-link-icon { transform: scale(1.15); }

/* ═══════════════ PAGE TRANSITIONS ═══════════════ */
.page {
  animation: page-in .45s cubic-bezier(.2,.9,.2,1) both;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(15px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stagger animation for grids */
.stats-grid > * { animation: stat-pop .5s cubic-bezier(.34,1.56,.64,1) both; }
.stats-grid > *:nth-child(1) { animation-delay: .05s; }
.stats-grid > *:nth-child(2) { animation-delay: .12s; }
.stats-grid > *:nth-child(3) { animation-delay: .19s; }
.stats-grid > *:nth-child(4) { animation-delay: .26s; }
.stats-grid > *:nth-child(5) { animation-delay: .33s; }
@keyframes stat-pop {
  from { opacity: 0; transform: translateY(20px) scale(.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════ MODAL ═══════════════ */
.modal-overlay {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: rgba(0,0,0,.4) !important;
  animation: backdrop-fade .3s ease both;
}
@keyframes backdrop-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  animation: modal-pop .4s cubic-bezier(.2,1.5,.2,1) both;
  box-shadow: 0 30px 60px rgba(0,0,0,.3), 0 0 60px rgba(34,197,94,.1);
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(20px) scale(.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════ INPUTS — FOCUS GLOW ═══════════════ */
input, select, textarea {
  transition: all .25s ease;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: #22c55e !important;
  box-shadow: 0 0 0 4px rgba(34,197,94,.18), 0 0 20px rgba(34,197,94,.15);
  transform: translateY(-1px);
}

/* ═══════════════ TOPBAR — GLASS ═══════════════ */
#topbar {
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  background: rgba(255,255,255,.75) !important;
  border-bottom: 1px solid rgba(34,197,94,.15);
  box-shadow: 0 4px 12px rgba(0,0,0,.04);
}

/* ═══════════════ TABLES ═══════════════ */
table tbody tr {
  transition: background .2s ease, transform .2s ease;
}
table tbody tr:hover {
  background: linear-gradient(90deg, rgba(34,197,94,.08), rgba(34,197,94,.02)) !important;
  transform: translateX(-2px);
}

/* ═══════════════ BADGES ═══════════════ */
.badge, .sb-badge {
  position: relative;
}
.sb-badge {
  background: linear-gradient(135deg, #ef4444, #f97316) !important;
  box-shadow: 0 0 0 2px rgba(255,255,255,.15), 0 0 16px rgba(239,68,68,.6);
  animation: badge-pulse 2s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255,255,255,.15), 0 0 12px rgba(239,68,68,.5); transform: scale(1); }
  50%      { box-shadow: 0 0 0 4px rgba(255,255,255,.08), 0 0 24px rgba(239,68,68,.8); transform: scale(1.05); }
}

/* ═══════════════ SIDEBAR BRAND GLOW ═══════════════ */
.sb-brand-icon {
  filter: drop-shadow(0 0 12px rgba(34,197,94,.5));
  animation: brand-glow 3s ease-in-out infinite;
}
@keyframes brand-glow {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(34,197,94,.5)); }
  50%      { filter: drop-shadow(0 0 20px rgba(34,197,94,.8)); }
}

/* ═══════════════ COUNT-UP ═══════════════ */
.count-up { display: inline-block; font-variant-numeric: tabular-nums; }

/* ═══════════════ SKELETON SHIMMER ═══════════════ */
.skeleton {
  background: linear-gradient(90deg, #eef0f3 25%, #f7f8fa 50%, #eef0f3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ═══════════════ SCROLLBAR POLISH ═══════════════ */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: rgba(0,0,0,.02); }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #1e4d0f, #22c55e);
  border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #22c55e, #84cc16);
}

/* ═══════════════ PILL NAV (vanilla port of reactbits PillNav) ═══════════════ */
#pill-nav-row {
  display: flex;
  justify-content: center;
  padding: 0 8px;
  background: transparent;
  min-width: 0;
}
.fx-pill-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  flex-wrap: nowrap;
  justify-content: flex-start;
  min-width: 0;
}
.fx-pill-list {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  max-width: 100%;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  user-select: none;
}
.fx-pill-list::-webkit-scrollbar { display: none; }
.fx-pill-list.is-dragging { cursor: grabbing; scroll-behavior: auto; user-select: none; }
.fx-pill-logo {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #1e4d0f);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(34,197,94,.4);
  transition: transform .4s cubic-bezier(.34,1.56,.64,1);
  cursor: pointer;
}
.fx-pill-logo:hover { transform: rotate(360deg) scale(1.08); }
.fx-pill-list {
  display: flex;
  align-items: stretch;
  gap: 2px;
  background: #0a1f04;
  padding: 3px;
  border-radius: 9999px;
  height: 38px;
  box-shadow: 0 6px 20px rgba(10,31,4,.3);
  max-width: 100%;
}
.fx-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  height: 32px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  background: transparent;
  border: 0;
  transition: color .2s ease;
  flex-shrink: 0;
}
.fx-pill::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -50%;
  width: 110%;
  aspect-ratio: 1;
  background: #22c55e;
  border-radius: 50%;
  transform: translateX(-50%) scale(0);
  transform-origin: 50% 100%;
  transition: transform .35s cubic-bezier(.2,.9,.2,1);
  z-index: 0;
}
.fx-pill:hover::before { transform: translateX(-50%) scale(1.3); }
.fx-pill:hover { color: #0a1f04; }
.fx-pill-content { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 5px; }
.fx-pill-icon { font-size: 13px; }
.fx-pill.active {
  background: #22c55e;
  color: #0a1f04;
}
.fx-pill-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  box-shadow: 0 0 0 2px rgba(255,255,255,.15), 0 0 10px rgba(239,68,68,.6);
  animation: badge-pulse 2s ease-in-out infinite;
}
/* Back-to-CRM button (shown in inventory view) — compact icon */
.fx-pill-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0;
  color: #fff;
  background: linear-gradient(135deg, #1e4d0f, #166534);
  border: 0;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(30,77,15,.4);
  transition: transform .2s ease, box-shadow .2s ease;
  flex-shrink: 0;
}
.fx-pill-back::before {
  content: '↩';
  font-size: 16px;
  font-weight: 800;
}
.fx-pill-back:hover {
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 6px 14px rgba(30,77,15,.5);
}

/* ─── Mobile layout (pills with names + horizontal scroll) ─── */
@media (max-width: 768px) {
  #topbar {
    padding: 6px 10px !important;
    gap: 8px !important;
  }
  #pill-nav-row {
    padding: 0;
    order: 99;
    flex-basis: 100%;
    margin-top: 4px;
  }
  .fx-pill-nav {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: flex-start;
  }
  .fx-pill-list {
    height: 36px;
    padding: 3px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
  }
  .fx-pill-list::-webkit-scrollbar { display: none; }
  .fx-pill {
    height: 30px;
    padding: 0 10px;
    font-size: 11px;
    flex-shrink: 0;
  }
  .fx-pill-icon { font-size: 12px; }
  .fx-pill-logo { width: 36px; height: 36px; font-size: 16px; flex-shrink: 0; }
  .fx-pill-back { width: 30px; height: 30px; }
  .fx-pill-back::before { font-size: 14px; }
  #topbar-user { display: none !important; }
}

/* Hide menu button when inside inventory (frees up space) */
body.crm-inventory-view #menu-btn { display: none !important; }

/* ─── Online users indicator ─── */
#topbar-online { display: flex !important; align-items: center; gap: 8px; padding: 0 4px; flex-shrink: 0; }
.online-cluster {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 6px;
  background: linear-gradient(135deg, rgba(34,197,94,.12), rgba(34,197,94,.04));
  border: 1px solid rgba(34,197,94,.3);
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(34,197,94,.05), 0 2px 8px rgba(34,197,94,.1);
}
.online-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #22c55e;
  color: #052e16;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 0 12px rgba(34,197,94,.5);
}
.online-cluster .online-avatar {
  width: 26px;
  height: 26px;
  font-size: 10px;
  border: 2px solid #fff;
}
.online-cluster .online-avatar:hover { transform: translateY(-1px) scale(1.1); z-index: 2; }
.online-cluster .online-dot {
  width: 8px;
  height: 8px;
  border-width: 1.5px;
  animation: online-pulse 1.8s ease-in-out infinite;
}
@keyframes online-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,163,74,.6); }
  50%      { box-shadow: 0 0 0 6px rgba(22,163,74,0); }
}
.online-more {
  background: #6b7280 !important;
  font-size: 10px !important;
  font-weight: 800 !important;
}
.online-empty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(148,163,184,.1);
  border: 1px solid rgba(148,163,184,.25);
  border-radius: 999px;
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}
.online-empty-dot {
  width: 8px; height: 8px;
  background: #94a3b8;
  border-radius: 50%;
}
@media (max-width: 768px) {
  .online-empty-text { display: none; }
  .online-empty { padding: 6px; }
  .online-cluster { padding: 3px 6px 3px 4px; }
  .online-cluster .online-avatar { width: 22px; height: 22px; font-size: 9px; }
  .online-count-badge { min-width: 18px; height: 18px; font-size: 10px; padding: 0 4px; }
}

/* ═══════════════ REDUCED MOTION ═══════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  #login-screen::before, #login-screen::after { animation: none !important; }
}
