/* ==========================================================================
   Martin Dow Pharmaceutical Store — Design System
   Primary: Purple #6C2EB9 | White | Light Gray
   ========================================================================== */

:root {
  --purple-900: #3d1a68;
  --purple-700: #5423a0;
  --purple-600: #6C2EB9;
  --purple-500: #8347d1;
  --purple-400: #a06ee0;
  --purple-100: #EDE7F6;
  --purple-50: #F6F3FC;

  --ink: #1F1330;
  --ink-soft: #5b5169;
  --gray-100: #F5F3FA;
  --gray-200: #ECE9F3;
  --gray-300: #DCD7E8;
  --white: #ffffff;

  --success: #16A34A;
  --success-bg: #E8F7EE;
  --warn: #D97706;
  --warn-bg: #FEF3E2;
  --danger: #DC2626;
  --danger-bg: #FDECEC;
  --info: #2563EB;
  --info-bg: #EAF1FE;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-sm: 0 2px 8px rgba(60, 20, 100, 0.06);
  --shadow-md: 0 8px 24px rgba(60, 20, 100, 0.10);
  --shadow-lg: 0 16px 40px rgba(60, 20, 100, 0.16);

  --font-display: 'Poppins', 'Arial Black', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-logo: 'Arial Black', 'Poppins', sans-serif;

  --nav-h: 64px;
  --bottom-nav-h: 68px;
  --transition: 0.22s cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --ink: #F2EEFA;
  --ink-soft: #C6BDD9;
  --gray-100: #17111F;
  --gray-200: #1F1829;
  --gray-300: #2A2136;
  --white: #221A2E;
  --purple-50: #241B33;
  --purple-100: #2E2340;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.35);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--gray-100);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  padding-bottom: calc(var(--bottom-nav-h) + 12px);
}

img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--purple-300, #cbb8ea); border-radius: 10px; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Top App Bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--nav-h);
  padding: 0 16px;
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(108,46,185,0.08);
}
[data-theme="dark"] .topbar { background: rgba(23,17,31,0.75); }

.topbar .brand-mini { display: flex; align-items: center; gap: 8px; font-family: var(--font-logo); font-weight: 900; color: var(--purple-600); font-size: 18px; }
.topbar .brand-mini img { width: 32px; height: 32px; border-radius: 50%; }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-pill);
  display: flex; align-items: center; justify-content: center;
  background: var(--purple-50); color: var(--purple-600);
  transition: transform var(--transition), background var(--transition);
  position: relative;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn .badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--purple-600); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: var(--radius-pill);
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Hero / Brand block ---------- */
.hero-brand {
  text-align: center;
  padding: 34px 16px 22px;
  background: linear-gradient(180deg, var(--purple-50) 0%, var(--gray-100) 100%);
}
.hero-brand .logo-ring {
  width: 92px; height: 92px; border-radius: 50%;
  margin: 0 auto 14px;
  background: radial-gradient(circle at 30% 30%, #ffffffcc, #ffffff33), var(--white);
  border: 3px solid var(--purple-400);
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  animation: floatLogo 4.5s ease-in-out infinite;
}
.hero-brand .logo-ring img { width: 70%; height: 70%; object-fit: contain; }
@keyframes floatLogo { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-6px);} }

.hero-brand h1.brand-name {
  font-family: var(--font-logo);
  font-weight: 900;
  font-size: clamp(28px, 6vw, 40px);
  color: var(--purple-600);
  letter-spacing: 0.5px;
}
.hero-brand p.brand-tagline {
  font-size: 13px; color: var(--ink-soft); margin-top: 4px; letter-spacing: 1.5px; text-transform: uppercase;
}
.hero-brand h2.section-title {
  margin-top: 26px; font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--ink);
}

/* ---------- Search ---------- */
.search-wrap { padding: 14px 16px 6px; }
.search-pill {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--purple-100);
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.search-pill:focus-within { box-shadow: var(--shadow-md); border-color: var(--purple-400); }
.search-pill input { flex: 1; border: none; outline: none; background: transparent; font-size: 15px; color: var(--ink); }
.search-pill svg { flex-shrink: 0; color: var(--purple-500); }

/* ---------- Category capsule chips (signature element) ---------- */
.categories-scroll { display: flex; gap: 10px; overflow-x: auto; padding: 16px; scrollbar-width: none; }
.categories-scroll::-webkit-scrollbar { display: none; }
.cat-chip {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 9px 16px 9px 9px;
  border-radius: var(--radius-pill);
  background: var(--white);
  box-shadow: var(--shadow-sm);
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  border: 1.5px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.cat-chip .capsule {
  width: 26px; height: 14px; border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--purple-600) 50%, var(--white) 50%);
  border: 1.5px solid var(--purple-400);
  flex-shrink: 0;
}
.cat-chip.active, .cat-chip:hover { border-color: var(--purple-500); color: var(--purple-600); background: var(--purple-50); transform: translateY(-1px); }

/* ---------- Product grid & cards ---------- */
.product-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; padding: 6px 16px 24px;
}
@media (min-width: 620px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .product-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1180px) { .product-grid { grid-template-columns: repeat(5, 1fr); } }

.product-card {
  background: var(--white); border-radius: var(--radius-md); overflow: hidden;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer; position: relative;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.product-card .thumb { aspect-ratio: 1/1; background: var(--purple-50); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-card .cat-tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--purple-500); font-weight: 700; }
.product-card .name { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.3; min-height: 36px; }
.product-card .price-row { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.product-card .price { font-family: var(--font-display); font-weight: 700; color: var(--purple-600); font-size: 15px; }
.product-card .add-btn {
  width: 32px; height: 32px; border-radius: var(--radius-pill); background: var(--purple-600); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm);
  transition: transform var(--transition), background var(--transition);
}
.product-card .add-btn:active { transform: scale(0.88); }
.product-card .stock-badge {
  position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: var(--radius-pill); background: var(--danger-bg); color: var(--danger);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: var(--radius-md); font-weight: 700; font-size: 15px;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--purple-600); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--purple-700); box-shadow: var(--shadow-md); }
.btn-outline { background: transparent; border: 1.5px solid var(--purple-500); color: var(--purple-600); }
.btn-outline:hover { background: var(--purple-50); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-success { background: var(--success-bg); color: var(--success); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 13px 16px; border-radius: var(--radius-sm); border: 1.5px solid var(--gray-300);
  background: var(--white); color: var(--ink); font-size: 15px; transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--purple-500); box-shadow: 0 0 0 3px rgba(108,46,185,0.12); }
.auth-card {
  max-width: 420px; margin: 40px auto; background: var(--white); border-radius: var(--radius-lg);
  padding: 32px 26px; box-shadow: var(--shadow-md);
}

/* ---------- Cards / Sections ---------- */
.card { background: var(--white); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 18px; }
.section-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 6px; }
.section-header h2 { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.section-header a { font-size: 13px; color: var(--purple-600); font-weight: 600; }

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around; align-items: center;
  height: var(--bottom-nav-h);
  background: rgba(255,255,255,0.9); backdrop-filter: blur(16px);
  border-top: 1px solid rgba(108,46,185,0.08);
  box-shadow: 0 -4px 16px rgba(60,20,100,0.06);
}
[data-theme="dark"] .bottom-nav { background: rgba(23,17,31,0.92); }
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600; color: var(--ink-soft); flex: 1; position: relative;
  transition: color var(--transition);
}
.bottom-nav a.active, .bottom-nav a:hover { color: var(--purple-600); }
.bottom-nav a .cart-count {
  position: absolute; top: -4px; right: calc(50% - 16px);
  background: var(--purple-600); color: #fff; font-size: 9px; min-width: 15px; height: 15px;
  border-radius: var(--radius-pill); display: flex; align-items: center; justify-content: center;
}

/* ---------- Floating buttons ---------- */
.floating-actions { position: fixed; right: 16px; bottom: calc(var(--bottom-nav-h) + 16px); z-index: 45; display: flex; flex-direction: column; gap: 12px; }
.fab {
  width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg); color: #fff; transition: transform var(--transition);
  position: relative;
}
.fab:active { transform: scale(0.9); }
.fab-cart { background: var(--purple-600); }
.fab-whatsapp { background: #25D366; }
.fab .badge {
  position: absolute; top: -4px; right: -4px; background: #fff; color: var(--purple-600);
  font-size: 11px; font-weight: 800; min-width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm);
}

/* ---------- Hamburger / Drawer ---------- */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(20,10,35,0.45); z-index: 60; opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.drawer-overlay.open { opacity: 1; pointer-events: all; }
.drawer {
  position: fixed; top: 0; left: -300px; width: 280px; height: 100%; background: var(--white); z-index: 61;
  transition: left var(--transition); box-shadow: var(--shadow-lg); padding: 20px; overflow-y: auto;
}
.drawer.open { left: 0; }
.drawer .drawer-header { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--gray-200); margin-bottom: 12px; }
.drawer .drawer-header img { width: 48px; height: 48px; border-radius: 50%; }
.drawer nav a { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; color: var(--ink); }
.drawer nav a:hover { background: var(--purple-50); color: var(--purple-600); }

/* ---------- Toast ---------- */
#toast-container { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 380px); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: var(--radius-md);
  background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 600;
  animation: toastIn 0.3s ease;
}
.toast.success { background: #16A34A; }
.toast.error { background: #DC2626; }
.toast.info { background: var(--purple-600); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Skeleton ---------- */
.skeleton { background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-300) 37%, var(--gray-200) 63%); background-size: 400% 100%; animation: skeletonShine 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes skeletonShine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-card { height: 210px; border-radius: var(--radius-md); }

/* ---------- Loader ---------- */
.page-loader { position: fixed; inset: 0; background: var(--gray-100); z-index: 200; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; transition: opacity 0.4s ease, visibility 0.4s ease; }
.page-loader.hide { opacity: 0; visibility: hidden; }
.spinner { width: 46px; height: 46px; border: 4px solid var(--purple-100); border-top-color: var(--purple-600); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,10,35,0.5); z-index: 80; display: flex; align-items: flex-end; justify-content: center; opacity: 0; pointer-events: none; transition: opacity var(--transition); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
@media (min-width: 640px) { .modal-overlay { align-items: center; } }
.modal { background: var(--white); width: 100%; max-width: 480px; border-radius: 24px 24px 0 0; max-height: 88vh; overflow-y: auto; transform: translateY(30px); transition: transform var(--transition); padding: 22px; }
.modal-overlay.open .modal { transform: translateY(0); }
@media (min-width: 640px) { .modal { border-radius: var(--radius-lg); } }
.modal-close { position: absolute; top: 14px; right: 14px; }

/* ---------- Badges / status ---------- */
.status-badge { padding: 4px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; text-transform: capitalize; }
.status-pending { background: var(--warn-bg); color: var(--warn); }
.status-approved, .status-processing { background: var(--info-bg); color: var(--info); }
.status-shipped { background: var(--purple-100); color: var(--purple-600); }
.status-delivered { background: var(--success-bg); color: var(--success); }
.status-cancelled, .status-rejected { background: var(--danger-bg); color: var(--danger); }

/* ---------- Order card ---------- */
.order-card { background: var(--white); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-sm); margin: 0 16px 14px; }
.order-card .row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.order-card .products-line { font-size: 13px; color: var(--ink); margin: 8px 0; }
.order-card .amount { font-family: var(--font-display); font-weight: 700; color: var(--purple-600); font-size: 16px; }

/* ---------- Stat cards (dashboard) ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 6px 16px; }
@media (min-width: 700px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { background: var(--white); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-sm); }
.stat-card .stat-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--purple-50); color: var(--purple-600); display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 24px; font-weight: 800; color: var(--ink); }
.stat-card .stat-label { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--ink-soft); }
.w-full { width: 100%; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-state svg { color: var(--purple-300, #cbb8ea); margin-bottom: 12px; }
.hidden { display: none !important; }

/* Sidebar (admin desktop) */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar { width: 240px; background: var(--white); border-right: 1px solid var(--gray-200); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: none; }
.admin-sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 12px 12px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; color: var(--ink-soft); margin-bottom: 4px; }
.admin-sidebar nav a.active, .admin-sidebar nav a:hover { background: var(--purple-50); color: var(--purple-600); }
.admin-main { flex: 1; padding-bottom: calc(var(--bottom-nav-h) + 12px); }
@media (min-width: 900px) {
  .admin-sidebar { display: block; }
  .admin-main { padding-bottom: 24px; }
  body.admin-body .bottom-nav { display: none; }
}

table.data-table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius-md); overflow: hidden; }
table.data-table th, table.data-table td { padding: 12px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--gray-200); }
table.data-table th { background: var(--purple-50); color: var(--purple-600); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: 0.4px; }
.table-wrap { overflow-x: auto; margin: 0 16px; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }

/* Install prompt banner */
.install-banner {
  position: fixed; bottom: calc(var(--bottom-nav-h) + 10px); left: 12px; right: 12px; z-index: 55;
  background: var(--white); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 14px;
  display: flex; align-items: center; gap: 12px; transform: translateY(120%); transition: transform var(--transition);
}
.install-banner.show { transform: translateY(0); }
.install-banner img { width: 42px; height: 42px; border-radius: 12px; }
.install-banner .txt { flex: 1; }
.install-banner .txt strong { font-size: 13px; display: block; }
.install-banner .txt span { font-size: 11px; color: var(--ink-soft); }
