/* ---------------------------
 * PROVIPHARM - FULL UPDATED MODERN CSS
 * --------------------------- */

:root {
  /* Modern Palette */
  --accent: #00AEEF; /* Primary Brand Blue */
  --accent-orange: #F68B1F; /* Secondary Brand Orange */
  --accent-dark: #008cc0;
  --bg-primary: #ffffff;
  --bg-secondary: #f4f5f9;
  --text-dark: #212529;
  --text-muted: #6c757d;

  /* Card and UI Styling */
  --radius-lg: 12px;
  --radius-sm: 6px;
  --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.08);
  --transition: all 0.2s ease-out;

  /* Status Colors */
  --price-color: #dc3545;
  --stock-in-color: #28a745;
  --stock-out-color: #6c757d;

  /* Badge Colors */
  --badge-soon-bg: #fff3cd;
  --badge-soon-color: #856404;
  --badge-expired-bg: #f8d7da;
  --badge-expired-color: #721c24;
  --badge-ok-bg: #d4edda;
  --badge-ok-color: #155724;
}

/* Base */
* { 
  box-sizing: border-box; 
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  width: 100%;
  overflow-x: hidden;
}

button, a, input, select { outline: none; }

button:focus, a:focus, input:focus, select:focus {
  outline: 3px solid rgba(0, 174, 239, 0.3);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------- */
/* Topbar / Header (FROZEN) */
/* ---------------------------------- */
.topbar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 16px 24px;
  background: var(--bg-primary);
  border-bottom: 2px solid var(--accent); /* Brand accent border */
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  color: var(--text-dark);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.topbar .header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.topbar .logo {
  height: auto;
  width: 250px;
}

/* --- UPDATED H1: SOLID BRAND COLOR (NO GRADIENT) --- */
.topbar h1 {
  margin: 0 auto;
  font-size: 1.8rem;
  font-weight: 800; 
  letter-spacing: -0.04em; 
  color: var(--accent); /* Solid #00AEEF */
  text-transform: uppercase;
  text-shadow: 1px 1px 0px rgba(0,0,0,0.02);
}

/* Dark Mode H1 Adjustment */
body.dark-mode .topbar h1 {
  color: #33beff; 
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.searchwrap {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}

.searchwrap input, .searchwrap select, .searchwrap button {
  padding: 10px 14px;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid #ced4da;
  transition: var(--transition);
}

.searchwrap input { min-width: 250px; flex: 1 1 250px; }
.searchwrap button {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border: 1px solid var(--accent);
  cursor: pointer;
}

.searchwrap button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* ---------------------------------- */
/* Toolbar (STAY-TOP SECONDARY BAR) */
/* ---------------------------------- */
.toolbar2 {
  display: flex;
  justify-content: space-between; 
  gap: 16px;
  align-items: center;
  padding: 12px 24px;
  flex-wrap: wrap;
  background: var(--bg-secondary);
  border-bottom: 1px solid #dee2e6;
  position: sticky;
  top: 153px; 
  z-index: 999;
}

.controls { display: none; }

.view-toggle button {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid #ced4da;
  background: var(--bg-primary);
  color: var(--text-muted);
  cursor: pointer;
}

.view-toggle button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---------------------------------- */
/* Grid & List containers */
/* ---------------------------------- */
.grid { 
  display: grid; 
  grid-template-columns: repeat(5, 1fr); 
  gap: 20px; 
  padding: 20px 24px; 
  width: 100%;
  box-sizing: border-box;
}
.list { display: flex; flex-direction: column; gap: 12px; padding: 20px 24px; width: 100%; }

/* Card Image */
.card img {
  width: 140px; 
  height: 140px;
  object-fit: contain; 
  background-color: #ffffff;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  border: 1px solid #eee;
  transition: var(--transition);
}

.card img:hover {
  transform: scale(1.05);
}

/* Card General Styling */
.card {
  padding: 16px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
  transition: var(--transition);
  display: flex;
  gap: 16px;
  align-items: flex-start;
  min-width: 0;
  border-top: 3px solid transparent;
}

.card:hover {
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
  transform: translateY(-3px);
  border-top: 3px solid var(--accent); /* Subtle interaction with brand blue */
}

/* Grid Layout Adjustments */
.grid .card { 
  flex-direction: column; 
  align-items: stretch; 
  text-align: center; 
}
.grid .card img {
  margin: 0 auto 12px auto; 
}

/* AUTO-ADJUST LAB & PRICE */
.labprice {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.lab-name {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boldprice {
  font-weight: 800;
  color: var(--price-color);
  font-size: 1.25rem;
  white-space: nowrap;
}

.grid .card .labprice {
  flex-direction: column;
  gap: 4px;
}

/* Card Content Styling */
.card .meta { flex: 1; min-width: 0; }
.card h2 {
  font-size: 1rem; font-weight: 600; color: var(--text-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.card .molecules { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .presentation { font-size: 0.95rem; color: var(--text-dark); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Stock styles */
.stock { margin-top: 10px; font-weight: 700; font-size: 0.85rem; text-transform: uppercase; }
.stock.bad-in { color: var(--stock-in-color); }
.stock.bad-out { color: var(--stock-out-color); }

/* --- EXPIRATION DATE FIX --- */
.expiry { 
  font-size: 0.9rem; 
  color: var(--text-muted); 
  margin-top: 8px; 
}

.expiry-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0, 174, 239, 0.05); /* Uses brand blue background tint */
  border: 1px solid rgba(0, 174, 239, 0.1);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  margin: 4px 0;
  width: auto;
}

.grid .card .expiry-row {
  margin-left: auto;
  margin-right: auto;
}

.expiry-icon { font-size: 0.9rem; }
.expiry-label { font-weight: bold; margin-right: 4px; font-size: 0.8rem; }
.expiry-date { font-size: 0.85rem; font-weight: 700; color: var(--text-dark); }

/* Expiry Color Coding */
.expiry-row.exp-expired { color: #dc3545; border-color: #dc3545; background: #fff5f5; }
.expiry-row.exp-urgent  { color: #fd7e14; border-color: #fd7e14; background: #fffaf0; }
.expiry-row.exp-warning { color: #856404; border-color: #ffeeba; background: #fff3cd; }
.expiry-row.exp-safe    { color: #28a745; border-color: #28a745; background: #f0fff4; }

body.dark-mode .expiry-row { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.1); }
body.dark-mode .expiry-row.exp-expired { background: #441a1a; }
body.dark-mode .expiry-row.exp-urgent  { background: #442a1a; }
body.dark-mode .expiry-row.exp-warning { background: #443a1a; }
body.dark-mode .expiry-row.exp-safe    { background: #1a4423; }

/* ---------------------------------- */
/* Quick view panel & Modals */
/* ---------------------------------- */
.quick-panel {
  position: fixed;
  right: 0; top: 0;
  height: 100vh;
  width: 460px;
  max-width: 95%;
  background: var(--bg-primary);
  padding: 24px;
  box-shadow: -12px 0 40px rgba(0,0,0,0.15);
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(0.2, 0.6, 0.4, 1);
  z-index: 9998;
  overflow-y: auto;
}
.quick-panel.open { transform: translateX(0); }
.quick-panel img { width: 100%; height: 320px; object-fit: contain; margin-bottom: 16px; border: 1px solid #f1f1f1; background: #fff; }
.quick-panel button { background: var(--accent); color: #fff; border: none; padding: 12px 20px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; width: 100%; margin-top: 10px;}
.quick-panel button#btnCloseQP { background: #6c757d; }

#imgModal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.9); z-index: 9999; }
#imgModal img { max-width: 90%; max-height: 90%; border-radius: var(--radius-lg); }

/* ---------------------------------- */
/* Footer & Utilities */
/* ---------------------------------- */
.main-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--bg-primary);
  border-top: 1px solid #e9ecef;
  padding: 15px 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  font-weight: 500;
}

.main-footer span {
  color: var(--accent); /* Brand blue footer accent */
  font-weight: 700;
}

body {
  padding-bottom: 60px; 
}

@media (max-width: 768px) {
  .main-footer {
    padding: 10px;
    font-size: 0.75rem;
  }
}

#backToTop { position: fixed; bottom: 80px; right: 24px; width: 45px; height: 45px; background: var(--accent); color: white; border: none; border-radius: 50%; display: none; align-items: center; justify-content: center; z-index: 999; cursor: pointer; }

.theme-toggle { background: none; border: 1px solid #ced4da; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; }

/* Orders & Cart */
.order-actions { display: flex; gap: 10px; }
.btn-order-toggle { background: #6c757d; color: white; border: none; padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; }
.btn-order-toggle.active { background: #dc3545 !important; }
.btn-generate-pdf { background: var(--stock-in-color); color: white; border: none; padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; }

.order-selector { margin-top: 12px; padding-top: 12px; border-top: 1px dashed #ddd; }
.qty-wrapper { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; }
.prod-qty { width: 80px; height: 32px; text-align: center; border: 1px solid #ccc; border-radius: var(--radius-sm); }

.cart-btn { background: var(--bg-secondary); border: 1px solid rgba(0,0,0,0.1); padding: 8px 12px; border-radius: var(--radius-sm); position: relative; cursor: pointer; }
#cartCount { position: absolute; top: -8px; right: -8px; background: var(--accent-orange); /* High visibility Orange */ color: white; font-size: 0.75rem; min-width: 18px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800;}

.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); z-index: 10001; display: flex; justify-content: center; align-items: center; padding: 20px; }
.cart-content { background: var(--bg-primary); width: 100%; max-width: 480px; max-height: 85vh; border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; }
.cart-header { padding: 20px; background: var(--bg-secondary); display: flex; justify-content: space-between; align-items: center; }
.cart-items-list { padding: 10px 20px; overflow-y: auto; flex: 1; }
.cart-item { display: flex; justify-content: space-between; padding: 15px 0; border-bottom: 1px solid rgba(0,0,0,0.05); }
.cart-footer { padding: 20px; background: var(--bg-secondary); }

/* Dark Mode */
body.dark-mode { --bg-primary: #1a1d21; --bg-secondary: #111315; --text-dark: #f8f9fa; --text-muted: #adb5bd; }
body.dark-mode .topbar, body.dark-mode .card, body.dark-mode .cart-content { border-color: #2d3238; }
body.dark-mode input, body.dark-mode select { background: #2d3238; color: white; border-color: #3f4750; }

/* --- FIX: Install Button Styling --- */
.install-btn {
  background-color: var(--accent) !important;
  color: #ffffff !important;
  border: 1px solid var(--accent) !important;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.install-btn:hover {
  background-color: var(--accent-dark) !important;
  border-color: var(--accent-dark) !important;
  box-shadow: 0 2px 8px rgba(0, 174, 239, 0.4);
}

.install-btn:focus {
  outline: 3px solid rgba(0, 174, 239, 0.3) !important;
  outline-offset: 2px;
}

.install-btn:active {
  transform: translateY(1px);
}

body.dark-mode .install-btn {
  background-color: var(--accent) !important;
  color: #ffffff !important;
  border-color: var(--accent) !important;
}

/* Ads */
.ad-container.ad-top-thin { width: calc(100% - 48px); max-width: 1200px; margin: 10px auto; height: 60px; background: var(--bg-primary); border: 1px solid rgba(0,0,0,0.05); border-radius: var(--radius-sm); position: relative; overflow: hidden; display: flex; justify-content: center; align-items: center; }
.ad-label-overlay { position: absolute; top: 2px; left: 6px; font-size: 0.6rem; color: #ccc; text-transform: uppercase; letter-spacing: 0.5px;
  pointer-events: none; 
  z-index: 1;}

/* ---------------------------------- */
/* RESPONSIVE BREAKPOINTS */
/* ---------------------------------- */

@media (max-width: 1200px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 992px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 15px; padding: 15px; }
}

@media (max-width: 768px) {
  .topbar {
    align-items: center;
    text-align: center;
    padding: 16px;
  }

  .topbar .header-content {
    flex-direction: column;
    gap: 12px;
  }

  .topbar .logo { 
    width: 180px; 
    margin: 0;
  }

  .topbar h1 {
    font-size: 1.4rem;
    margin: 0;
  }

  .header-actions {
    justify-content: center;
    width: 100%;
  }

  .toolbar2 { 
    top: 250px; 
    padding: 10px 15px; 
  }
  
  .grid { 
    grid-template-columns: repeat(2, 1fr); 
    gap: 10px; 
    padding: 10px; 
    width: 100%;
    margin: 0;
  }

  .card { 
    padding: 10px; 
    gap: 8px;
    min-width: 0;
  }
  
  .card img { 
    width: 100%; 
    max-width: 120px; 
    height: auto; 
    aspect-ratio: 1/1; 
  }

  .quick-panel { width: 100%; }
}

@media (max-width: 380px) {
  .grid { gap: 8px; padding: 8px; }
  .card { padding: 8px; }
}

.hidden { display: none !important; }

/* --- FIXED BADGE SYSTEM --- */
.card {
  position: relative !important;
}

.badge-container {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 99;
  pointer-events: none;
}

.badge {
  display: inline-block !important;
  padding: 4px 10px !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  width: fit-content;
  border: none !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.badge-new {
  background-color: var(--accent) !important; /* Brand Blue Badge */
  color: #ffffff !important;
}

.badge-price {
  background-color: var(--accent-orange) !important; /* Brand Orange Badge */
  color: #ffffff !important;
}

.list .badge-container {
  top: 5px;
  left: 5px;
}

body.dark-mode .badge-new {
  background-color: #008cc0 !important;
  color: #ffffff !important;
}
body.dark-mode .badge-price {
  background-color: #d87515 !important;
  color: #ffffff !important;
}

.molecules, .presentation, #qpMolecules, #qpPresentation {
  color: inherit !important;
  text-shadow: none !important; 
}