/* Tailwind CDN is loaded via script tag in HTML */

@layer base {
  :root {
    --brand-primary: var(--brand-primary, #0f766e);
    --brand-primary-hover: var(--brand-primary-hover, #0d9488);
    --brand-accent: var(--brand-accent, #d97706);
    --brand-bg: var(--bg-page, #f8fafc);
    --brand-surface: var(--bg-card, #ffffff);
    --brand-text: var(--text-primary, #0f172a);
    --brand-muted: var(--text-muted, #64748b);
    --brand-border: var(--border-default, #e2e8f0);
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
  }

  html {
    -webkit-tap-highlight-color: transparent;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--brand-bg);
    color: var(--brand-text);
    scroll-behavior: smooth;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
  }

  body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: calc(100px + var(--sab));
    -webkit-overflow-scrolling: touch;
  }

  @supports (padding-top: env(safe-area-inset-top)) {
    .safe-top {
      padding-top: var(--sat);
    }
    .safe-bottom {
      padding-bottom: var(--sab);
    }
  }
}

/* Scrollbar customization - Clean, visible, and consistent across desktop and mobile views */
* {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
  border: 2px solid #f1f5f9;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

::-webkit-scrollbar-thumb:active {
  background: #64748b;
}

::-webkit-scrollbar-corner {
  background: #f1f5f9;
}

@media (max-width: 640px) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  ::-webkit-scrollbar-thumb {
    border-width: 1.5px;
  }
}

/* Touch targets */
button, a, input, select, textarea {
  min-height: 44px;
  touch-action: manipulation;
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + var(--sab));
  padding-bottom: var(--sab);
  background-color: var(--bottom-nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--brand-border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 40;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--brand-muted);
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  background: none;
  border: none;
  padding: 4px 0;
}

.bottom-nav-item.active {
  color: var(--brand-primary);
  font-weight: 600;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
  transition: transform 0.2s ease;
}

.bottom-nav-item.active svg {
  transform: translateY(-2px);
  stroke: var(--brand-primary);
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  transform: translateX(12px);
  background-color: var(--discount-badge-bg);
  color: var(--text-inverse);
  font-size: 10px;
  font-weight: 700;
  border-radius: 9999px;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Product Card Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 640px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

@media (min-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
  }
}

@media (min-width: 1280px) {
  .product-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 24px;
  }
}

/* Product Card Styling */
.product-card {
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: 4px; /* Minimal, sharper corner radius */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.product-card:active {
  transform: scale(0.99);
}

@media (hover: hover) {
  .product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    border-color: #cbd5e1;
  }
  html.dark .product-card:hover {
    border-color: #475569;
  }
}

/* Image Container */
.product-card-img-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background-color: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-bottom: 1px solid var(--brand-border);
  overflow: hidden;
  border-radius: 4px 4px 0 0; /* Align with top corners of the card */
}

.product-card-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: transform 0.3s ease;
}

/* Wishlist Button */
.product-card-wish-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border: 1px solid var(--border-default);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
  z-index: 10;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

html.dark .product-card-wish-btn {
  background: rgba(23, 30, 46, 0.9);
  border-color: #2a3547;
}

.product-card-wish-btn:hover {
  transform: scale(1.1);
}

/* Info Container */
.product-card-info {
  padding: 10px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  justify-content: space-between;
  gap: 8px;
}

.product-card-top-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.product-card-category {
  font-size: 10px;
  font-weight: 600;
  color: var(--brand-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.product-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 2.8em;
  max-height: 2.8em;
  cursor: pointer;
  margin: 0;
}

.product-card-title:hover {
  color: var(--brand-primary);
}

.product-card-bottom-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Delivery Line */
.product-card-delivery {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--brand-muted);
  line-height: 1.2;
}

/* Price Container */
.product-card-price-container {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.product-card-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-primary);
}

.product-card-old-price {
  font-size: 12px;
  text-decoration: line-through;
  color: var(--text-light);
}

/* Buttons Grid */
.product-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}

.product-card-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  height: 36px;
  min-height: 36px;
  border-radius: 4px; /* sharper buttons as requested */
  cursor: pointer;
  padding: 0 4px;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Button standard styles: "কার্টে রাখুন" and "এখনই কিনুন" */
.add-to-cart-btn, .buy-now-btn {
  background-color: #ffffff !important;
  border: 1.5px solid !important;
  border-radius: 4px !important; /* Sharp corners consistently */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease !important;
  cursor: pointer;
}

/* Specific color themes */
.add-to-cart-btn {
  border-color: var(--brand-primary) !important;
  color: var(--brand-primary) !important;
}

.buy-now-btn {
  border-color: var(--brand-accent) !important;
  color: var(--brand-accent) !important;
}

/* Dark mode overrides: use dark surface background instead of pure white */
html.dark .add-to-cart-btn, html.dark .buy-now-btn {
  background-color: var(--brand-surface) !important;
}

/* Hover states (only on hover-enabled devices) */
@media (hover: hover) {
  .add-to-cart-btn:hover {
    background-color: var(--brand-primary) !important;
    color: #ffffff !important;
    border-color: var(--brand-primary) !important;
  }
  .buy-now-btn:hover {
    background-color: var(--brand-accent) !important;
    color: #ffffff !important;
    border-color: var(--brand-accent) !important;
  }
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--border-default) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 6px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toast Notification */
#toast-container {
  position: fixed;
  top: max(16px, var(--sat));
  right: 16px;
  left: 16px;
  max-width: 400px;
  margin: 0 auto;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--text-primary);
  color: var(--text-inverse);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.error {
  background: var(--status-error-text);
}

.toast.success {
  background: var(--status-success-text);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Drawer / Modal Overlay */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.drawer-content {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 85%;
  max-width: 360px;
  background: white;
  z-index: 51;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.drawer-overlay.active .drawer-content {
  transform: translateX(0);
}

/* Floating Action / Image Zoom Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* ----------------------------------------------------
   DARK MODE OVERRIDES
   ---------------------------------------------------- */
html.dark, html.dark body {
  background-color: #0b0f19 !important;
  color: #f8fafc !important;
  --brand-bg: #0b0f19;
  --brand-surface: #171e2e;
  --brand-text: #f8fafc;
  --brand-muted: #94a3b8;
  --brand-border: #2a3547;
}

/* Card & Background Overrides */
html.dark .bg-white {
  background-color: #171e2e !important;
}
html.dark .bg-slate-50 {
  background-color: #0b0f19 !important;
}
html.dark .bg-slate-100 {
  background-color: #242f41 !important;
}
html.dark .bg-slate-50\/40 {
  background-color: rgba(23, 30, 46, 0.4) !important;
}
html.dark .bg-teal-50\/40 {
  background-color: rgba(15, 118, 110, 0.15) !important;
}
html.dark .bg-teal-50 {
  background-color: rgba(15, 118, 110, 0.2) !important;
  color: #2dd4bf !important;
}
html.dark .bg-amber-50 {
  background-color: rgba(217, 119, 6, 0.15) !important;
  color: #fbbf24 !important;
  border-color: rgba(217, 119, 6, 0.3) !important;
}
html.dark .bg-red-50 {
  background-color: rgba(239, 68, 68, 0.15) !important;
  color: #fca5a5 !important;
}
html.dark .bg-rose-50 {
  background-color: rgba(244, 63, 94, 0.15) !important;
  color: #fda4af !important;
}

/* Borders */
html.dark .border-slate-100,
html.dark .border-slate-200,
html.dark .border-slate-300 {
  border-color: #2a3547 !important;
}
html.dark hr {
  border-color: #2a3547 !important;
}

/* Typography Overrides */
html.dark .text-slate-900 {
  color: #f8fafc !important;
}
html.dark .text-slate-800 {
  color: #e2e8f0 !important;
}
html.dark .text-slate-700 {
  color: #cbd5e1 !important;
}
html.dark .text-slate-600 {
  color: #94a3b8 !important;
}
html.dark .text-slate-500 {
  color: #64748b !important;
}
html.dark .text-slate-400 {
  color: #475569 !important;
}

/* Inputs, Selects, Textareas */
html.dark input,
html.dark select,
html.dark textarea {
  background-color: #171e2e !important;
  color: #f8fafc !important;
  border-color: #2a3547 !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #475569 !important;
}
html.dark input:focus,
html.dark select:focus,
html.dark textarea:focus {
  background-color: #171e2e !important;
  border-color: #0f766e !important;
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.2) !important;
}

/* UI Custom Overrides */
html.dark header {
  background-color: #171e2e !important;
  border-color: #2a3547 !important;
}
html.dark .bottom-nav {
  background-color: rgba(23, 30, 46, 0.95) !important;
  border-color: #2a3547 !important;
}
html.dark .drawer-content {
  background: #171e2e !important;
}
html.dark .drawer-item {
  color: #cbd5e1 !important;
}
html.dark .drawer-item:hover,
html.dark .drawer-item:active {
  background-color: #242f41 !important;
}
html.dark .category-chip {
  background-color: #171e2e !important;
  border-color: #2a3547 !important;
  color: #cbd5e1 !important;
}
html.dark .category-chip.active {
  background-color: #0f766e !important;
  border-color: #0f766e !important;
  color: #ffffff !important;
}
html.dark .chat-container {
  background: #171e2e !important;
  border-color: #2a3547 !important;
}
html.dark .chat-bubble.admin {
  background-color: #242f41 !important;
  color: #e2e8f0 !important;
}
html.dark .bg-teal-100 {
  background-color: rgba(15, 118, 110, 0.25) !important;
  color: #2dd4bf !important;
}
html.dark .bg-teal-500 {
  background-color: #0f766e !important;
}
html.dark .ring-white {
  --tw-ring-color: #171e2e !important;
}
html.dark .divide-slate-100 > * + *,
html.dark .divide-slate-200 > * + * {
  border-color: #2a3547 !important;
}
