/* Premium Dark Mode Design System */
:root[data-bs-theme="dark"] {
    /* Brand Colors */
    --bs-primary: #4EE84E;
    --bs-primary-rgb: 78, 232, 78;

    /* Background Colors */
    --bs-body-bg: #141417;
    --bg-darker: #0D0D0F;
    --bg-surface: #1E1E24;
    --bg-surface-hover: #2A2A32;

    /* Text Colors */
    --bs-body-color: #F4F4F5;
    --text-muted: #A1A1AA;

    /* Borders */
    --bs-border-color: #2E2E36;
    --bs-border-color-translucent: rgba(255, 255, 255, 0.1);

    /* Utilities */
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(78, 232, 78, 0.3);
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

.d-flex.flex-column.min-vh-100 {
    min-height: 100vh;
}

main.flex-grow-1 {
    flex: 1 0 auto;
}

.footer {
    flex-shrink: 0;
}

h1,
h2,
h3,
h4,
h5,
h6,
.navbar-brand {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Base Utility Classes */
.bg-darker {
    background-color: var(--bg-darker) !important;
}

.bg-surface {
    background-color: var(--bg-surface) !important;
}

.text-secondary {
    color: var(--text-muted) !important;
}

/* Components */
.premium-nav {
    background-color: rgba(9, 9, 11, 0.8) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.model-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.3s ease;
}

.model-card:hover {
    transform: translateY(-5px);
    border-color: rgba(78, 232, 78, 0.5);
    box-shadow: var(--shadow-glow);
}

.model-img-wrapper {
    position: relative;
    width: 100%;
    padding-top: 75%;
    /* 4:3 Aspect Ratio */
    background-color: #27272a;
    overflow: hidden;
}

.model-img-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.model-card:hover .model-img-wrapper img {
    transform: scale(1.05);
}

.btn-primary {
    background: linear-gradient(135deg, #4EE84E 0%, #2CB02C 100%);
    border: none;
    box-shadow: 0 4px 15px rgba(78, 232, 78, 0.3);
    color: #000;
    font-weight: 700;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5DF55D 0%, #36C736 100%);
    box-shadow: var(--shadow-glow);
    color: #000;
    transform: translateY(-1px);
}

/* Badges */
.badge-glass {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Forms */
.form-control,
.form-select {
    background-color: var(--bg-surface);
    border: 1px solid var(--bs-border-color);
    color: var(--bs-body-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-surface-hover);
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(78, 232, 78, 0.25);
    color: var(--bs-body-color);
}

.form-label {
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--radius-lg);
}

.text-danger {
    color: #ff4d4f !important;
}

/* Hover glow for category pills */
.hover-glow {
    transition: all 0.3s ease;
}

.hover-glow:hover {
    border-color: rgba(78, 232, 78, 0.5) !important;
    box-shadow: 0 0 12px rgba(78, 232, 78, 0.2);
    transform: translateY(-2px);
}

/* Dropdown menu darkmode */
.dropdown-menu.bg-surface .dropdown-item {
    color: #e5e5e5;
}

.dropdown-menu.bg-surface .dropdown-item:hover,
.dropdown-menu.bg-surface .dropdown-item:focus {
    background-color: var(--bg-surface-hover);
    color: #fff;
}

/* Table dark theme */
.table-dark {
    --bs-table-bg: var(--bg-surface);
    --bs-table-border-color: var(--bs-border-color);
}

/* Auth pages */
.auth-card {
    background: linear-gradient(145deg, var(--bg-surface) 0%, rgba(18, 18, 20, 0.95) 100%);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(8px);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #52525b;
}

/* Object fit utility */
.object-fit-cover {
    object-fit: cover;
}

.object-fit-contain {
    object-fit: contain;
}

/* Cursor pointer */
.cursor-pointer {
    cursor: pointer;
}

/* Breadcrumb dark mode */
.breadcrumb {
    --bs-breadcrumb-divider-color: #52525b;
    --bs-breadcrumb-item-active-color: #fafafa;
}

/* Input group text */
.input-group-text {
    background-color: var(--bg-surface);
    border-color: var(--bs-border-color);
    color: var(--text-muted);
}

/* Header specific styles */
.header-main .nav-link-top,
.header-main .category-link {
    transition: color 0.2s ease;
}

.header-main .nav-link-top:hover,
.header-main .category-link:hover {
    color: var(--bs-primary) !important;
}

.category-nav::-webkit-scrollbar {
    height: 4px;
}

.category-nav::-webkit-scrollbar-track {
    background: transparent;
}

.category-nav::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 4px;
}

.category-nav::-webkit-scrollbar-thumb:hover {
    background: #52525b;
}

.hover-primary {
    transition: color 0.2s ease;
}

.hover-primary:hover {
    color: var(--bs-primary) !important;
}

.placeholder-secondary::placeholder {
    color: var(--text-muted) !important;
    opacity: 0.7;
}

/* override no-scrollbar */
.no-scrollbar {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-focus-ring:focus {
    box-shadow: none !important;
    outline: none !important;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE & CROSS-BROWSER COMPATIBILITY FIXES
   ═══════════════════════════════════════════════════════ */

/* ── 1. TOUCH TARGETS: Min 44x44px ──────────────────── */
.nav-link,
.dropdown-item,
.btn-sm,
.btn-close,
.page-link,
.breadcrumb-item a,
.hover-glow,
.category-link {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Fix dropdown items to be flex instead of inline-flex */
.dropdown-item {
    display: flex !important;
}

/* Social icon buttons in footer */
.btn.rounded-circle.btn-sm {
    width: 44px !important;
    height: 44px !important;
}

/* Pagination touch targets */
.pagination .page-link {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* File download buttons */
.btn.rounded-circle[style*="width: 42px"] {
    min-width: 44px !important;
    min-height: 44px !important;
}

/* ── 2. FIREFOX BACKDROP-FILTER FALLBACK ─────────────── */
.premium-nav {
    background-color: rgba(9, 9, 11, 0.95) !important;
}

@supports (backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px)) {
    .premium-nav {
        background-color: rgba(9, 9, 11, 0.8) !important;
    }
}

.badge-glass {
    background: rgba(0, 0, 0, 0.8);
}

@supports (backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px)) {
    .badge-glass {
        background: rgba(0, 0, 0, 0.6);
    }
}

.auth-card {
    background: linear-gradient(145deg, var(--bg-surface) 0%, rgba(18, 18, 20, 0.98) 100%);
}

@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
    .auth-card {
        background: linear-gradient(145deg, var(--bg-surface) 0%, rgba(18, 18, 20, 0.95) 100%);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

/* ── 3. iOS POSITION:STICKY FIX ──────────────────────── */
.header-main.sticky-top {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
}

.position-sticky {
    position: -webkit-sticky !important;
    position: sticky !important;
}

/* ── 4. CROSS-BROWSER SCROLLBAR ──────────────────────── */
/* Firefox scrollbar */
html {
    scrollbar-width: thin;
    scrollbar-color: #3f3f46 var(--bg-darker, #0D0D0F);
}

.category-nav {
    scrollbar-width: thin;
    scrollbar-color: #3f3f46 transparent;
}

/* ── 5. RESPONSIVE FONT SIZING ───────────────────────── */
h1, .display-3 {
    font-size: clamp(1.75rem, 4vw + 1rem, 3.5rem);
}

h2 {
    font-size: clamp(1.5rem, 3vw + 0.5rem, 2.25rem);
}

h3 {
    font-size: clamp(1.25rem, 2vw + 0.5rem, 1.75rem);
}

.lead {
    font-size: clamp(1rem, 1.5vw + 0.5rem, 1.25rem);
}

/* ── 6. vh → dvh iOS SAFARI FIX ─────────────────────── */
.d-flex.flex-column.min-vh-100 {
    min-height: 100vh;
    min-height: 100dvh;
}

/* ── 7. IMAGE OVERFLOW PROTECTION ────────────────────── */
img {
    max-width: 100%;
    height: auto;
}

/* Preserve absolute positioned images in model-img-wrapper */
.model-img-wrapper img {
    max-width: none;
    height: 100%;
}

/* ── 8. TABLE RESPONSIVE ─────────────────────────────── */
.table-responsive-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    min-width: 100%;
}

/* ── 9. FORM RESPONSIVE PADDING ──────────────────────── */
@media (max-width: 575.98px) {
    .form-control,
    .form-select {
        padding: 0.625rem 0.75rem;
        font-size: 1rem; /* Prevents iOS zoom on focus */
    }

    .card.p-4 {
        padding: 1rem !important;
    }

    .card.p-5 {
        padding: 1.25rem !important;
    }
}

/* ── 10. RESPONSIVE LAYOUT FIXES ─────────────────────── */

/* Mobile: Stack filter pills properly */
@media (max-width: 767.98px) {
    /* Header top bar mobile layout */
    .header-top {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem !important;
    }

    /* Make search full width on small screens */
    .header-top .flex-grow-1 {
        order: 3;
        flex-basis: 100%;
        margin: 0 !important;
    }

    /* Filter pills wrap */
    .d-flex.gap-3.flex-wrap {
        gap: 0.5rem !important;
    }

    /* Category pills overflow scroll */
    .d-flex.gap-3.overflow-auto {
        -webkit-overflow-scrolling: touch;
    }

    /* Footer stacking */
    .footer .d-flex.gap-3 {
        flex-wrap: wrap;
    }

    /* Product grid mobile */
    .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Card padding reduction on mobile */
    .card-body.px-4,
    .card-body.px-md-5 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Hero section spacing */
    .container.py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    /* Hero stats */
    .d-flex.justify-content-center.gap-5 {
        gap: 1.5rem !important;
    }

    /* Model card hover disabled on touch */
    .model-card:hover {
        transform: none;
    }

    /* Message panel full width on mobile */
    #messagePanel {
        width: 100vw !important;
    }
    #messagePanel:not(.open) {
        right: -100vw !important;
    }
    #messagePanel.open {
        right: 0 !important;
    }

    /* Chat window full width on mobile */
    #chatWindow {
        width: calc(100vw - 16px) !important;
        right: 8px !important;
        height: 70vh !important;
        height: 70dvh !important;
    }

    /* Chat minimized bar */
    #chatMinimized {
        width: calc(100vw - 40px) !important;
        right: 20px !important;
    }

    /* Notification dropdown full width */
    .dropdown-menu[style*="width: 320px"] {
        width: calc(100vw - 2rem) !important;
        max-width: 320px;
    }

    /* Stat boxes on profile */
    .bg-darker.px-4.py-3.rounded-3 {
        min-width: auto !important;
        flex: 1 1 calc(50% - 0.75rem) !important;
    }

    /* Profile avatar smaller on mobile */
    .avatar-wrapper .rounded-circle[style*="width: 130px"] {
        width: 90px !important;
        height: 90px !important;
    }

    /* Profile cover shorter on mobile */
    .rounded-top-4[style*="height: 85px"] {
        height: 60px !important;
    }
}

/* Very small screens */
@media (max-width: 400px) {
    /* Hero buttons stack */
    .d-flex.justify-content-center.gap-3.mb-4 {
        flex-direction: column;
        align-items: center;
    }

    .d-flex.justify-content-center.gap-3.mb-4 .btn {
        width: 100%;
        max-width: 300px;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 991.98px) {
    .col-md-3 {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }

    #messagePanel {
        width: 340px !important;
    }

    #chatWindow {
        width: 340px !important;
    }
}

/* ── 11. HARDCODED WIDTH OVERRIDES ───────────────────── */
@media (max-width: 767.98px) {
    /* Override any inline max-width styles that break on mobile */
    [style*="max-width: 650px"],
    [style*="max-width: 600px"],
    [style*="max-width: 740px"],
    [style*="max-width: 800px"] {
        max-width: 100% !important;
    }

    /* Glow effect overflow fix */
    [style*="width: 500px"][style*="position: absolute"] {
        width: 300px !important;
    }
}

/* ── 12. MODAL RESPONSIVE ────────────────────────────── */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }

    .modal-body {
        padding: 1rem;
    }
}

/* ── 13. CHAT WIDGET RESPONSIVE ──────────────────────── */
@media (max-width: 767.98px) {
    #chatWidget {
        width: calc(100vw - 16px) !important;
        height: calc(100vh - 80px) !important;
        height: calc(100dvh - 80px) !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 8px !important;
        border-radius: 16px 16px 0 0 !important;
    }
}

/* ── 14. PRINT MEDIA ─────────────────────────────────── */
@media print {
    .header-main,
    .footer,
    #messagePanel,
    #chatWindow,
    #chatMinimized,
    #chatWidget,
    #btnOpenConvos,
    .toast-container {
        display: none !important;
    }

    main {
        margin: 0 !important;
    }
}

/* ══════════════════════════════════════════════════════
   PRODUCT CARD — minimal image-only card with hover info
   ══════════════════════════════════════════════════════ */
.product-card {
    display: block;
    text-decoration: none;
    color: inherit;
}

.product-card-inner {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: var(--bg-darker);
    border: 1px solid var(--bs-border-color);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    aspect-ratio: 1 / 1;
}

.product-card:hover .product-card-inner {
    border-color: rgba(78, 232, 78, 0.4);
    box-shadow: 0 0 20px rgba(78, 232, 78, 0.15);
}

.product-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    max-width: none;
    transition: transform 0.4s ease;
}

.product-card:hover .product-card-img {
    transform: scale(1.05);
}

.product-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
    padding: 2rem 0.65rem 0.6rem;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.product-card:hover .product-card-overlay {
    opacity: 1;
}

/* Always show on touch/mobile devices (no hover capability) */
@media (hover: none) {
    .product-card-overlay {
        opacity: 1 !important;
    }
}

.product-card-seller {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.88);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 63%;
    line-height: 1.3;
}

.product-card-price {
    font-size: 0.74rem;
    font-weight: 700;
    color: #4EE84E;
    white-space: nowrap;
    line-height: 1.3;
    flex-shrink: 0;
}

/* ── 15. REDUCED MOTION ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .model-card,
    .model-card:hover,
    .hover-glow,
    .hover-glow:hover,
    .btn-primary,
    .btn-primary:hover,
    .model-img-wrapper img,
    .model-card:hover .model-img-wrapper img {
        transition: none !important;
        transform: none !important;
        animation: none !important;
    }
}

/* ── 16. ADMIN LAYOUT TOUCH FIXES ────────────────────── */
.sidebar-link {
    min-height: 44px;
}

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

.theme-toggle {
    min-width: 44px;
    min-height: 44px;
}

.admin-pagination .page-link {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}