/* =========================================================================
   LESOVIA DESIGN SYSTEM
   Shared tokens + base elements + components. Load this BEFORE any
   page-specific stylesheet so page CSS only needs genuinely unique layout.
   ========================================================================= */

/* ---------- Tokens ---------- */
:root {
  --lv-green: #0B7A3D;
  --lv-green-deep: #086030;
  --lv-green-mist: #E8F5EC;
  --lv-green-mist-line: #CFE9D7;

  --lv-ink: #14231B;
  --lv-slate: #5B6B62;
  --lv-slate-soft: #8A968F;

  --lv-canvas: #F6F8F6;
  --lv-surface: #FFFFFF;
  --lv-line: #E2E8E4;

  --lv-danger: #C6362E;
  --lv-danger-deep: #A72922;
  --lv-danger-mist: #FBE9E8;

  --lv-gold: #C8930A;
  --lv-gold-mist: #FBF1DC;

  --lv-info: #2E5FA8;
  --lv-info-mist: #E9F0FA;

  --lv-space-1: 4px;
  --lv-space-2: 8px;
  --lv-space-3: 16px;
  --lv-space-4: 24px;
  --lv-space-5: 32px;
  --lv-space-6: 48px;

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

  --lv-shadow-sm: 0 1px 3px rgba(20, 35, 27, 0.08);
  --lv-shadow-md: 0 6px 20px rgba(20, 35, 27, 0.10);

  --lv-font-display: "Fraunces", Georgia, serif;
  --lv-font-body: "Work Sans", "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---------- Base ---------- */
body {
  font-family: var(--lv-font-body);
  background: var(--lv-canvas);
  color: var(--lv-ink);
}

h1, h2, h3 {
  font-family: var(--lv-font-display);
  color: var(--lv-ink);
  font-weight: 600;
}

a {
  color: var(--lv-green);
}

/* ---------- Buttons ----------
   New shared classes for anything we actively touch. Existing bespoke
   button selectors (#logoutBtn, .buyBtn, #searchBtn, etc.) are also
   reskinned below so pages that aren't fully migrated yet still look
   consistent without needing every inline style rewritten. */
.btn {
  font-family: var(--lv-font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--lv-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--lv-green);
  color: #fff;
}
.btn-primary:hover { background: var(--lv-green-deep); }

.btn-secondary {
  background: var(--lv-surface);
  color: var(--lv-ink);
  border-color: var(--lv-line);
}
.btn-secondary:hover { border-color: var(--lv-slate-soft); }

.btn-danger {
  background: var(--lv-danger);
  color: #fff;
}
.btn-danger:hover { background: var(--lv-danger-deep); }

.btn-sm {
  font-size: 13px;
  padding: 7px 12px;
}

/* Reskin existing button selectors used across the app so untouched pages
   still inherit the palette instead of clashing with it. */
#logoutBtn,
.deleteBtn,
button.deleteBtn {
  background: var(--lv-danger) !important;
  color: #fff !important;
  border: none;
  border-radius: var(--lv-radius-sm);
  padding: 8px 16px;
  cursor: pointer;
}
#logoutBtn:hover,
.deleteBtn:hover {
  background: var(--lv-danger-deep) !important;
}

.buyBtn,
.addCartBtn,
#addToCartBtn,
#buyBtn,
#searchBtn,
#sendMessageBtn,
#checkoutBtn,
#payBtn,
.cart-btn,
.order-btn,
.dashboard-btn,
.notification-btn,
button.shipBtn {
  background: var(--lv-green) !important;
  color: #fff !important;
  border: none;
  border-radius: var(--lv-radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.buyBtn:hover,
.addCartBtn:hover,
#addToCartBtn:hover,
#buyBtn:hover,
#searchBtn:hover,
#sendMessageBtn:hover,
#checkoutBtn:hover,
#payBtn:hover,
.cart-btn:hover,
.order-btn:hover,
.dashboard-btn:hover,
.notification-btn:hover,
button.shipBtn:hover {
  background: var(--lv-green-deep) !important;
}

/* ---------- Navbar (unifies the three different header colors) ---------- */
.navbar,
header,
header nav,
nav.navbar {
  background: var(--lv-ink);
  color: #fff;
}

/* :not(.btn) so this doesn't fight a button's own color -- a plain nav
   link (no .btn class) should default to white on this dark background,
   but something like ".btn-secondary" (white background, dark text) sets
   its own color on purpose and was losing that fight on cart/messages/
   order.html, rendering as invisible white-on-white text. */
.navbar a:not(.btn),
header a:not(.btn) {
  color: #fff;
}

/* !important on all four here so this one definition wins over whatever
   size/weight each page's own stylesheet happened to set on ".logo-text"
   -- that per-page drift (22px in one place, 24px in another, 32px in a
   third) is exactly why the wordmark looked different on every page. */
.logo-text,
.logo span {
  color: var(--lv-green-mist) !important;
  font-family: var(--lv-font-display) !important;
  font-size: 28px !important;
  font-weight: 600 !important;
}

/* ---------- Cards ---------- */
.card,
.review-card,
.profile-container,
section,
form.login-card,
.login-card {
  background: var(--lv-surface);
  border-radius: var(--lv-radius-md);
  box-shadow: var(--lv-shadow-sm);
}

/* ---------- Product cards ---------- */
.product-card {
  background: var(--lv-surface);
  border: 1px solid var(--lv-line);
  border-radius: var(--lv-radius-md);
  box-shadow: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}
.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--lv-shadow-md);
}
.product-card img,
.product-img {
  border-radius: var(--lv-radius-sm);
  object-fit: cover;
}
.product-card .price,
.product-card strong,
#detailPrice,
.product-price {
  color: var(--lv-green-deep) !important;
}

/* ---------- Reviews ---------- */
.review-card {
  border: 1px solid var(--lv-line);
  border-left: 4px solid var(--lv-gold);
}
.stars,
.review-stars,
.average-rating {
  color: var(--lv-gold) !important;
}

/* ---------- Forms ---------- */
input, select, textarea {
  font-family: var(--lv-font-body);
  border: 1px solid var(--lv-line);
  border-radius: var(--lv-radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  background: var(--lv-surface);
  color: var(--lv-ink);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--lv-green);
  box-shadow: 0 0 0 3px var(--lv-green-mist);
}

/* ---------- Badges / status pills ---------- */
.badge,
.notification-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: var(--lv-radius-pill);
  font-family: var(--lv-font-body);
}
.badge-success { background: var(--lv-green-mist); color: var(--lv-green-deep); border: 1px solid var(--lv-green-mist-line); }
.badge-warning { background: var(--lv-gold-mist); color: #8a660a; }
.badge-danger  { background: var(--lv-danger-mist); color: var(--lv-danger); }
.badge-info    { background: var(--lv-info-mist); color: var(--lv-info); }
.badge-neutral { background: var(--lv-canvas); color: var(--lv-slate); border: 1px solid var(--lv-line); }

.notification-badge {
  background: var(--lv-danger) !important;
  color: #fff !important;
}

/* ---------- Highlight (scroll-to target from a notification link) ----------
   Was only ever defined in the orphaned buyer.css (loaded by no page), so
   this effect has been silently invisible everywhere it was already used
   (e.g. jumping to a specific order from a notification), not just here. */
.highlight-order {
  border: 3px solid var(--lv-green) !important;
  box-shadow: 0 0 15px rgba(11, 122, 61, 0.5);
}

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed var(--lv-line);
  border-radius: var(--lv-radius-md);
  color: var(--lv-slate);
  background: var(--lv-surface);
}
.empty-state .empty-glyph {
  font-size: 28px;
  margin-bottom: 10px;
}

/* ---------- Loading skeleton (available now; wiring it into the actual
   data-fetch calls in app.js is a follow-up JS change, not included here) --- */
.lv-skeleton {
  background: linear-gradient(90deg, var(--lv-line) 25%, var(--lv-green-mist) 50%, var(--lv-line) 75%);
  background-size: 200% 100%;
  animation: lv-shimmer 1.6s infinite;
  border-radius: var(--lv-radius-sm);
}
@keyframes lv-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .lv-skeleton { animation: none; }
}

/* ---------- Toast (available now; replacing alert() calls in app.js is a
   functionality change and is intentionally NOT done in this pass) ---------- */
.lv-toast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--lv-ink);
  color: var(--lv-canvas);
  padding: 12px 18px;
  border-radius: var(--lv-radius-md);
  font-size: 14px;
  box-shadow: var(--lv-shadow-md);
}

/* ---------- Shop search matches (index.html / buyer dashboard) ---------- */
.shop-results-heading {
  margin: 10px 0 12px;
  font-size: 15px;
  color: var(--lv-slate);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.shop-card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.shop-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--lv-surface);
  border: 1px solid var(--lv-green-mist-line);
  border-radius: var(--lv-radius-md);
  padding: 16px 20px;
  text-decoration: none;
  color: var(--lv-ink);
  min-width: 240px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.shop-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--lv-shadow-md);
}

.shop-card-icon {
  font-size: 28px;
}

.shop-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.shop-card-rating {
  color: var(--lv-gold);
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 4px;
}

.shop-card-desc {
  font-size: 13px;
  color: var(--lv-slate);
  margin: 0;
}

/* ---------- Shop storefront page (shop.html) ---------- */
.shop-header {
  max-width: 1000px;
  margin: 30px auto 10px;
  padding: 0 5%;
}

.shop-header h1 {
  margin-bottom: 6px;
}

.shop-header .shop-rating-line {
  color: var(--lv-gold);
  font-weight: 600;
  margin-bottom: 10px;
}

.shop-header .shop-description {
  color: var(--lv-slate);
  max-width: 65ch;
}

/* ---------- Seller dashboard product stats (uploaded / sold) ---------- */
.seller-product-stats {
  font-size: 13px;
  color: var(--lv-slate);
}

/* ---------- Seller sales history (seller-history.html) ---------- */
.sold-item-card {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: var(--lv-surface);
  border: 1px solid var(--lv-line);
  border-radius: var(--lv-radius-md);
  padding: 18px;
  margin-bottom: 16px;
  max-width: 900px;
}

.sold-item-img {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: var(--lv-radius-sm);
  flex-shrink: 0;
  background: var(--lv-canvas);
}

.sold-item-info {
  flex: 1;
}

.sold-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.sold-item-header h3 {
  margin: 0;
}

.sold-item-info p {
  margin: 4px 0;
  font-size: 14px;
}

@media (max-width: 600px) {
  .sold-item-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

/* ---------- Messaging (messages.html / seller-messages.html) ----------
   Two-pane layout: a conversation list on the left, the open thread on the
   right -- same idea as WhatsApp Web. Below 700px it collapses to a single
   column; ".showing-detail" (toggled by showConversation/
   showConversationList in app.js) switches which pane is visible. */
.messages-app {
  display: flex;
  border: 1px solid var(--lv-line);
  border-radius: var(--lv-radius-md);
  overflow: hidden;
  max-width: 1300px;
  margin: 20px auto;
  height: 78vh;
  min-height: 600px;
  background: var(--lv-surface);
  box-shadow: var(--lv-shadow-sm);
}

.conversation-list {
  width: 380px;
  flex: none;
  border-right: 1px solid var(--lv-line);
  overflow-y: auto;
}

.conversation-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--lv-line);
  transition: background-color 0.15s ease;
}

.conversation-row:hover {
  background: var(--lv-canvas);
}

.conversation-row.active {
  background: var(--lv-green-mist);
}

.conversation-row img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: var(--lv-canvas);
}

.conversation-row-info {
  min-width: 0;
  flex: 1;
}

.conversation-row-info .conv-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--lv-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-row-info .conv-time {
  font-size: 13px;
  color: var(--lv-slate);
  margin-top: 4px;
}

.conversation-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.conversation-detail-empty {
  margin: auto;
  color: var(--lv-slate);
  padding: 40px;
  text-align: center;
}

.conversation-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--lv-line);
  background: var(--lv-canvas);
}

.conversation-detail-header img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.conversation-detail-header strong {
  font-size: 18px;
}

.conversation-back-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--lv-ink);
  padding: 0;
}

.conversation-thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  font-size: 15px;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-top: 1px solid var(--lv-line);
  background: var(--lv-surface);
}

.chat-attach-btn {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--lv-green);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-attach-btn:hover {
  background: var(--lv-green-deep);
}

.chat-text-input {
  flex: 1;
  border-radius: var(--lv-radius-pill);
  padding: 13px 20px;
  border: 1px solid var(--lv-line);
  resize: none;
  font-family: var(--lv-font-body);
  font-size: 15px;
  max-height: 90px;
}

.chat-send-btn {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--lv-green);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-send-btn:hover {
  background: var(--lv-green-deep);
}

.chat-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--lv-canvas);
  border: 1px solid var(--lv-line);
  border-radius: var(--lv-radius-pill);
  padding: 4px 10px;
  font-size: 12px;
  margin: 0 14px 6px;
}

@media (max-width: 700px) {
  .messages-app {
    flex-direction: column;
    border: none;
    border-radius: 0;
    height: 82vh;
    box-shadow: none;
  }

  .conversation-list {
    width: 100%;
    border-right: none;
  }

  /* The bigger desktop avatars would crowd a phone-width list. */
  .conversation-row img {
    width: 54px;
    height: 54px;
  }

  .conversation-detail-header img {
    width: 44px;
    height: 44px;
  }

  .conversation-detail {
    display: none;
  }

  .messages-app.showing-detail .conversation-list {
    display: none;
  }

  .messages-app.showing-detail .conversation-detail {
    display: flex;
  }

  .conversation-back-btn {
    display: inline-block;
  }
}
