/* Variables de couleur */
:root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --primary-color: #bb86fc;
    --primary-variant: #3700b3;
    --secondary-color: #03dac6;
    --error-color: #cf6679;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --card-bg: #2d2d2d;
    --card-hover: #3d3d3d;
}

/* Reset et styles de base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
}

/* État initial - header plein écran */
body.initial-state {
    height: 100vh;
    overflow: hidden;
}

body.initial-state .container {
    height: 100%;
    padding: 0;
    max-width: none;
}

body.initial-state .hero-header {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2rem;
    margin: 0;
    border-radius: 0;
}

body.initial-state .hero-header h1 {
    margin-bottom: 3rem;
}

.warning-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 8px;
    color: #ffc107;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.warning-text i {
    font-size: 1rem;
    flex-shrink: 0;
}

.warning-text span {
    line-height: 1.4;
}

body.initial-state .search-container {
    max-width: 800px;
    width: 100%;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* En-tête */
header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 0;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-variant));
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.hero-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-variant));
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Barre de recherche */
.search-container {
    display: flex;
    max-width: 700px;
    margin: 0 auto;
    padding: 0 1rem;
}

#searchInput {
    flex: 1;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    border: none;
    border-radius: 50px 0 0 50px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

#searchInput::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#searchInput:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 2px var(--primary-color);
}

#searchBtn {
    padding: 0 2rem;
    background: var(--secondary-color);
    color: #000;
    border: none;
    border-radius: 0 50px 50px 0;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#searchBtn:hover {
    background: #00c9b8;
    transform: translateY(-2px);
}

/* Filtres */
.filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: var(--surface-color);
    padding: 1rem 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 100;
}

.filter-controls {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.sort-group, .service-filter-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sort-group label, .service-filter-group label {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

#sortBy, #serviceFilter {
    padding: 0.7rem 1rem;
    border-radius: 25px;
    border: 2px solid #444;
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 180px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23bb86fc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1.2em;
    padding-right: 2.5rem;
}

#sortBy:focus, #serviceFilter:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(187, 134, 252, 0.2);
    transform: translateY(-1px);
}

#sortBy:hover, #serviceFilter:hover {
    border-color: var(--primary-color);
    background-color: rgba(187, 134, 252, 0.05);
}

.custom-select-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    padding: 0.7rem 1rem;
    border-radius: 25px;
    border: 2px solid #444;
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 180px;
    position: relative;
    z-index: 10000;
}

.custom-select-trigger:hover {
    border-color: var(--primary-color);
    background-color: rgba(187, 134, 252, 0.05);
}

.custom-select-trigger:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(187, 134, 252, 0.2);
    transform: translateY(-1px);
}

.custom-select-trigger i {
    transition: transform 0.3s ease;
    color: var(--primary-color);
}

.custom-select.open .custom-select-trigger i {
    transform: rotate(180deg);
}

.custom-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 2px solid #444;
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.custom-select.open .custom-options {
    display: block;
    animation: slideDown 0.3s ease;
}

.custom-option {
    padding: 0.8rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.custom-option:last-child {
    border-bottom: none;
}

.custom-option:hover {
    background: rgba(187, 134, 252, 0.1);
    color: var(--primary-color);
}

.custom-option.selected {
    background: rgba(187, 134, 252, 0.2);
    color: var(--primary-color);
    font-weight: 600;
}

.option-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.option-icon img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    border-radius: 2px;
}

.custom-select-value {
    display: flex;
    align-items: center;
    flex: 1;
}

.custom-select-value .option-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.custom-select-value .option-icon img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    border-radius: 2px;
}

.option-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#serviceFilter option {
    padding: 0.5rem;
    background: var(--card-bg);
    color: var(--text-primary);
    border: none;
}

#serviceFilter option:hover {
    background: rgba(187, 134, 252, 0.1);
}

.search-info {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
    padding: 0.3rem 0.8rem;
    background: rgba(187, 134, 252, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(187, 134, 252, 0.2);
}

/* Meilleure offre */
.best-deal {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--primary-color);
    box-shadow: 0 4px 30px rgba(187, 134, 252, 0.2);
    transition: transform 0.3s ease;
}

.best-deal:hover {
    transform: translateY(-3px);
}

.best-deal h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.deal-card {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.deal-card img {
    width: 200px;
    height: 200px;
    object-fit: contain;
    background: white;
    border-radius: 8px;
    padding: 1rem;
}

.deal-info {
    flex: 1;
}

.deal-price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin: 0.5rem 0 1rem;
}

.deal-source {
    display: inline-block;
    background: rgba(3, 218, 198, 0.1);
    color: var(--secondary-color);
    padding: 0.3rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    text-transform: capitalize;
}

.deal-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-color);
    color: #000;
    text-decoration: none;
    padding: 0.7rem 1.5rem;
    border-radius: 50px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.deal-btn:hover {
    background: #a45ed8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(187, 134, 252, 0.3);
}

/* Résultats */
.results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.product-card {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #333;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    border-color: var(--primary-color);
}

.product-image {
    width: 100%;
    height: 200px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-info {
    padding: 1.5rem;
}

.product-title {
    font-size: 1rem;
    margin-bottom: 0.8rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 3.2em;
    line-height: 1.6;
}

.product-price {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin: 0.5rem 0;
}

.product-source {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.2rem 0.8rem;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    text-transform: capitalize;
}

/* État de chargement */
.loading {
    text-align: center;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Message d'erreur */
.error-message {
    background: rgba(207, 102, 121, 0.1);
    border-left: 4px solid var(--error-color);
    padding: 1.5rem;
    border-radius: 6px;
    margin: 2rem 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--error-color);
}

.error-message i {
    font-size: 1.5rem;
}

/* Pied de page */
footer {
    text-align: center;
    padding: 2rem;
    margin-top: 3rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid #333;
}

/* Classes utilitaires */
.hidden {
    display: none !important;
}

/* Animations d'apparition */
.filters, .results-container {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.filters:not(.hidden) {
    animation: slideDown 0.4s ease forwards;
}

.results-container:not(.hidden) {
    animation: fadeIn 0.5s ease forwards;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Animation de transition stylée */
body:not(.initial-state) .hero-header {
    animation: heroTransition 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

body:not(.initial-state) .container {
    animation: containerResize 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes heroTransition {
    0% {
        height: 100vh;
        border-radius: 0;
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    100% {
        height: auto;
        min-height: auto;
        border-radius: 12px;
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes containerResize {
    0% {
        height: 100%;
        padding: 0;
        max-width: none;
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
    100% {
        height: auto;
        padding: 2rem;
        max-width: 1400px;
        transform: translateY(0);
    }
}

/* Effet de vague lors de la transition */
.transition-wave {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(187, 134, 252, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    animation: waveEffect 1s ease-out forwards;
    pointer-events: none;
    z-index: 1000;
}

@keyframes waveEffect {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(20);
        opacity: 0;
    }
}

/* Animation des éléments du header pendant la transition */
body:not(.initial-state) .hero-header h1 {
    animation: titleShrink 0.6s ease-out forwards;
}

body:not(.initial-state) .search-container {
    animation: searchMove 0.6s ease-out forwards;
}

@keyframes titleShrink {
    0% {
        font-size: 2.5rem;
        margin-bottom: 3rem;
        transform: translateY(0);
    }
    100% {
        font-size: 2.5rem;
        margin-bottom: 1.5rem;
        transform: translateY(-10px);
    }
}

@keyframes searchMove {
    0% {
        max-width: 800px;
        transform: translateY(0);
    }
    100% {
        max-width: 700px;
        transform: translateY(-10px);
    }
}

/* Responsive */
/* Mobile First - Petits écrans */
@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }

    header h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .search-container {
        flex-direction: column;
        gap: 0.8rem;
        padding: 0 1rem;
    }

    #searchInput {
        border-radius: 25px;
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }

    #searchBtn {
        border-radius: 25px;
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }

    .filters {
        flex-direction: column;
        gap: 0.8rem;
        align-items: stretch;
        padding: 1rem;
    }

    .filter-controls {
        flex-direction: column;
        gap: 0.8rem;
        width: 100%;
    }

    .sort-group, .service-filter-group {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    .sort-group label, .service-filter-group label {
        font-size: 0.85rem;
        margin-bottom: 0.3rem;
    }

    #sortBy, #serviceFilter {
        width: 100%;
        min-width: auto;
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }

    .results {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .product-card {
        border-radius: 8px;
    }

    .product-image {
        height: 150px;
    }

    .product-info {
        padding: 1rem;
    }

    .product-title {
        font-size: 0.9rem;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        height: 4.8em;
    }

    .product-price {
        font-size: 1.2rem;
    }

    .deal-card {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .deal-card img {
        width: 120px;
        height: 120px;
    }

    .deal-price {
        font-size: 1.5rem;
    }

    /* Responsive pour l'état initial sur petits mobiles */
    body.initial-state .hero-header {
        padding: 1rem;
    }
    
    body.initial-state .hero-header h1 {
        font-size: 1.8rem;
        margin-bottom: 1.5rem;
    }
    
    body.initial-state .search-container {
        max-width: 100%;
        padding: 0 1rem;
    }
    
    .transition-wave {
        width: 60px;
        height: 60px;
    }
}

/* Mobile - Écrans moyens */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .search-container {
        flex-direction: column;
        gap: 1rem;
        padding: 0 1rem;
    }

    #searchInput {
        border-radius: 50px;
        padding: 0.8rem 1.5rem;
    }

    #searchBtn {
        border-radius: 50px;
        padding: 0.8rem;
        justify-content: center;
    }

    .filters {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
        padding: 1rem;
    }

    .filter-controls {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }

    .sort-group, .service-filter-group {
        width: 100%;
        justify-content: space-between;
    }

    #sortBy, #serviceFilter {
        flex: 1;
        min-width: auto;
        font-size: 0.9rem;
    }

    .results {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .deal-card {
        flex-direction: column;
        text-align: center;
    }

    .deal-card img {
        width: 150px;
        height: 150px;
    }

    .deal-btn {
        margin: 0 auto;
    }
    
    /* Responsive pour l'état initial sur mobile */
    body.initial-state .hero-header {
        padding: 1rem;
    }
    
    body.initial-state .hero-header h1 {
        font-size: 2rem;
        margin-bottom: 2rem;
    }
    
    body.initial-state .search-container {
        max-width: 100%;
        padding: 0 1rem;
    }
    
    .transition-wave {
        width: 80px;
        height: 80px;
    }
}

/* Tablette */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 1.5rem;
    }

    header h1 {
        font-size: 2.2rem;
    }

    .search-container {
        max-width: 600px;
    }

    .filters {
        flex-direction: column;
        gap: 1rem;
    }

    .filter-controls {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .sort-group, .service-filter-group {
        flex: 1;
        min-width: 250px;
    }

    .results {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .product-image {
        height: 180px;
    }

    .deal-card img {
        width: 180px;
        height: 180px;
    }
}

/* Desktop - Grand écran */
@media (min-width: 1025px) and (max-width: 1440px) {
    .container {
        padding: 2rem;
    }

    header h1 {
        font-size: 2.5rem;
    }

    .search-container {
        max-width: 700px;
    }

    .results {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* Ultra-wide */
@media (min-width: 1441px) {
    .container {
        padding: 2rem;
        max-width: 1600px;
    }

    header h1 {
        font-size: 2.8rem;
    }

    .search-container {
        max-width: 800px;
    }

    .results {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }

    .product-image {
        height: 220px;
    }
}

/* Animations mobile optimisées */
@media (max-width: 768px) {
    body:not(.initial-state) .hero-header {
        animation: heroTransitionMobile 0.6s ease-out forwards;
    }
    
    @keyframes heroTransitionMobile {
        0% {
            height: 100vh;
            border-radius: 0;
            transform: scale(1);
        }
        100% {
            height: auto;
            border-radius: 8px;
            transform: scale(1);
        }
    }
    
    @keyframes titleShrink {
        0% {
            font-size: 2rem;
            margin-bottom: 2rem;
            transform: translateY(0);
        }
        100% {
            font-size: 1.8rem;
            margin-bottom: 1rem;
            transform: translateY(-5px);
        }
    }
    
    @keyframes searchMove {
        0% {
            max-width: 100%;
            transform: translateY(0);
        }
        100% {
            max-width: 100%;
            transform: translateY(-5px);
        }
    }
}

/* Thème clair (optionnel) */
@media (prefers-color-scheme: light) {
    :root {
        --bg-color: #f5f5f5;
        --surface-color: #ffffff;
        --text-primary: #333333;
        --text-secondary: #666666;
        --card-bg: #ffffff;
        --card-hover: #f0f0f0;
    }

    .best-deal {
        background: linear-gradient(135deg, #f8f9fa, #e9ecef);
        border-color: var(--primary-color);
    }

    .product-card {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    }

    .product-card:hover {
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    }
}
