/**
 * Marketplace Alibaba Niger - Styles WhatsApp
 * Style mobile-first avec couleurs WhatsApp officielles
 */

/* ==========================================================================
   Variables CSS - Couleurs WhatsApp
   ========================================================================== */
:root {
    --color-primary: #075E54;        /* Vert foncé WhatsApp */
    --color-secondary: #25D366;      /* Vert clair WhatsApp */
    --color-secondary-hover: #20BA5A;
    --color-background: #ECE5DD;     /* Beige clair */
    --color-white: #FFFFFF;
    --color-text-primary: #303030;
    --color-text-secondary: #667781;
    --color-border: #D1D7DB;
    --color-input-bg: #F0F2F5;
    
    /* Badges */
    --color-badge-new-bg: #e8f5e9;
    --color-badge-new: #2e7d32;
    --color-badge-occasion-bg: #fff3cd;
    --color-badge-occasion: #856404;
    --color-badge-troc-bg: #e3f2fd;
    --color-badge-troc: #1976d2;
    --color-badge-gift-bg: #fce4ec;
    --color-badge-gift: #c2185b;
    
    /* Dimensions */
    --header-height: 56px;
    --sidebar-width: 280px;
    --border-radius: 7.5px;
    --border-radius-pill: 24px;
    --transition-speed: 0.2s;
}

/* ==========================================================================
   Reset et Base
   ========================================================================== */
.alibaba-marketplace * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.alibaba-marketplace {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text-primary);
    background: var(--color-background);
    min-height: 100vh;
}

/* ==========================================================================
   Header Style WhatsApp
   ========================================================================== */
.marketplace-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--color-primary);
    color: var(--color-white);
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.header-content {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 16px;
    gap: 16px;
}

.header-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--color-white);
    text-decoration: none;
    border-radius: 50%;
    transition: background var(--transition-speed);
}

.header-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.header-title {
    flex: 1;
    font-size: 19px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-subtitle {
    display: block;
    font-size: 13px;
    font-weight: 400;
    opacity: 0.9;
}

.header-search-btn,
.header-filter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--color-white);
    cursor: pointer;
    border-radius: 50%;
    transition: background var(--transition-speed);
}

.header-search-btn:hover,
.header-filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Panneau de Recherche Mobile
   ========================================================================== */
.search-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-white);
    z-index: 1100;
    display: none;
    flex-direction: column;
}

.search-panel.active {
    display: flex;
}

.search-panel-header {
    display: flex;
    align-items: center;
    height: var(--header-height);
    padding: 0 8px 0 16px;
    background: var(--color-primary);
    gap: 12px;
}

.search-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--color-white);
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
}

.search-close-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 36px;
    padding: 8px 12px 8px 40px;
    background: var(--color-input-bg);
    border: none;
    border-radius: 20px;
    font-size: 15px;
    color: var(--color-text-primary);
    transition: all var(--transition-speed);
    -webkit-appearance: none;
    appearance: none;
}

.search-input:focus {
    outline: none;
    background: var(--color-white);
    box-shadow: 0 0 0 2px var(--color-secondary);
}

/* Fix pour iOS Safari */
.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-results-button,
.search-input::-webkit-search-results-decoration {
    display: none;
}

.search-suggestions {
    background: var(--color-white);
    max-height: 300px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background var(--transition-speed);
}

.suggestion-item:hover,
.suggestion-item:active {
    background: var(--color-input-bg);
}

.suggestion-name {
    font-size: 15px;
    color: var(--color-text-primary);
    font-weight: 500;
    margin-bottom: 4px;
}

.suggestion-meta {
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* ==========================================================================
   Container Principal
   ========================================================================== */
.marketplace-container {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* ==========================================================================
   Sidebar Filtres
   ========================================================================== */
.marketplace-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-white);
    border-right: 1px solid var(--color-border);
    z-index: 900;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.marketplace-sidebar.active {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.marketplace-sidebar.active .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--color-white);
    position: relative;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-primary);
}

.sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: 50%;
    transition: background var(--transition-speed);
}

.sidebar-close-btn:hover {
    background: var(--color-input-bg);
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Filtres */
.filter-section {
    margin-bottom: 24px;
}

.filter-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 12px;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 0;
}

.filter-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-secondary);
}

.filter-checkbox span {
    font-size: 14px;
    color: var(--color-text-primary);
}

.filter-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--color-text-primary);
    background: var(--color-white);
    cursor: pointer;
    transition: border-color var(--transition-speed);
}

.filter-select:focus {
    outline: none;
    border-color: var(--color-secondary);
}

.filter-price {
    display: flex;
    align-items: center;
    gap: 8px;
}

.price-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--color-text-primary);
}

.price-input:focus {
    outline: none;
    border-color: var(--color-secondary);
}

.price-separator {
    color: var(--color-text-secondary);
}

.btn-reset-filters {
    width: 100%;
    padding: 10px;
    background: var(--color-input-bg);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background var(--transition-speed);
}

.btn-reset-filters:hover {
    background: var(--color-border);
}

.search-desktop {
    display: none;
}

/* ==========================================================================
   Contenu Principal
   ========================================================================== */
.marketplace-main {
    flex: 1;
    padding: 16px 8px;
}

/* Barre de résultats */
.results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--color-white);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
}

.results-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.sort-select {
    padding: 6px 10px;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--color-text-secondary);
    background: var(--color-white);
    cursor: pointer;
}

/* Grille de produits */
.products-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

/* ==========================================================================
   Card Produit Style WhatsApp
   ========================================================================== */
.product-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 12px;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.product-card:hover {
    background: var(--color-input-bg);
    transform: scale(0.98);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.product-image {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: var(--border-radius);
    margin-bottom: 12px;
}

.product-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.product-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}

.badge-new {
    background: var(--color-badge-new-bg);
    color: var(--color-badge-new);
}

.badge-occasion {
    background: var(--color-badge-occasion-bg);
    color: var(--color-badge-occasion);
}

.badge-troc {
    background: var(--color-badge-troc-bg);
    color: var(--color-badge-troc);
}

.badge-gift {
    background: var(--color-badge-gift-bg);
    color: var(--color-badge-gift);
}

.product-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-description {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.product-meta {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
}

.product-contact {
    width: 100%;
    height: 42px;
    background: var(--color-secondary);
    border: none;
    border-radius: var(--border-radius-pill);
    color: var(--color-white);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.product-contact:hover {
    background: var(--color-secondary-hover);
}

/* ==========================================================================
   États Vides et Chargement
   ========================================================================== */
.no-results {
    text-align: center;
    padding: 60px 20px;
    background: var(--color-white);
    border-radius: var(--border-radius);
}

.no-results-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.no-results h3 {
    font-size: 20px;
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

.no-results p {
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* Skeleton Loader */
.product-card.skeleton {
    pointer-events: none;
}

.skeleton-image,
.skeleton-text {
    background: linear-gradient(90deg, #E4E6EB 25%, #F0F2F5 50%, #E4E6EB 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--border-radius);
}

.skeleton-image {
    width: 100%;
    height: 210px;
    margin-bottom: 12px;
}

.skeleton-title {
    height: 20px;
    width: 80%;
    margin-bottom: 8px;
}

.skeleton-description {
    height: 14px;
    width: 100%;
    margin-bottom: 6px;
}

.skeleton-price {
    height: 24px;
    width: 40%;
    margin-bottom: 12px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ==========================================================================
   Bouton Voir Plus
   ========================================================================== */
.load-more-container {
    text-align: center;
    padding: 24px 0;
}

.btn-load-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 32px;
    height: 42px;
    background: var(--color-secondary);
    border: none;
    border-radius: var(--border-radius-pill);
    color: var(--color-white);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-speed);
}

.btn-load-more:hover:not(:disabled) {
    background: var(--color-secondary-hover);
}

.btn-load-more:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.spinner {
    animation: spin 1s linear infinite;
}

.spinner-circle {
    stroke-dasharray: 60;
    stroke-dashoffset: 45;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Footer
   ========================================================================== */
.marketplace-footer {
    background: var(--color-text-primary);
    color: var(--color-white);
    padding: 24px 16px;
    text-align: center;
    font-size: 14px;
}

/* ==========================================================================
   Responsive - Tablet (768px+)
   ========================================================================== */
@media (min-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .marketplace-main {
        padding: 16px;
    }
    
    .header-filter-btn {
        display: none;
    }
    
    .marketplace-sidebar {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: none;
    }
    
    .sidebar-close-btn {
        display: none;
    }
    
    .marketplace-main {
        margin-left: var(--sidebar-width);
    }
    
    .search-panel {
        display: none !important;
    }
    
    .header-search-btn {
        display: none;
    }
    
    .search-desktop {
        display: block !important;
    }
}

/* ==========================================================================
   Responsive - Desktop (1024px+)
   ========================================================================== */
@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
    
    .marketplace-container {
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (min-width: 1280px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}