/* Theme Variables */
:root {
  /* Day Mode Colors */
  --bg-primary: #fefcf8;
  --text-primary: #2a2a2a;
  --navbar-bg: rgba(255, 255, 255, 0.95);
  --navbar-text: #2a2a2a;
  --card-bg: #fff;
  --card-shadow: rgba(200, 160, 120, 0.05);
  --card-hover-shadow: rgba(255, 128, 0, 0.85);
  --accent-color: rgba(205, 127, 50, 0.85);
  --footer-bg: #111;
  --footer-text: #eee;
  --modal-bg: #fff;
  --modal-text: #2a2a2a;
  --border-color: #e0e0e0;
  --light-bg: #f9f9f9;
  --sidebar-bg: #f8f9fa;

  /* Overlay (follows theme via existing vars) */
  --overlay-bg: var(--card-bg);
  --overlay-text: var(--text-primary);
}

/* Night Mode Colors */
[data-theme="night"] {
  --bg-primary: #1a1a1a;
  --text-primary: #f0f0f0;
  --navbar-bg: rgba(26, 26, 26, 0.95);
  --navbar-text: #f0f0f0;
  --card-bg: #2d2d2d;
  --card-shadow: rgba(0, 0, 0, 0.3);
  --card-hover-shadow: rgba(205, 127, 50, 0.6);
  --accent-color: rgba(205, 127, 50, 0.85);
  --footer-bg: #0a0a0a;
  --footer-text: #ccc;
  --modal-bg: #2d2d2d;
  --modal-text: #f0f0f0;
  --border-color: #404040;
  --light-bg: #2d2d2d;
  --sidebar-bg: #2d2d2d;
}

/* ============================
   Global Font Setup
   ============================ */
* {
  font-family: 'Poppins', 'Playfair Display', serif !important;
  font-weight: 400;
}

h1,
h2,
h3,
h4,
h5,
h6,
.navbar-brand,
.section-title,
.footer-brand,
.contact-title,
.checkout-title {
  font-family: 'Playfair Display', serif !important;
  font-weight: 700;
}

.btn,
.form-label,
.form-control,
.nav-link,
p,
li,
a {
  font-family: 'Poppins', sans-serif !important;
  font-weight: 400;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================
   Navbar Enhancement - White & Minimal
   ============================ */
.navbar {
  background-color: var(--navbar-bg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1100;
}

.navbar .navbar-brand,
.navbar .nav-link {
  color: var(--navbar-text);
  transition: color 0.3s ease;
}

.navbar .nav-link:hover {
  color: var(--accent-color);
}

/* Navbar mobile styles */
@media (max-width: 991.98px) {
  .navbar {
    background-color: var(--navbar-bg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  }

  .navbar .navbar-brand,
  .navbar .nav-link {
    color: var(--navbar-text);
  }

  .navbar .nav-link:hover {
    color: var(--accent-color);
  }

  .navbar-toggler {
    border-color: var(--border-color);
  }

  .navbar-toggler-icon {
    filter: invert(0);
  }
}

/* Night mode navbar toggler icon */
[data-theme="night"] .navbar-toggler-icon {
  filter: invert(1);
}

/* ============================
   Content margin below fixed navbar
   ============================ */
main,
#mainContent,
.content-wrapper {
  margin-top: 60px;
}

/* ============================
   Search Bar and Table Horizontal Layout
   ============================ */
.search-table-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.search-input {
  flex: 1 1 300px;
  padding: 0.6rem 1rem;
  border: 2px solid rgba(205, 127, 50, 0.85);
  border-radius: 30px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s ease;
}

.search-input:focus {
  border-color: rgba(205, 127, 50, 1);
  box-shadow: 0 0 8px rgba(205, 127, 50, 0.7);
}

.product-table {
  border-collapse: collapse;
  border: 2px solid rgba(205, 127, 50, 0.85);
  border-radius: 10px;
  overflow: hidden;
  max-width: 700px;
  box-shadow: 0 0 15px rgba(205, 127, 50, 0.15);
}

.product-table th,
.product-table td {
  padding: 0.75rem 1rem;
  border: 1px solid rgba(205, 127, 50, 0.25);
  text-align: left;
  font-family: 'Poppins', sans-serif;
  color: #2a2a2a;
  font-weight: 500;
}

.product-table th {
  background-color: rgba(205, 127, 50, 0.15);
}

/* ============================
   Product Card
   ============================ */
.product-card {
  text-align: center;
  padding: 1rem 0.75rem;
  border-radius: 0.5rem;
  overflow: hidden;
  background-color: var(--card-bg);
  box-shadow: 0 0 10px var(--card-shadow);
  transition: box-shadow 0.3s ease;
  position: relative;
  max-width: 280px;
  margin: auto;
}

.product-card:hover {
  box-shadow: 0 0 25px var(--card-hover-shadow);
}

.product-img-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 0.5rem;
}

.product-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 0.5rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: block;
}

.product-card:hover img {
  transform: scale(1.05);
  box-shadow: 0 10px 20px rgba(205, 127, 50, 0.85);
}

.product-card button {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  padding: 0.4rem 1.1rem;
  border-radius: 30px;
  border: 2px solid rgba(205, 127, 50, 0.85);
  background-color: transparent;
  color: rgba(205, 127, 50, 0.85);
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
}

.product-card button:hover {
  background-color: rgba(205, 127, 50, 0.85);
  color: #fff;
  border-color: rgba(205, 127, 50, 0.85);
}

.sale-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(205, 127, 50, 0.95);
  color: #fff;
  padding: 6px 14px;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 1.2rem;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: skew(-12deg);
  cursor: default;
  transition: box-shadow 0.3s ease;
  z-index: 20;
}

.sale-badge:hover {
  box-shadow: 0 6px 16px rgba(205, 127, 50, 0.8);
}

.sale-badge .old-price {
  position: relative;
  font-size: 0.8rem;
  opacity: 0.75;
  color: #fff;
  text-transform: uppercase;
  padding-right: 12px;
  transform: skew(12deg);
}

.sale-badge .old-price::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 5%;
  right: 5%;
  border-top: 2.5px solid #fff;
  transform: rotate(-15deg);
  transform-origin: center;
  opacity: 0.85;
}

.sale-badge .new-price {
  color: #cd7f32;
  font-size: 1.1rem;
  font-weight: 900;
  text-transform: uppercase;
  transform: skew(12deg);
}

/* ============================
   Section Titles and Animations
   ============================ */
.section-title {
  text-align: center;
  margin-bottom: 1.25rem;
  color: rgba(205, 127, 50, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  animation: titleFade 1.2s ease both;
}

@keyframes titleFade {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================
   Footer Styling
   ============================ */
.footer {
  margin-top: 2rem;
  padding: 1rem 0;
  background-color: var(--footer-bg);
  color: var(--footer-text);
}

.footer-brand {
  color: var(--accent-color);
  font-weight: bold;
  font-style: italic;
}

.section-heading {
  color: var(--accent-color);
}

.footer-link {
  color: var(--footer-text);
  text-decoration: none;
  transition: color 0.3s ease;
  display: inline-block;
}

.footer-link:hover {
  color: var(--accent-color);
}

.social-icon {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.3s ease;
}

.social-icon:hover {
  color: rgba(205, 127, 50, 1);
}

.footer-slogan {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-color);
  text-shadow: 2px 3px 6px rgba(0, 0, 0, 0.6);
  user-select: none;
}

/* ============================
   Responsive Enhancements (MOBILE)
   ============================ */
@media (max-width: 991.98px) {
  /* Toggle button style (optional hover) */
  #filterToggleBtn:hover {
    background: rgba(205, 127, 50, 1);
  }

  /* FILTER OVERLAY - full viewport width under navbar (themed) */
  #filterOverlay {
    display: none;
    position: fixed;
    top: 56px;                 /* below navbar */
    left: 0;
    width: 100vw;

    /* Use dynamic viewport height to avoid browser UI overlap */
    height: calc(100dvh - 56px);

    background-color: var(--overlay-bg);
    color: var(--overlay-text);
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.3);

    /* leave room at the bottom so content never hides behind the sticky actions */
    padding: 1rem 1rem 6rem;

    z-index: 1050;
    overflow-y: auto;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
    transform: translateX(-100%);
    opacity: 0;
  }

  /* Show the overlay - slide in from left */
  #filterOverlay.active {
    display: block;
    transform: translateX(0);
    opacity: 1;
  }

  /* Close button stays on top-right below navbar */
  #closeFilterBtn {
    position: fixed;
    top: 56px;
    right: 1rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    color: rgba(205, 127, 50, 0.85);
    transition: color 0.3s ease;
    z-index: 11000;
  }

  #closeFilterBtn:hover {
    color: rgba(205, 127, 50, 1);
  }

  /* Ensure overlay headings don't hide under close button */
  #filterOverlay > h4 {
    padding-top: 2.5rem;
  }

  /* Hide desktop sidebar on mobile */
  #filterSidebar {
    display: none !important;
  }

  /* Sticky actions bar at the bottom of the mobile overlay */
  .filter-actions {
    position: sticky;
    bottom: 0;
    background: var(--overlay-bg);
    padding: 0.75rem 0;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    /* iOS safe area support */
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
}

/* Theme Toggle Button */
.theme-toggle {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.3s ease;
  margin-left: 1rem;
}

.theme-toggle:hover {
  background-color: var(--accent-color);
  color: white;
  transform: scale(1.1);
}

/* Filter Sidebar with Theme Support (DESKTOP) */
#filterSidebar {
  background-color: var(--sidebar-bg) !important;
  border-color: var(--border-color) !important;
}

/* Make overlay/labels readable in both themes */
#filterOverlay label,
#filterSidebar label {
  color: var(--text-primary);
}

/* Modal Theming */
.modal-content {
  background-color: var(--modal-bg);
  color: var(--modal-text);
  border: 1px solid var(--border-color);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
}

.modal-footer {
  border-top: 1px solid var(--border-color);
}

/* Form Controls Theming */
.form-control {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.form-control:focus {
  background-color: var(--card-bg);
  border-color: var(--accent-color);
  color: var(--text-primary);
  box-shadow: 0 0 0 0.2rem rgba(205, 127, 50, 0.25);
}

/* Button Theming */
.btn-outline-dark {
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-outline-dark:hover {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

/* Tablet & down tweaks for navbar items */
@media (max-width: 1024px) {
  .navbar-nav .nav-item {
    display: flex;
    justify-content: center;
  }
  .navbar-nav .theme-toggle {
    width: auto;
    margin: 0;
  }
}

/* 1) Make every card stretch to the same height in its row */
#products .row.g-4 {
  align-items: stretch;
}

#products .product-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* 2) Clamp the description text to 3 lines with an ellipsis */
.product-desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1rem;
}

/* Footer logo sizing */
.footer-logo {
  display: inline-block;
  max-width: 180px;
  width: auto;
  height: auto;
  margin: 0 auto 1rem;
  transition: transform 0.3s ease;
}

.footer-logo:hover {
  transform: scale(1.05);
}

@media (max-width: 767px) {
  .footer .col-md-3 {
    text-align: center;
  }
}

@media (min-width: 577px) and (max-width: 1024px) {
  .footer-logo {
    max-width: 100px;
    margin-bottom: 0.75rem;
  }
}

/* ============================
   Pagination — pill-style
   ============================ */
.custom-pagination {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.custom-pagination .page-link {
  border-radius: 1.5rem;
  padding: 0.4rem 0.8rem;
  min-width: 2rem;
  text-align: center;
  color: #555;
  background-color: #fff;
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.custom-pagination .page-link:hover {
  background-color: #f0f0f0;
  color: #333;
}

.custom-pagination .page-item.active .page-link {
  background-color: var(--accent-color);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.custom-pagination .page-item.disabled .page-link {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 400px) {
  .custom-pagination .page-link {
    padding: 0.25rem 0.5rem;
    min-width: 1.6rem;
    font-size: 0.85rem;
  }
}

/* Prevent mobile modal from hiding under navbar */
@media (max-width: 576px) {
  .modal-dialog.modal-dialog-centered {
    margin: 56px auto 0 !important;
  }
}
