/**
 * accessibility-improvements.css
 * Fixes for WCAG AA compliance and mobile responsiveness
 * Sprint 1: Accessibility & Mobile
 */

/* Custom elements are inline by default; these components are page regions. */
custom-topbar,
custom-navbar,
custom-footer,
custom-breadcrumb {
    display: block;
    width: 100%;
}

/* ===== COLOR CONTRAST FIXES ===== */

/* Badge improvements - darker backgrounds for better contrast */
.badge {
    font-weight: 600;
    padding: 6px 10px !important;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Header badges styling - override global badge padding and enforce perfect circles */
custom-topbar a .badge,
custom-navbar a .badge {
    position: absolute !important;
    top: -5px !important;
    right: -8px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    min-width: 16px !important;
    min-height: 16px !important;
    width: 16px !important;
    height: 16px !important;
    font-size: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: #fff !important;
    color: #2F8F61 !important; /* Brand green text */
    border: none !important; /* Remove borders */
    box-shadow: 0 1px 3px rgba(0,0,0,0.15) !important;
}

.badge-success,
.badge-info,
.badge-danger {
    color: #fff !important;
}

.badge-success {
    background-color: #28a745 !important;
}

.badge-info {
    background-color: #0056b3 !important;
}

.badge-danger {
    background-color: #c82333 !important;
}

/* Button hover states for visibility */
.btn-outline-dark:hover,
.btn-outline-dark:focus {
    outline: 2px solid #2F8F61;
    outline-offset: 2px;
}

/* ===== FOCUS STATES (KEYBOARD NAVIGATION) ===== */

/* Remove default outline and add custom one */
*:focus {
    outline-width: 2px;
    outline-offset: 2px;
    outline-color: #2F8F61;
}

/* Navigation focus states */
.nav-link:focus,
.dropdown-item:focus {
    outline: 2px solid #2F8F61;
    outline-offset: -2px;
}

/* Button focus states */
button:focus {
    outline: 2px solid #2F8F61;
    outline-offset: 2px;
}

/* Link focus states */
a:focus {
    outline: 2px solid #2F8F61;
    outline-offset: 2px;
}

/* ===== SKIP LINK (KEYBOARD NAVIGATION) ===== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #2F8F61;
    color: white;
    padding: 8px;
    z-index: 9999;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

/* ===== THEME TOGGLE BUTTON ===== */

#theme-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    padding: 10px 15px;
    background-color: #2F8F61;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

#theme-toggle-btn:hover {
    background-color: #1e6a47;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

#theme-toggle-btn:focus {
    outline: 2px solid #2F8F61;
    outline-offset: 2px;
}

#theme-toggle-btn i {
    font-size: 1rem;
}

/* Stack back-to-top above the theme toggle so they don't collide in the corner */
.back-to-top {
    bottom: 84px !important;
    right: 20px !important;
    z-index: 999;
}

@media (max-width: 576px) {
    #theme-toggle-btn {
        bottom: 15px;
        right: 15px;
        /* Icon-only circle on mobile — small footprint, stops covering headers */
        width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 50%;
        gap: 0;
        justify-content: center;
        font-size: 0.8rem;
    }

    #theme-toggle-btn .tt-label {
        display: none;
    }

    .back-to-top {
        bottom: 70px !important;
        right: 15px !important;
    }
}

/* ===== MOBILE RESPONSIVENESS ===== */

/* Ensure search is visible on mobile */
@media (max-width: 768px) {
    .navbar-collapse {
        background-color: #343a40;
        padding: 15px;
    }

    .navbar-toggler {
        min-height: 44px;
        min-width: 44px;
        padding: 8px;
    }

    /* Increase tap target sizes to 44x44px minimum */
    .btn {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-square {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    /* Make carousel responsive */
    #header-carousel {
        height: auto !important;
    }

    .carousel-item {
        height: auto !important;
        min-height: 300px !important;
    }

    .carousel-item img {
        max-height: 300px;
    }

    /* Keep CTA clear of the indicators on the short mobile carousel */
    #header-carousel .carousel-caption {
        z-index: 16;
        padding-bottom: 2.5rem;
    }

    #header-carousel .carousel-indicators {
        bottom: 4px;
        margin-bottom: 0;
    }

    /* Product card improvements on mobile */
    .product-item {
        margin-bottom: 15px;
    }

    .product-img {
        height: 200px !important;
    }

    /* Improve badge visibility on mobile */
    .product-item .badge {
        font-size: 0.7rem !important;
        padding: 4px 6px !important;
    }
}

@media (max-width: 576px) {
    .carousel-item {
        min-height: 250px !important;
    }

    .carousel-item img {
        max-height: 250px;
    }

    .h1,
    .h2,
    .h3,
    .h4,
    .h5,
    .h6 {
        font-size: 1rem;
    }

    /* Ensure readable font sizes */
    body {
        font-size: 15px;
    }

    .product-img {
        height: 180px !important;
    }
}

/* ===== FORM ACCESSIBILITY ===== */

label {
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #2F8F61;
    outline-offset: 2px;
    border-color: #2F8F61 !important;
}

/* ===== BREADCRUMB ACCESSIBILITY ===== */

.breadcrumb {
    padding: 12px 15px;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: " / ";
}

/* ===== MODAL ACCESSIBILITY ===== */

.modal-header .close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== PRINT STYLES ===== */

@media print {
    .navbar,
    .footer,
    .back-to-top {
        display: none;
    }
}

/* ===== CATEGORY CARDS LIGHT MODE DEFAULTS & HOVER CONTRAST FIXES ===== */
.cat-item {
    background-color: #f8f9fa !important;
    border-color: #e0e0e0 !important;
    transition: background-color 0.3s ease, border-color 0.3s ease !important;
}

.cat-item div.overflow-hidden {
    background-color: #fff !important;
    border-color: #e0e0e0 !important;
    transition: background-color 0.3s ease, border-color 0.3s ease !important;
}

/* Enforce high text contrast when hovering over category card */
.cat-item:hover .text-dark,
.cat-item:hover h6 {
    color: #fff !important;
}

.cat-item:hover .text-muted,
.cat-item:hover small {
    color: #e8e8e8 !important;
}

/* ===== THEME (data-theme single source of truth) =====
 * theme-toggle.js always sets data-theme="light" | "dark" on <html>,
 * so the theme is driven entirely by this attribute. Do NOT key theme
 * colors off @media (prefers-color-scheme): the OS setting would override
 * the manual toggle and leak the wrong palette (e.g. dark-mode light text
 * onto a light background), making content unreadable.
 */

/* ===== LIGHT THEME ===== */

[data-theme="light"] {
    color-scheme: light;
}

[data-theme="light"] body {
    background-color: #fff !important;
    color: #333 !important;
}

[data-theme="light"] .bg-light {
    background-color: #f8f9fa !important;
}

[data-theme="light"] .bg-dark {
    background-color: #343a40 !important;
}

[data-theme="light"] .bg-secondary {
    background-color: #6c757d !important;
}

[data-theme="light"] .text-dark {
    color: #333 !important;
}

[data-theme="light"] .text-muted {
    color: #6c757d !important;
}

[data-theme="light"] .text-body {
    color: #333 !important;
}

[data-theme="light"] .text-secondary {
    color: #6c757d !important;
}

[data-theme="light"] h1,
[data-theme="light"] h2,
[data-theme="light"] h3,
[data-theme="light"] h4,
[data-theme="light"] h5,
[data-theme="light"] h6 {
    color: #333 !important;
}

[data-theme="light"] .font-weight-bold {
    color: #333 !important;
}

[data-theme="light"] a {
    color: #2F8F61 !important;
}

[data-theme="light"] a:hover {
    color: #1e6a47 !important;
}

[data-theme="light"] .card {
    background-color: #fff !important;
    border-color: #dee2e6 !important;
    color: #333 !important;
}

[data-theme="light"] .form-control,
[data-theme="light"] .form-control:focus {
    background-color: #fff !important;
    color: #333 !important;
    border-color: #ced4da !important;
}

[data-theme="light"] .input-group-text {
    background-color: #e9ecef !important;
    border-color: #ced4da !important;
    color: #333 !important;
}

[data-theme="light"] .table {
    color: #333 !important;
}

[data-theme="light"] .table-light {
    background-color: #f8f9fa !important;
}

[data-theme="light"] .dropdown-menu {
    background-color: #fff !important;
    border-color: #dee2e6 !important;
}

[data-theme="light"] .dropdown-item {
    color: #333 !important;
}

[data-theme="light"] .dropdown-item:hover,
[data-theme="light"] .dropdown-item:focus {
    background-color: #f1f3f5 !important;
    color: #111 !important;
}

[data-theme="light"] .breadcrumb {
    background-color: #f8f9fa !important;
}

[data-theme="light"] .breadcrumb-item.active {
    color: #6c757d !important;
}

[data-theme="light"] .modal-content {
    background-color: #fff !important;
    border-color: #dee2e6 !important;
    color: #333 !important;
}

[data-theme="light"] .modal-header {
    border-color: #dee2e6 !important;
}

[data-theme="light"] .alert {
    color: inherit;
}

[data-theme="light"] .product-item {
    background-color: #fff !important;
    border-color: #dee2e6 !important;
}

[data-theme="light"] .product-item h5,
[data-theme="light"] .product-item h6,
[data-theme="light"] .product-item .text-dark {
    color: #333 !important;
}

[data-theme="light"] .section-title {
    color: #333 !important;
}

[data-theme="light"] .section-title span {
    background-color: #f0f0f0 !important;
    color: #333 !important;
}

[data-theme="light"] .product-action {
    background-color: rgba(255, 255, 255, 0.9) !important;
}

[data-theme="light"] .product-action .fa,
[data-theme="light"] .product-action i {
    color: #333 !important;
}

[data-theme="light"] .btn-outline-dark {
    color: #333 !important;
    border-color: #999 !important;
    background-color: transparent !important;
}

[data-theme="light"] .btn-outline-dark:hover,
[data-theme="light"] .btn-outline-dark:focus {
    background-color: #2F8F61 !important;
    color: white !important;
    border-color: #2F8F61 !important;
}

[data-theme="light"] .cat-item {
    background-color: #f8f9fa !important;
    border-color: #e0e0e0 !important;
}

[data-theme="light"] .cat-item:hover {
    background-color: #2F8F61 !important;
}

[data-theme="light"] .cat-item div.overflow-hidden {
    background-color: #fff !important;
    border-color: #e0e0e0 !important;
}

/* ===== DARK THEME ===== */

[data-theme="dark"] {
    color-scheme: dark;
}

[data-theme="dark"] body {
    background-color: #111714 !important;
    color: #f1f5f3 !important;
}

[data-theme="dark"] .bg-light,
[data-theme="dark"] .bg-white {
    background-color: #202a25 !important;
}

[data-theme="dark"] .bg-dark {
    background-color: #0d0d0d !important;
}

[data-theme="dark"] .bg-secondary {
    background-color: #19211d !important;
}

[data-theme="dark"] .text-dark {
    color: #f1f5f3 !important;
}

[data-theme="dark"] .text-muted {
    color: #b7c0bb !important;
}

[data-theme="dark"] .text-body {
    color: #e8e8e8 !important;
}

[data-theme="dark"] .text-secondary {
    color: #b0b0b0 !important;
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6 {
    color: #e8e8e8 !important;
}

[data-theme="dark"] .font-weight-bold {
    color: #e8e8e8 !important;
}

[data-theme="dark"] a {
    color: #69c99a !important;
}

[data-theme="dark"] a:hover {
    color: #8bdcaf !important;
}

[data-theme="dark"] .navbar-dark {
    background-color: #1a1a1a !important;
    border-color: #333 !important;
}

[data-theme="dark"] .card {
    background-color: #202a25 !important;
    border-color: #3b4a43 !important;
    color: #f1f5f3 !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-control:focus {
    background-color: #19211d !important;
    color: #f1f5f3 !important;
    border-color: #53635b !important;
}

[data-theme="dark"] .form-control::placeholder {
    color: #929e98 !important;
    opacity: 1;
}

[data-theme="dark"] .border,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-right,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-left,
[data-theme="dark"] hr {
    border-color: #3b4a43 !important;
}

[data-theme="dark"] .input-group-text {
    background-color: #333 !important;
    border-color: #555 !important;
    color: #e8e8e8 !important;
}

[data-theme="dark"] .table {
    color: #e8e8e8 !important;
}

[data-theme="dark"] .table-light {
    background-color: #2a2a2a !important;
}

[data-theme="dark"] .thead-dark {
    background-color: #1a1a1a !important;
    color: #e8e8e8 !important;
}

[data-theme="dark"] .badge {
    color: #fff !important;
}

[data-theme="dark"] custom-topbar a .badge,
[data-theme="dark"] custom-navbar a .badge {
    background-color: #2F8F61 !important;
    color: #fff !important;
}

[data-theme="dark"] .badge-light {
    background-color: #444 !important;
    color: #e8e8e8 !important;
}

[data-theme="dark"] .dropdown-menu {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
}

[data-theme="dark"] .dropdown-item {
    color: #e8e8e8 !important;
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background-color: #3a3a3a !important;
    color: #fff !important;
}

[data-theme="dark"] .breadcrumb {
    background-color: #2a2a2a !important;
}

[data-theme="dark"] .breadcrumb-item a {
    color: #4a9eff !important;
}

[data-theme="dark"] .breadcrumb-item.active {
    color: #b0b0b0 !important;
}

[data-theme="dark"] .modal-content {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
    color: #e8e8e8 !important;
}

[data-theme="dark"] .modal-header {
    border-color: #444 !important;
}

[data-theme="dark"] .carousel-caption {
    background: rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .alert {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
    color: #e8e8e8 !important;
}

[data-theme="dark"] .footer,
[data-theme="dark"] footer {
    background-color: #0d0d0d !important;
    color: #e8e8e8 !important;
}

[data-theme="dark"] .product-item {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
}

[data-theme="dark"] .product-item h5,
[data-theme="dark"] .product-item h6,
[data-theme="dark"] .product-item .text-dark {
    color: #e8e8e8 !important;
}

[data-theme="dark"] .product-item .font-weight-bold {
    color: #e8e8e8 !important;
}

[data-theme="dark"] .section-title {
    color: #e8e8e8 !important;
}

[data-theme="dark"] .section-title span {
    background-color: #333 !important;
    color: #e8e8e8 !important;
    padding-right: 12px !important;
}

[data-theme="dark"] #categories-container .badge,
[data-theme="dark"] #categories-container .btn {
    background-color: #2F8F61 !important;
    color: white !important;
    border-color: #2F8F61 !important;
}

[data-theme="dark"] #categories-container .badge:hover,
[data-theme="dark"] #categories-container .btn:hover {
    background-color: #1e6a47 !important;
}

[data-theme="dark"] .product-action {
    background-color: rgba(0, 0, 0, 0.7) !important;
}

[data-theme="dark"] .product-action .fa,
[data-theme="dark"] .product-action i {
    color: #e8e8e8 !important;
}

[data-theme="dark"] .btn-outline-dark {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #e8e8e8 !important;
    border-color: #555 !important;
}

[data-theme="dark"] .btn-outline-dark:hover,
[data-theme="dark"] .btn-outline-dark:focus {
    background-color: #2F8F61 !important;
    color: white !important;
    border-color: #2F8F61 !important;
}

[data-theme="dark"] .cat-item {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
}

[data-theme="dark"] .cat-item:hover {
    background-color: #2F8F61 !important;
}

[data-theme="dark"] .cat-item div.overflow-hidden {
    background-color: #1a1a1a !important;
    border-color: #444 !important;
}

#mobile-filter-bar {
    background-color: #fff;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

/* Custom control labels and checkbox inputs in dark mode */
[data-theme="dark"] .custom-control-label {
    color: #e8e8e8 !important;
}

[data-theme="dark"] .custom-control-label::before {
    background-color: #333 !important;
    border-color: #555 !important;
}

[data-theme="dark"] .custom-control-input:checked ~ .custom-control-label::before {
    background-color: #2F8F61 !important;
    border-color: #2F8F61 !important;
}

/* Badge border in dark mode */
[data-theme="dark"] .badge.border {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
    color: #b0b0b0 !important;
}

/* Outline secondary button styling in dark mode */
[data-theme="dark"] .btn-outline-secondary {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #e8e8e8 !important;
    border-color: #555 !important;
}

[data-theme="dark"] .btn-outline-secondary:hover,
[data-theme="dark"] .btn-outline-secondary:focus {
    background-color: #2F8F61 !important;
    color: white !important;
    border-color: #2F8F61 !important;
}

[data-theme="dark"] .btn-outline-secondary:active,
[data-theme="dark"] .btn-outline-secondary.active {
    background-color: #1e6a47 !important;
    color: white !important;
    border-color: #1e6a47 !important;
}

/* Button light styling in dark mode */
[data-theme="dark"] .btn-light {
    background-color: #333 !important;
    color: #e8e8e8 !important;
    border-color: #555 !important;
}

[data-theme="dark"] .btn-light:hover,
[data-theme="dark"] .btn-light:focus {
    background-color: #444 !important;
    color: #fff !important;
    border-color: #666 !important;
}

/* Custom select options styling in dark mode */
[data-theme="dark"] select.form-control option {
    background-color: #333 !important;
    color: #e8e8e8 !important;
}

/* Mobile filter bar container override */
[data-theme="dark"] #mobile-filter-bar {
    background-color: #2a2a2a !important;
    border-top-color: #444 !important;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.5) !important;
}


/* ===== TEXT OVER IMAGES (carousel + offer overlays) =====
 * These captions/overlays sit on top of photos and must stay light in
 * BOTH themes. The data-theme heading/text rules above (e.g. light h1->#333)
 * outrank Bootstrap's .text-white, so they would otherwise darken caption
 * text into illegibility over the image. Restore white + add a shadow for
 * contrast against busy photo backgrounds.
 */

[data-theme="light"] .text-white,
[data-theme="dark"] .text-white,
[data-theme="light"] .carousel-caption,
[data-theme="light"] .carousel-caption h1,
[data-theme="light"] .carousel-caption h2,
[data-theme="light"] .carousel-caption h3,
[data-theme="light"] .carousel-caption h4,
[data-theme="light"] .carousel-caption h5,
[data-theme="light"] .carousel-caption h6,
[data-theme="light"] .carousel-caption p,
[data-theme="light"] .offer-text,
[data-theme="light"] .offer-text h3,
[data-theme="light"] .offer-text h6 {
    color: #fff !important;
}

.carousel-caption,
.offer-text {
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}


/* ===== PAGINATION ===== */

.pagination .page-link {
    color: #2F8F61;
    border-color: #dee2e6;
}

.pagination .page-item.active .page-link {
    background-color: #2F8F61;
    border-color: #2F8F61;
    color: #fff;
}

.pagination .page-link:hover {
    color: #1e6a47;
    background-color: #f1f3f5;
}

.pagination .page-item.disabled .page-link {
    color: #adb5bd;
}

[data-theme="dark"] .pagination .page-link {
    background-color: #2a2a2a;
    border-color: #444;
    color: #4a9eff;
}

[data-theme="dark"] .pagination .page-item.active .page-link {
    background-color: #2F8F61;
    border-color: #2F8F61;
    color: #fff;
}

[data-theme="dark"] .pagination .page-link:hover {
    background-color: #333;
    color: #6bb3ff;
}

[data-theme="dark"] .pagination .page-item.disabled .page-link {
    background-color: #1a1a1a;
    color: #666;
    border-color: #444;
}


/* ===== TOAST NOTIFICATIONS ===== */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: calc(100% - 40px);
    max-width: 360px;
    pointer-events: none;
}

.app-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #fff;
    color: #333;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    border-left: 4px solid #6c757d;
    font-size: 0.9rem;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

.app-toast-show {
    opacity: 1;
    transform: translateX(0);
}

.app-toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.app-toast-msg {
    flex: 1;
    line-height: 1.3;
}

.app-toast-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    padding: 0 2px;
    flex-shrink: 0;
}

.app-toast-close:hover {
    opacity: 1;
}

.app-toast-success { border-left-color: #28a745; }
.app-toast-success .app-toast-icon { color: #28a745; }
.app-toast-error { border-left-color: #dc3545; }
.app-toast-error .app-toast-icon { color: #dc3545; }
.app-toast-warning { border-left-color: #ffc107; }
.app-toast-warning .app-toast-icon { color: #e0a800; }
.app-toast-info { border-left-color: #2F8F61; }
.app-toast-info .app-toast-icon { color: #2F8F61; }

[data-theme="dark"] .app-toast {
    background: #2a2a2a;
    color: #e8e8e8;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

@media (max-width: 576px) {
    #toast-container {
        top: auto;
        bottom: 80px; /* clear the floating theme-toggle button */
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

/* Cart/wishlist badge bump — toggled by JS after add-to-cart */
@keyframes badge-bump {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.4); }
    60%  { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.badge-bump {
    animation: badge-bump 0.4s ease;
}


/* ===== SEARCH AUTOCOMPLETE ===== */

.search-autocomplete {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    max-height: 360px;
    overflow-y: auto;
}

.search-autocomplete-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #f1f3f5;
}

.search-autocomplete-item:last-child {
    border-bottom: none;
}

.search-autocomplete-item:hover,
.search-autocomplete-item.active {
    background: #f1f3f5;
    color: #111;
    text-decoration: none;
}

.search-autocomplete-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.search-autocomplete-name {
    flex: 1;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-autocomplete-price {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2F8F61;
    flex-shrink: 0;
}

.search-autocomplete-empty {
    padding: 12px;
    text-align: center;
    color: #6c757d;
    font-size: 0.88rem;
}

[data-theme="dark"] .search-autocomplete {
    background: #2a2a2a;
    border-color: #444;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .search-autocomplete-item {
    color: #e8e8e8;
    border-bottom-color: #3a3a3a;
}

[data-theme="dark"] .search-autocomplete-item:hover,
[data-theme="dark"] .search-autocomplete-item.active {
    background: #3a3a3a;
    color: #fff;
}

[data-theme="dark"] .search-autocomplete-empty {
    color: #b0b0b0;
}


/* ===== HIGH CONTRAST MODE SUPPORT ===== */

@media (prefers-contrast: more) {
    .badge {
        border: 2px solid currentColor;
    }

    button,
    a {
        text-decoration: underline;
    }
}

/* ===== REDUCE MOTION SUPPORT ===== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .carousel {
        animation: none;
    }
}

/* ===== PRODUCT PAGE DARK MODE ===== */

[data-theme="dark"] .product-gallery-main {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
}

[data-theme="dark"] .thumbnail-item {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
}

[data-theme="dark"] .thumbnail-item:hover,
[data-theme="dark"] .thumbnail-item.active {
    border-color: #2F8F61 !important;
}

[data-theme="dark"] .qty-control {
    border-color: #555 !important;
}

[data-theme="dark"] .qty-control button {
    background-color: #333 !important;
    color: #e8e8e8 !important;
}

[data-theme="dark"] .qty-control button:hover {
    background-color: #444 !important;
}

[data-theme="dark"] .qty-control input {
    background-color: #2a2a2a !important;
    color: #e8e8e8 !important;
}

[data-theme="dark"] .btn-wishlist {
    background-color: #2a2a2a !important;
    border-color: #555 !important;
    color: #e8e8e8 !important;
}

[data-theme="dark"] .btn-wishlist:hover,
[data-theme="dark"] .btn-wishlist.in-wishlist {
    border-color: #e74c3c !important;
    color: #e74c3c !important;
}

[data-theme="dark"] .review-card {
    background-color: #2a2a2a !important;
    border-left-color: #2F8F61 !important;
}

[data-theme="dark"] .review-author {
    color: #e8e8e8 !important;
}

[data-theme="dark"] .review-text {
    color: #b0b0b0 !important;
}

[data-theme="dark"] .review-form-card {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
}

[data-theme="dark"] .star-rating-input label {
    color: #555 !important;
}

[data-theme="dark"] .star-rating-input input:checked ~ label,
[data-theme="dark"] .star-rating-input label:hover,
[data-theme="dark"] .star-rating-input label:hover ~ label {
    color: #ffc107 !important;
}

[data-theme="dark"] .divider {
    border-top-color: #444 !important;
}

[data-theme="dark"] #pd-back-link {
    color: #b0b0b0 !important;
}

[data-theme="dark"] #pd-back-link:hover {
    color: #e8e8e8 !important;
}

.card-qty-input::-webkit-outer-spin-button,
.card-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

[data-theme="dark"] .card-qty-input {
    background-color: #2a2a2a !important;
    color: #e8e8e8 !important;
    border-color: #555 !important;
}


/* ===== DARK MODE CATEGORY SPACING (theme-agnostic) ===== */

#categories-container .col-lg-3 {
    margin-bottom: 15px;
}

/* ===== STOREFRONT QUALITY PASS ===== */
:root {
    --bt-primary: #2f8f61;
    --bt-primary-strong: #216b48;
    --bt-radius-sm: 6px;
    --bt-radius-md: 10px;
    --bt-radius-lg: 16px;
    --bt-shadow-sm: 0 2px 8px rgba(18, 38, 29, 0.08);
    --bt-shadow-md: 0 12px 30px rgba(18, 38, 29, 0.12);
}

html { scroll-behavior: smooth; }
body { overflow-x: hidden; -webkit-font-smoothing: antialiased; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

a, button, input, select, textarea { touch-action: manipulation; }

:focus:not(:focus-visible) { outline: none; }
:focus-visible {
    outline: 3px solid #2f8f61 !important;
    outline-offset: 3px !important;
}

.product-item {
    border-radius: var(--bt-radius-md);
    overflow: hidden;
    box-shadow: var(--bt-shadow-sm);
}

.quantity .btn,
.btn-remove,
.btn-remove-wishlist,
.btn-add-cart {
    min-height: 44px;
    min-width: 44px;
}
.quantity .qty-input,
.edit-btn,
.delete-btn {
    min-height: 44px;
}
.product-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--bt-shadow-md) !important;
}
.product-img-click:focus-visible {
    outline-offset: -4px !important;
}

.breadcrumb { border-radius: var(--bt-radius-sm); }
.breadcrumb-item.active { font-weight: 600; }

/* Filter drawer shared by catalog and stores on small screens. */
.mobile-filter-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1055;
    background: rgba(0, 0, 0, 0.58);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.mobile-filter-backdrop.is-open { opacity: 1; pointer-events: auto; }
.filter-drawer-header { display: none; }

@media (max-width: 991.98px) {
    .mobile-header-compact {
        position: relative;
        width: 100%;
        max-width: 100vw;
        overflow: visible;
        box-sizing: border-box;
    }
    .navbar-collapse .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    .catalog-filter-sidebar .custom-control {
        min-height: 44px;
        align-items: center !important;
    }
    .mobile-header-compact .icon-btn {
        width: auto;
        height: 44px;
        min-width: 52px;
        padding: 0 8px !important;
        border: 1px solid #4b5560 !important;
        border-radius: 6px;
        background: #1f252a !important;
        color: #fff !important;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    .mobile-header-compact .mobile-action-glyph {
        color: #fff !important;
        font-size: 0.75rem;
        font-weight: 700;
        line-height: 1;
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    .mobile-header-compact .action-icons {
        display: flex !important;
        flex: 0 0 auto;
        gap: 6px !important;
        position: absolute;
        top: 6px;
        right: 15px;
        width: 110px;
        min-width: 110px;
    }
    .mobile-header-compact .logo-area {
        min-width: 0;
        max-width: calc(100% - 130px);
    }
    .mobile-header-compact .logo-area .h3 { font-size: 1rem !important; }

    .catalog-filter-sidebar {
        position: fixed !important;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 1060;
        width: min(88vw, 380px) !important;
        max-width: none !important;
        overflow-y: auto;
        padding: 0 18px 32px !important;
        background: var(--page-bg, #fff);
        transform: translateX(105%);
        transition: transform 0.25s ease;
        box-shadow: -12px 0 32px rgba(0, 0, 0, 0.2);
    }
    .catalog-filter-sidebar.is-open { transform: translateX(0); }
    .filter-drawer-header {
        position: sticky;
        top: 0;
        z-index: 2;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 0 -18px 20px;
        padding: 14px 18px;
        background: inherit;
        border-bottom: 1px solid #dee2e6;
    }
    .filter-drawer-close { width: 44px; height: 44px; border-radius: 50%; }
    body.filter-drawer-open { overflow: hidden; }
    #mobile-filter-bar { padding-bottom: max(10px, env(safe-area-inset-bottom)) !important; }
    #mobile-filter-bar .btn { min-height: 48px; }
}

#header-carousel .btn-outline-light {
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.9) !important;
}
#header-carousel .btn-outline-light:hover,
#header-carousel .btn-outline-light:focus-visible {
    color: #1b2a23 !important;
    background: #fff !important;
}

/* Convert commerce tables into readable cards instead of hidden horizontal UI. */
@media (max-width: 767.98px) {
    .commerce-table-responsive { overflow: visible !important; }
    .commerce-table-responsive table,
    .commerce-table-responsive tbody,
    .commerce-table-responsive tr,
    .commerce-table-responsive td { display: block; width: 100%; }
    .commerce-table-responsive thead { display: none; }
    .commerce-table-responsive tr {
        margin-bottom: 16px;
        padding: 14px;
        border: 1px solid #dee2e6 !important;
        border-radius: var(--bt-radius-md);
        background: var(--surface-bg, #fff);
        box-shadow: var(--bt-shadow-sm);
    }
    .commerce-table-responsive td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        min-height: 48px;
        padding: 8px 0 !important;
        text-align: right !important;
        border: 0 !important;
    }
    .commerce-table-responsive td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: #6c757d;
        font-size: 0.78rem;
        font-weight: 700;
        text-transform: uppercase;
    }
    .commerce-table-responsive td.product-cell {
        justify-content: flex-start;
        text-align: left !important;
        border-bottom: 1px solid #dee2e6 !important;
    }
    .commerce-table-responsive td.product-cell::before { display: none; }
    .commerce-table-responsive .empty-commerce-cell {
        display: block;
        text-align: center !important;
        border: 0 !important;
    }
    .commerce-table-responsive .empty-commerce-cell::before { display: none; }
}

[data-theme="dark"] .catalog-filter-sidebar { background: #181818; }
[data-theme="dark"] .commerce-table-responsive tr { background: #262626; border-color: #444 !important; }
[data-theme="dark"] .filter-drawer-header { border-color: #444; }
