/* products.css - styling for product listing pages */
:root{
  --brand-dark: #001f3f;
  --brand-accent: #6CA6CD;
  --menu-link-color: var(--brand-accent);
  --menu-link-hover-color: plum;
  --card-radius: 0.5rem;
}

.page-title { color: var(--brand-dark); font-weight:700; margin-bottom:0.25rem; }
.product-grid .product-card { border-radius: var(--card-radius); border: 1px solid #e6e6e6; transition: transform .15s ease, box-shadow .15s ease; box-shadow: 0 1px 6px rgba(0,0,0,0.06); overflow: hidden; display:flex; flex-direction:column; }
.product-grid .product-card:hover { transform: translateY(-6px); box-shadow: 0 14px 40px rgba(0,0,0,0.12); }
.product-thumb { width:100%; height:200px; object-fit:cover; display:block; background:#f7f7f7; }
.terrarium-preview-image { filter: grayscale(1) brightness(0.55) contrast(0.95) !important; }
.product-body { padding: 0.85rem 0.9rem; display:flex; flex-direction:column; flex:1 1 auto; }
.product-title { color: var(--brand-dark); font-weight:700; margin:0 0 0.25rem 0; font-size:1rem; }
.product-sub { color:#555; font-size:0.85rem; margin:0 0 0.5rem 0; }

/* Product card link color: only style contextual text links (not buttons). */
.product-sub a {
  color: var(--menu-link-color) !important;
  text-decoration: none;
}
.product-sub a:hover {
  color: var(--menu-link-hover-color) !important;
  text-decoration: underline;
}
.product-price { font-size:1.05rem; color:#111; font-weight:700; }
.product-badge { background: var(--brand-accent); color: var(--brand-dark); padding:0.25rem 0.45rem; border-radius:0.35rem; font-weight:700; font-size:0.8rem; }
.product-actions { gap:0.35rem; }
.product-actions .btn-primary { background-color: var(--brand-dark); border-color: var(--brand-dark); color: #ffffff; }
.product-actions .btn-outline-secondary {
  background-color: var(--brand-dark);
  color: #ffffff;
  border-color: var(--brand-dark);
}
.product-actions .btn-outline-secondary:hover,
.product-actions .btn-outline-secondary:focus {
  background-color: #012b4a;
  color: #ffffff;
  border-color: #012b4a;
}
.compatible-fandoms { display:flex; flex-wrap:wrap; gap:0.5rem; }
.compatible-fandoms a.category-button {
  border-radius: 0.35rem;
  background: var(--brand-accent);
  color: var(--brand-dark);
  padding: 0.25rem 0.5rem;
  font-weight: 700;
  font-size: 0.85rem;
  border: none;
  text-decoration: none;
  display: inline-block;
}
.compatible-fandoms a.category-button:hover {
  background: #5b98bb; /* slightly darker accent on hover */
  color: var(--brand-dark);
  text-decoration: none;
}

/* Modal image styling */
#productImageModal .modal-body { padding:0; }
#productImageModal img { width:100%; height:auto; display:block; }

/* Tidy up small devices */
@media (max-width: 576px) {
  .product-thumb { height:160px; }
}

/* Quick view modal styles */
.quickview-image { width: 100%; height: 320px; object-fit: contain; background: #fff; border: 1px solid #eee; padding: 8px; }
.quickview-meta { padding-left: 1rem; }
.quickview-price { font-size: 1.25rem; font-weight: 800; color: #111; margin-bottom: 0.5rem; }
.quickview-qty { max-width: 120px; }

/* Quick View modal header: match AD Admin titlebar colors */
#productQuickViewModal .modal-header {
  background-color: #001f3f !important;
  color: #ffffff !important;
}
#productQuickViewModal .modal-title {
  color: #6CA6CD !important;
}
/* Product modals use dark headers in both themes, so render a text-based white close icon. */
#productQuickViewModal .btn-close,
#productDetailsModal .btn-close,
#customizeNewModal .btn-close,
#customizeFandomModal .btn-close,
#createFandomModal .btn-close,
#createCharacterModal .btn-close {
  border: none !important;
  box-shadow: none !important;
  filter: none !important;
  opacity: 1 !important;
  background: transparent !important;
  background-image: none !important;
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#productQuickViewModal .btn-close::before,
#productDetailsModal .btn-close::before,
#customizeNewModal .btn-close::before,
#customizeFandomModal .btn-close::before,
#createFandomModal .btn-close::before,
#createCharacterModal .btn-close::before {
  content: "×" !important;
  color: #ffffff !important;
  font-size: 22px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
}

#productQuickViewModal .btn-close::after,
#productDetailsModal .btn-close::after,
#customizeNewModal .btn-close::after,
#customizeFandomModal .btn-close::after,
#createFandomModal .btn-close::after,
#createCharacterModal .btn-close::after {
  display: none !important;
}

/* Details modal header: match AD Admin titlebar colors */
#productDetailsModal .modal-header {
  background-color: var(--brand-dark) !important;
  color: #ffffff !important;
}
#productDetailsModal .modal-title {
  color: var(--brand-accent) !important;
}
/* Customize modals: match the same AD Admin titlebar styling */
#customizeNewModal .modal-header,
#customizeFandomModal .modal-header {
  background-color: var(--brand-dark) !important;
  color: #ffffff !important;
}
#customizeNewModal .modal-title,
#customizeFandomModal .modal-title {
  color: var(--brand-accent) !important;
}
/* Create Fandom modal should follow same titlebar styling */
#createFandomModal .modal-header {
  background-color: var(--brand-dark) !important;
  color: #ffffff !important;
}
#createFandomModal .modal-title {
  color: var(--brand-accent) !important;
}

/* Create Character modal should follow same titlebar styling */
#createCharacterModal .modal-header {
  background-color: var(--brand-dark) !important;
  color: #ffffff !important;
}
#createCharacterModal .modal-title {
  color: var(--brand-accent) !important;
}

/* Dark theme overrides: ensure page title is readable on dark backgrounds */
body.dark-theme .page-title {
  color: #F5EBFF;
}

/* Dark-theme product overrides: ensure product cards match dark theme */
body.dark-theme .product-grid .product-card {
  background-color: var(--card-bg) !important;
  color: var(--card-text) !important;
  border: 1px solid var(--card-border) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45) !important;
}

body.dark-theme .product-grid .product-card:hover {
  background-color: rgba(255,255,255,0.02) !important;
  border-color: var(--menu-link-hover-color) !important;
  transform: translateY(-4px) !important;
}

body.dark-theme .product-grid .product-card .product-title {
  color: var(--card-text, #FFFFFF) !important;
}

body.dark-theme .product-grid .product-card .product-sub,
body.dark-theme .product-grid .product-card .product-price {
  color: var(--card-subtext) !important;
}

body.dark-theme .product-actions .btn,
body.dark-theme .product-card .btn-primary,
body.dark-theme .product-card .btn {
  background-color: #4B0082 !important;
  border-color: #4B0082 !important;
  color: var(--card-text) !important;
  border-radius: 0.5rem !important;
}

body.dark-theme .product-actions .customize-new-btn {
  background-color: #4B0082 !important;
  border-color: #4B0082 !important;
  color: var(--card-subtext) !important;
  border-radius: 0.5rem !important;
}

body.dark-theme .product-badge {
  background-color: #E9D8F7 !important;
  color: #4B0082 !important;
  border: 1px solid rgba(75,0,130,0.06) !important;
  padding: 0.15rem 0.45rem !important;
  border-radius: 0.375rem !important;
  font-weight: 600;
}

/* Ensure product page buttons and badges follow the dark theme when active */
body.dark-theme .product-card .product-badge,
body.dark-theme .product-box .product-badge,
body.dark-theme .product-card .badge:not(.bg-danger),
body.dark-theme .product-box .badge:not(.bg-danger) {
    background-color: #E9D8F7 !important;
    color: #4B0082 !important;
    border: 1px solid rgba(75,0,130,0.06) !important;
}

body.dark-theme .product-card .product-actions .btn,
body.dark-theme .product-card .btn-primary,
body.dark-theme .product-card .btn,
body.dark-theme .product-box .btn {
    background-color: #4B0082 !important;
    border-color: #4B0082 !important;
    color: #F5EBFF !important;
    border-radius: 0.5rem !important;
}

body.dark-theme .product-card .product-actions .customize-new-btn {
    background-color: #4B0082 !important;
    border-color: #4B0082 !important;
    color: var(--card-subtext, rgba(245,235,255,0.9)) !important;
}

body.dark-theme .terrarium-preview-image,
body.light-theme .terrarium-preview-image {
    background-color: #2f343a !important;
    filter: grayscale(1) brightness(0.55) contrast(0.95) !important;
}

/* Force product modal headers to match navbar/footer purple and use white title text */
body.dark-theme #productQuickViewModal .modal-header,
body.dark-theme #productDetailsModal .modal-header,
body.dark-theme #customizeNewModal .modal-header,
body.dark-theme #customizeFandomModal .modal-header,
body.dark-theme #createFandomModal .modal-header,
body.dark-theme #createCharacterModal .modal-header {
    background-color: #4B0082 !important;
    color: #ffffff !important;
    border-bottom: 1px solid rgba(245,235,255,0.04) !important;
}

body.dark-theme #productQuickViewModal .modal-title,
body.dark-theme #productDetailsModal .modal-title,
body.dark-theme #customizeNewModal .modal-title,
body.dark-theme #customizeFandomModal .modal-title,
body.dark-theme #createFandomModal .modal-title,
body.dark-theme #createCharacterModal .modal-title {
    color: #ffffff !important;
}

/* Make the close button transparent and render a bold white × (remove Bootstrap background image) */
body.dark-theme .modal-header .btn-close {
    background: transparent !important;
    background-image: none !important;
    border: none !important;
    box-shadow: none !important;
    filter: none !important;
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

body.dark-theme .modal-header .btn-close::before {
    content: "×" !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 22px !important;
    line-height: 1 !important;
}

body.dark-theme .modal-header .btn-close::after { display: none !important; }

/* More specific overrides for product modals to beat ID-scoped rules in packaged CSS */
body.dark-theme #productQuickViewModal .modal-header .btn-close,
body.dark-theme #productDetailsModal .modal-header .btn-close,
body.dark-theme #customizeNewModal .modal-header .btn-close,
body.dark-theme #customizeFandomModal .modal-header .btn-close,
body.dark-theme #createFandomModal .modal-header .btn-close,
body.dark-theme #createCharacterModal .modal-header .btn-close {
    background: transparent !important;
    background-image: none !important;
    border: none !important;
    box-shadow: none !important;
    filter: none !important;
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

body.dark-theme #productQuickViewModal .modal-header .btn-close::before,
body.dark-theme #productDetailsModal .modal-header .btn-close::before,
body.dark-theme #customizeNewModal .modal-header .btn-close::before,
body.dark-theme #customizeFandomModal .modal-header .btn-close::before,
body.dark-theme #createFandomModal .modal-header .btn-close::before,
body.dark-theme #createCharacterModal .modal-header .btn-close::before {
    content: "×" !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 22px !important;
    line-height: 1 !important;
}

body.dark-theme #productQuickViewModal .modal-header .btn-close::after,
body.dark-theme #productDetailsModal .modal-header .btn-close::after,
body.dark-theme #customizeNewModal .modal-header .btn-close::after,
body.dark-theme #customizeFandomModal .modal-header .btn-close::after,
body.dark-theme #createFandomModal .modal-header .btn-close::after,
body.dark-theme #createCharacterModal .modal-header .btn-close::after { display: none !important; }

/* Utility class extracted from inline style attributes in product_table.html */
.product-config-flex-item {
    flex: 1;
}

.product-link { text-decoration: none !important; color: inherit !important; display: block; }
        .product-container {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 1.25rem;
            align-items: start;
            margin-top: 1.5rem;
        }
        .product-box {
            border: 1px solid var(--card-border, #cbd5e1);
            border-radius: 0.5rem;
            padding: 1.25rem;
            min-height: 180px; /* slightly taller cards */
            display: flex;
            flex-direction: column;
            justify-content: center;
            background-color: var(--card-bg, #eef6fb); /* theme-aware */
            color: var(--card-text, #001f3f);
            box-shadow: 0 3px 10px rgba(0,0,0,0.04);
            transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background-color .12s ease;
            text-align: center;
        }
        .product-box h2 { margin: 0 0 0.5rem 0; font-size: 1.18rem; line-height: 1.2; color: var(--product-title-color, #001f3f); }
        .product-box p { margin: 0; color: var(--product-sub-color, #214a5a); font-size: 0.98rem; }
        .product-link:hover .product-box,
        .product-link:focus .product-box {
            transform: translateY(-4px);
            border-color: var(--menu-link-hover-color, #6CA6CD) !important; /* admin accent fallback */
            background-color: rgba(255,255,255,0.02) !important;
            box-shadow: 0 10px 26px rgba(0,0,0,0.08);
        }

        /* Ensure inline template styles respect dark theme variables if body has the class */
        body.dark-theme .product-box {
            background-color: var(--card-bg) !important;
            color: var(--card-text) !important;
            border-color: var(--card-border) !important;
            box-shadow: 0 2px 8px rgba(0,0,0,0.45) !important;
        }
        body.dark-theme .product-box h2 { color: var(--card-text, #FFFFFF) !important; }
        body.dark-theme .product-box p { color: var(--card-subtext) !important; }

        .products-page { padding-bottom: 10px; box-sizing: border-box; }
