/* ==============================
   Root Variables & Dark Mode
   ============================== */
:root {
  --bg-color: #f0f4f8;
  --text-color: #333;
  --card-bg: #ffffff;
  --badge-bg: #ff6347;
  --hot-badge-bg: #f39c12;
  --active-filter-bg: #36c36c;
  --stock-color: #1d1d1d;
  --stock-out-color: #d9534f;
  --btn-color: #007bff;
  --btn-hover-color: darkblue;
  --btn-text-color: #333;
}

body.dark-mode {
  --bg-color: #1e1e1e;
  --text-color: #f0f0f0;
  --card-bg: #2c2c2c;
  --badge-bg: #c0392b;
  --hot-badge-bg: #f39c12;
  --active-filter-bg: #27ae60;
  --stock-color: #28a823;
  --stock-out-color: #ff6b6b;
  --btn-color: #3498db;
  --btn-hover-color: #1f5fa6;
  --btn-text-color: #f0f0f0;
}

/* ==============================
   Global
   ============================== */
body {
  font-family: 'Segoe UI', sans-serif;
  margin: 0;
  padding: 0 0 70px;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background 0.3s, color 0.3s;
}

/* ==============================
   Header
   ============================== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background-color: var(--card-bg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.branding {
  display: flex;
  align-items: center;
  gap: 10px;
}

.branding img {
  height: 36px;
  width: auto;
}

.branding h1 {
  font-size: 1.2em;
  margin: 0;
  font-weight: 500;
  color: var(--text-color);
}

.branding p {
  margin: 0;
  font-size: 0.85em;
}

/* ==============================
   Dark Mode Switch
   ============================== */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 20px;
}

.slider:before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* ==============================
   Send Message Button
   ============================== */
.card-front .send-msg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0.4em 0.8em;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--btn-color);
  background-color: transparent;
  color: var(--btn-text-color);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
}

.card-front .send-msg-btn:hover {
  border-color: var(--btn-hover-color);
  color: var(--btn-hover-color);
  transform: scale(1.05);
}

.card-front .send-msg-btn::after {
  content: ">";
  font-weight: bold;
  margin-left: 4px;
  transition: transform 0.2s ease;
}

.card-front .send-msg-btn:hover::after {
  transform: translateX(2px);
}

/* ==============================
   Badge
   ============================== */
.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background:none;
  color: white;
  font-size: 0.75em;
  padding: 0.4em 0.7em;
  border-radius: 6px;
  font-weight: bold;
}

.badge.hot {
  background-color: var(--hot-badge-bg);
}

/* ==============================
   Seller Info
   ============================== */
.seller-info {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-color);
  z-index: 10;
  max-width: 90%;
  overflow: hidden;
}

/* ==============================
   Login Link
   ============================== */
.login-link {
  color: var(--text-color);
  font-weight: 500;
  text-decoration: none;
  font-size: 1rem;
  padding: 6px 10px;
  transition: color 0.2s ease;
}

.login-link:hover {
  color: #28a745;
  text-decoration: underline;
}

/* ==============================
   Filters & Search
   ============================== */
.filters {
  background-color: var(--card-bg);
  padding: 1em 1.5em 0.8em;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 1em;
}

.filter-buttons {
  display: flex;
  gap: 1em;
  flex-wrap: wrap;
}

.filter-with-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.filter-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 5px;
}

.filter {
  padding: 0.5em 1em;
  background-color: #e0e0e0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.3s ease, color 0.3s ease;
}

.filter:hover {
  background-color: #d0d0d0;
}

.filter.active {
  background-color: var(--active-filter-bg);
  color: white;
}

.search-bar {
  display: flex;
  width: 100%;
}

#search {
  padding: 0.6em 1em;
  border-radius: 8px;
  border: 1px solid #ccc;
  width: 100%;
  max-width: 320px;
  font-size: 1em;
  background-color: var(--card-bg);
  color: var(--text-color);
}

/* ==============================
   Product Grid & Cards
   ============================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5em;
  padding: 1.5em;
}

.card {
  perspective: 1200px;
  background: transparent;
  border-radius: 16px;
  position: relative;
  animation: fadeIn 0.4s ease;
  min-height: 300px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(.2,.9,.2,1);
  transform-style: preserve-3d;
  border-radius: 16px;
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.5em;
  background: var(--card-bg);
  box-shadow: 0 4px 14px rgba(0,0,0,0.04);
  color: var(--text-color);
  border-radius: 16px;
  backface-visibility: hidden;
}

.card-back {
  transform: rotateY(180deg);
  overflow-y: auto;
  padding-right: 0.8em;
  align-items: flex-start;
  gap: 0.6em;
}

.card-front img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 0.8em;
}

.title {
  font-size: 1.1em;
  font-weight: 600;
  margin: 0.5em 0 0.2em;
}

.price {
  color: #36c36c;
  font-weight: bold;
  font-size: 1em;
}

.stock {
  font-size: 0.85em;
  color: var(--stock-color);
  margin-top: 6px;
}

.stock.out {
  color: var(--stock-out-color);
  font-weight: bold;
}

.card.out-of-stock {
  opacity: 0.6;
}

/* ==============================
   Profile Image
   ============================== */
.profile-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid #ccc;
  transition: border-color 0.3s ease;
}

.profile-img:hover {
  border-color: #888;
}

/* ==============================
   Bottom Navigation
   ============================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--card-bg);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  z-index: 1000;
}

.bottom-nav a {
  text-decoration: none;
  color: #777;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bottom-nav a i {
  font-size: 18px;
  margin-bottom: 3px;
}

.bottom-nav a.active {
  color: #00bfff;
  position: relative;
}

/* ==============================
   Responsive Adjustments
   ============================== */
@media (max-width: 480px) {
  .seller-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }

  .card-front .send-msg-btn {
    width: 100%;
    font-size: 0.7rem;
    padding: 0.35em 0.6em;
  }

  .grid {
    gap: 1em;
    padding: 1em;
  }

  .card-front img {
    width: 70px;
    height: 70px;
  }

  .filter-buttons {
    gap: 0.4em;
  }

  .bottom-nav a {
    font-size: 10px;
  }

  .bottom-nav a i {
    font-size: 16px;
  }
}
