/**
 * Manpasand Exchange Marketplace - Main Stylesheet
 * Theme: Luminous Professional (Clean, Light, Vibrant Accents)
 */

/* ============================================
   IMPORTS & FONTS
   ============================================ */
/* Fonts loaded via header.php to avoid strict blocking and improve speed */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    /* Base Colors - Clean Light */
    --bg-body: #f8fafc;
    /* Slate 50 */
    --bg-surface: #ffffff;
    /* White */
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-glass-heavy: rgba(255, 255, 255, 0.9);
    --bg-input: #ffffff;

    /* Brand Gradients (Vibrant) */
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    /* Indigo -> Violet -> Fuchsia */
    --secondary-gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    /* Blue -> Cyan */
    --accent-glow: rgba(99, 102, 241, 0.15);

    /* Text Colors - High Contrast */
    --text-primary: #0f172a;
    /* Slate 900 */
    --text-secondary: #475569;
    /* Slate 600 */
    --text-muted: #4F5878;
    /* Slate 400 */
    --text-light: #f8fafc;
    /* For dark backgrounds/buttons */
    --text-inverse: #ffffff;

    /* Borders */
    --border-color: #e2e8f0;
    /* Slate 200 */
    --border-glass: rgba(255, 255, 255, 0.5);

    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Shadows (Soft & Modern) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);

    /* Spacing */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --header-height: 80px;
    --bottom-nav-height: 70px;
}

[data-bs-theme="dark"] {
    /* Deep Rich Dark Theme - Slate/Blue Black */

    --bg-body: #020617;
    /* Slate 950 - Deepest Blue/Black */
    --bg-surface: #0f172a;
    /* Slate 900 */
    --bg-glass: rgba(15, 23, 42, 0.7);
    --bg-glass-heavy: rgba(15, 23, 42, 0.9);
    --bg-input: #1e293b;
    /* Slate 800 */

    /* Adjust Accents for Dark Mode */
    --accent-glow: rgba(139, 92, 246, 0.25);

    /* Text Colors - Inverted */
    --text-primary: #f1f5f9;
    /* Slate 100 */
    --text-secondary: #cbd5e1;
    /* Slate 300 */
    --text-muted: #64748b;
    /* Slate 500 */
    --text-light: #0f172a;
    /* Inverse text */
    --text-inverse: #0f172a;

    /* Borders */
    --border-color: #1e293b;
    /* Slate 800 */
    --border-glass: rgba(255, 255, 255, 0.1);

    /* Shadows (More specialized for dark mode) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

/* ============================================
   RESET & BASE
   ============================================ */
* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    padding-bottom: var(--bottom-nav-height);
    /* Mobile nav spacing */
    min-height: 100vh;
    max-width: 100vw;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Selection */
::selection {
    background: #8b5cf6;
    color: white;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

.text-accent {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    /* Standard property */
    font-weight: 800;
}

.bg-accent {
    background: var(--primary-gradient);
    color: white;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-family: var(--font-heading);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
}

.btn-primary {
    background: var(--text-primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background: #1e293b;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Vibrant Accent Button */
.btn-accent {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(139, 92, 246, 0.39);
}

.btn-accent:hover {
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.23);
    filter: brightness(1.05);
}

.btn-outline {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
    border-color: var(--text-primary);
    background: var(--bg-input);
}

/* ============================================
   GLASS CARDS & CONTAINERS
   ============================================ */
.bg-card,
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: #cbd5e1;
}

/* Special Glass Effect for featured sections */
.bg-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

/* ============================================
   HEADER & NAV
   ============================================ */
.navbar {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.navbar-brand {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--text-primary) !important;
}

.nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary) !important;
    background: rgba(0, 0, 0, 0.03);
}

/* Mobile Nav */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    height: var(--bottom-nav-height);
    z-index: 1050;
    padding: 0 1rem;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    transition: color 0.2s;
}

.mobile-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.mobile-nav-item.active {
    color: #3235F1;
    /* Indigo */
}

.mobile-fab {
    background: var(--text-secondary);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transform: translateY(-15px);
}

.mobile-fab:hover {
    transform: translateY(-18px);
}

/* ============================================
   FORMS
   ============================================ */
.form-control,
.form-select {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-input);
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    color: var(--text-primary);
}

/* ============================================
   UTILITIES
   ============================================ */
.font-heading {
    font-family: var(--font-heading);
}

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

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

.shadow-soft {
    box-shadow: var(--shadow-lg);
}

.badge-condition {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.8rem;
    box-shadow: var(--shadow-sm);
}

/* Animations */
@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

.floating {
    animation: float 6s ease-in-out infinite;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-up {
    animation: fadeUp 0.6s ease-out forwards;
}

.delay-100 {
    animation-delay: 0.1s;
}

.delay-200 {
    animation-delay: 0.2s;
}

/* Drag & Drop */
.image-upload-container {
    background: var(--bg-body);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.image-upload-container:hover,
.image-upload-container.dragover {
    border-color: #6366f1;
    background: var(--accent-glow);
}

.image-preview-item {
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-md);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Image Item Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.item-card {
    height: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.item-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: #cbd5e1;
    z-index: 50;
    /* Ensure it floats above others */
}

/* Fix for dropdowns being clipped or hidden */
.item-card .dropdown-menu {
    z-index: 1050;
    /* Higher than card hover */
}

/* When dropdown is open, keep the card above others even if not hovering */
.item-card:has(.dropdown-menu.show) {
    z-index: 60;
    transform: none;
    /* Prevent transform issues with popper.js */
}

.item-card-image-wrapper {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.item-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.item-card:hover .item-card-image {
    transform: scale(1.05);
}

.item-card-content {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.item-card-title {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.item-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.item-location {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.item-card-footer {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent 40%);
    pointer-events: none;
    z-index: 2;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
    }

    .items-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .item-card-image-wrapper {
        aspect-ratio: 4 / 3;
    }

    .item-card-content {
        padding: 0.5rem;
    }

    .item-card-title {
        font-size: 0.85rem;
        margin-bottom: 0.2rem;
    }

    .item-price {
        font-size: 0.9rem;
        line-height: 1.2;
    }

    .item-card-footer {
        padding-top: 0.5rem;
    }
    
    .item-location {
        font-size: 0.75rem;
        max-width: 80px;
    }
    
    .item-card-footer small {
        font-size: 0.7rem;
    }
    
    .item-card .badge {
        font-size: 0.65rem;
        padding: 0.25rem 0.4rem;
    }

    h1 {
        font-size: 1.75rem;
    }
}

/* ============================================
   GLOBAL SEARCH BAR
   ============================================ */
.search-bar-section {
    background: var(--bg-glass-heavy);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: top 0.3s;
}

/* Ensure inputs in search bar look seamless */
.search-bar-section .input-group-text {
    border: 1px solid var(--border-color);
    border-right: none;
    color: var(--text-secondary);
    background-color: var(--bg-input);
}

.search-bar-section .form-control,
.search-bar-section .form-select {
    border-left: none;
}

.search-bar-section .form-control:focus,
.search-bar-section .form-select:focus {
    box-shadow: none;
    border-color: var(--border-color);
    border-bottom: 2px solid #6366f1;
}

/* Hide overlapping borders */
.search-bar-section .input-group:focus-within .input-group-text {
    border-color: #6366f1;
    border-bottom: 2px solid #6366f1;
}

@media (max-width: 768px) {
    .search-bar-section {
        position: relative !important;
        top: 0 !important;
    }
}

/* Featured Items Styling */
.featured-card {
    border: 2px solid #f59e0b !important;
    /* Amber-500 */
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.2) !important;
    position: relative;
    z-index: 1;
}

.featured-card::before {
    /* Inner Glow */
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: var(--radius-md);
    box-shadow: inset 0 0 20px rgba(245, 158, 11, 0.1);
    pointer-events: none;
    z-index: 2;
}

.featured-badge {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: white !important;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ============================================
   CHAT MODAL & NOTIFICATIONS
   ============================================ */
.bg-glass-light {
    background: rgba(99, 102, 241, 0.05);
}

[data-bs-theme="dark"] .bg-glass-light {
    background: rgba(139, 92, 246, 0.1);
}

#conversation-list .list-group-item {
    transition: all 0.2s ease;
    border-color: var(--border-color) !important;
}

#conversation-list .list-group-item:hover {
    background-color: var(--bg-input) !important;
    transform: translateX(5px);
}

#conversation-list .list-group-item.bg-glass-light {
    border-left: 3px solid #6366f1 !important;
}

.fit-content {
    width: fit-content;
}

.min-width-0 {
    min-width: 0;
}

/* ============================================
   BACK TO TOP BUTTON
   ============================================ */
.back-to-top {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 20px);
    right: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

@media (max-width: 768px) {
    .back-to-top {
        right: 15px;
        bottom: calc(var(--bottom-nav-height) + 15px);
    }
}

/* iOS safe-area adjustments */
@supports (-webkit-touch-callout: none) {
    body {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    }

    .mobile-bottom-nav {
        height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    @media (max-width: 768px) {
        .back-to-top {
            bottom: calc(var(--bottom-nav-height) + 15px + env(safe-area-inset-bottom, 0px));
        }
    }
}