/* ==========================================================================
   THEME 3: COMPONENTS.CSS - PRECISION PHARMA HUB
   Tối ưu hóa hiển thị cho Quick Order, Customer 360, Leaflet Map, Bottom Nav, Modals
   ========================================================================== */

/* 1. MODAL OVERLAY COMPATIBILITY */
.modal-overlay.show,
.modal-overlay.open {
  opacity: 1 !important;
  visibility: visible !important;
  display: flex !important;
}

/* 2. LEAFLET MAP CONTAINER */
.leaflet-map-box {
  width: 100%;
  height: 480px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-radius: 6px !important;
  border: 1px solid var(--border-medium) !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: var(--font-body) !important;
}

.leaflet-popup-tip {
  background: var(--bg-surface) !important;
}

.map-marker-pulse {
  width: 18px;
  height: 18px;
  background: #059669;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 rgba(5, 150, 105, 0.4);
  animation: markerPulse 1.8s infinite;
}

@keyframes markerPulse {
  0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.7); }
  70% { box-shadow: 0 0 0 14px rgba(5, 150, 105, 0); }
  100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

/* 3. CUSTOMER 360 TABS */
.customer-360-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.customer-360-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.customer-tabs-nav {
  display: flex;
  gap: 4px;
  background: var(--bg-surface-alt);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.customer-tab-btn {
  padding: 8px 14px;
  font-size: 0.825rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.customer-tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-surface);
}

.customer-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.customer-tab-pane {
  display: none;
}

.customer-tab-pane.active {
  display: block;
}

/* 4. QUICK ORDER WORKSPACE */
.quick-order-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1024px) {
  .quick-order-layout {
    grid-template-columns: 1fr;
  }
}

.quick-order-cart-card {
  position: sticky;
  top: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.cart-items-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.cart-item-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.qty-counter-box {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-surface-alt);
}

.qty-btn {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
}

.qty-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.qty-input {
  width: 36px;
  text-align: center;
  border: none;
  background: transparent;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-main);
  outline: none;
}

/* 5. MOBILE BOTTOM NAVIGATION */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(58px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-subtle);
  z-index: 35;
  box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.08);
  justify-content: space-around;
  align-items: center;
  padding: 0 6px env(safe-area-inset-bottom, 0px) 6px;
}

.mobile-bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
  gap: 2px;
  transition: all 0.15s ease;
  position: relative;
}

.mobile-bottom-nav-item i {
  font-size: 1.15rem;
  transition: transform 0.15s ease;
}

.mobile-bottom-nav-item:active i {
  transform: scale(0.9);
}

.mobile-bottom-nav-item.active,
.mobile-bottom-nav-item:hover {
  color: var(--primary);
  font-weight: 700;
}

.mobile-bottom-nav-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
  }
}

/* 6. AI INSIGHTS & COPILOT DRAWER */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.ai-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
  z-index: 101;
}

.drawer-overlay.open .ai-drawer {
  transform: translateX(0);
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 7. ROW 2 COLUMN UTILITY */
.row-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .row-2-col {
    grid-template-columns: 1fr;
  }
}

/* 8. BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-neutral {
  background: var(--bg-surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.badge-outline {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}
