:root {
    --primary-bg: #0a0a0c;
    --widget-bg: rgba(93, 47, 134, 0.05);
    --card-bg: rgba(40, 44, 52, 0.75);
    --text-color: #ffffff;
    --accent-color: #8b5cf6;
    --glow-color: rgba(139, 92, 246, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background: var(--primary-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Effet de grain */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZPfnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRWAz5GuSBIkwG1H3FabJ2OsUOUhGC6tK4EMtJO0ttC6IBD3kM0ve0tJwMdSfjZo+EEISaeTr9P3wYrGjXqyC1krcKdhMpxEnt5JetoulscpyzhXN5FRpuPHvbeQaKxFAEB6EN+cYN6xD7RYGpX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WNNWTa5Z5kPZw5+LbVT99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==');
    opacity: 0.4;
    pointer-events: none;
    z-index: 1;
}

.desktop {
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 2;
    background: radial-gradient(circle at 50% 0%, var(--glow-color) 0%, transparent 50%);
}

header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    text-align: center;
    padding: 20px 0;
}

/* Animation pour l'heure */
@keyframes pulseTime {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes fadeNumber {
    0% { opacity: 0.7; transform: translateY(2px); }
    100% { opacity: 1; transform: translateY(0); }
}

.time {
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: 5px;
    background: linear-gradient(135deg, #fff 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(139, 92, 246, 0.5);
    position: relative;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.time.tick {
    animation: timePulse 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes timePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); filter: brightness(1.2); }
    100% { transform: scale(1); }
}

.date {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.widgets-container {
    display: grid;
    gap: 35px;
    padding: 25px;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    max-width: 1800px;
    margin: 0 auto;
}

.widget {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible;
    transition: opacity 0.3s ease-in-out;
    opacity: 1;
}

.widget:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(139, 92, 246, 0.2);
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 0 5px;
}

.widget-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.more {
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.2s;
}

.more:hover {
    opacity: 1;
}

.tools-list {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    justify-content: center;
    padding: 5px;
    overflow: visible;
}

.tool {
    width: 100px;
    height: 100px;
    flex: 0 0 100px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 16px;
    margin-right: 16px;
    overflow: visible;
    transition: opacity 0.3s ease-in-out;
    opacity: 1;
    cursor: pointer;
}

.tool:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(139, 92, 246, 0.15);
    box-shadow: 
        0 10px 20px rgba(0, 0, 0, 0.1),
        0 0 20px rgba(139, 92, 246, 0.15);
}

.tool img {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    border-radius: 14px;
    object-fit: contain;
    padding: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: transform 0.3s ease;
}

.tool span {
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    max-width: 85%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool:hover img {
    transform: scale(1.1);
}

.dock {
    margin-top: auto;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    padding: 15px;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    gap: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Responsive adjustments */
@media (min-width: 640px) {
    .desktop {
        padding: 30px;
    }
    
    .widgets-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tools-list {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    }
}

@media (min-width: 1024px) {
    .desktop {
        padding: 40px;
    }
    
    .widgets-container {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .tools-list {
        grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
    }
    
    .tool {
        min-height: 110px;
    }
}

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

/* Enhanced Mobile optimizations */
@media (max-width: 768px) {
    .desktop {
        padding: 12px;
        gap: 15px;
    }

    header {
        padding: 15px 0;
        margin-bottom: 20px;
    }
    
    .time {
        font-size: 2.8rem;
        margin-bottom: 4px;
    }
    
    .date {
        font-size: 1rem;
    }
    
    .widgets-container {
        gap: 20px;
        padding: 15px;
        grid-template-columns: 1fr; /* Force single column on mobile */
    }
    
    .widget {
        min-width: 250px;
        width: 100%;
    }

    .widget-header {
        margin-bottom: 16px;
    }

    .widget-header h3 {
        font-size: 1.2rem;
    }
    
    .tools-list {
        gap: 15px;
        padding: 10px;
    }
    
    .tool {
        width: 85px;
        height: 85px;
        padding: 8px;
        margin: 8px;
    }
    
    .tool img {
        width: 40px;
        height: 40px;
        margin-bottom: 8px;
        padding: 6px;
    }
    
    .tool span {
        font-size: 0.7rem;
        line-height: 1.2;
        max-width: 100%;
        padding: 0 4px;
    }

    .free-tag {
        font-size: 0.6em;
        padding: 2px 6px;
        top: -10px;
    }

    /* Adjust dock for mobile */
    .dock {
        padding: 10px;
        border-radius: 16px;
        gap: 15px;
        margin: 10px auto;
    }

    /* Ajustements pour la grille de résultats */
    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        gap: 15px;
        padding: 15px;
    }
}

/* Special adjustments for very small screens */
@media (max-width: 360px) {
    .widget {
        min-width: 200px;
    }
    
    .tools-list {
        gap: 10px;
        padding: 8px;
    }
    
    .tool {
        width: 75px;
        height: 75px;
        padding: 6px;
        margin: 6px;
    }
    
    .tool img {
        width: 35px;
        height: 35px;
        margin-bottom: 6px;
    }
    
    .tool span {
        font-size: 0.65rem;
    }

    .tools-list {
        gap: 12px;
        padding: 12px;
    }

    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 12px;
        padding: 12px;
    }
}

/* Tablet optimization */
@media (min-width: 640px) and (max-width: 1023px) {
    .widgets-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .tools-list {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }
}

/* Landscape phone optimization */
@media (max-width: 639px) and (orientation: landscape) {
    .widgets-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tool {
        min-height: 70px;
    }
    
    .time {
        font-size: 2.5rem;
    }
    
    header {
        margin-bottom: 15px;
    }
}

/* Ajustements pour les widgets avec beaucoup d'outils */
.widget .tools-list:has(> .tool:nth-child(n+5)) {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
}

/* Animation hover plus fluide */
.tool:hover img {
    transform: scale(1.1);
}

/* Styles pour la barre de recherche */
.search-container {
    position: relative;
    max-width: 600px;
    margin: 0 auto 30px;
    padding: 0 20px;
}

.search-input {
    width: 100%;
    padding: 15px 45px 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1.1rem;
    backdrop-filter: blur(20px);
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(108, 99, 255, 0.2);
}

.search-icon {
    position: absolute;
    right: 35px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.6;
}

/* Styles pour la popup des outils */
.tool-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    perspective: 1000px;
}

.popup-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 24px;
    width: 90%;
    max-width: 500px;
    border: 1px solid rgba(139, 92, 246, 0.2);
    box-shadow: 0 0 50px rgba(139, 92, 246, 0.3);
    transform: rotateX(-90deg) translateY(100px) scale(0.8);
    opacity: 0;
    transform-origin: bottom center;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), 
                opacity 0.3s ease,
                box-shadow 0.3s ease;
    backface-visibility: hidden;
}

.popup-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.popup-header img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: contain;
}

.popup-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #fff 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.popup-description {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
    margin-bottom: 25px;
}

.popup-button {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.8) 0%, rgba(139, 92, 246, 0.6) 100%);
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.popup-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

.button-arrow {
    transition: transform 0.3s ease;
}

.popup-button:hover .button-arrow {
    transform: translateX(5px);
}

.tool-popup.active {
    opacity: 1;
}

.tool-popup.active .popup-content {
    transform: rotateX(0) translateY(0) scale(1);
    opacity: 1;
    box-shadow: 0 0 80px rgba(139, 92, 246, 0.4);
}

/* Animation de sortie */
.tool-popup.closing .popup-content {
    transform: rotateX(90deg) translateY(-100px) scale(0.8);
    opacity: 0;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.2);
}

.time .colon {
    display: inline-block;
    width: 20px;
    text-align: center;
    opacity: 1;
    background: linear-gradient(135deg, #fff 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(139, 92, 246, 0.5);
}

/* Style pour le badge gratuit */
.free-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, var(--accent-color) 0%, rgba(139, 92, 246, 0.8) 100%);
    color: white;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.tool:hover .free-badge {
    transform: scale(1);
}

.free-tag {
    background: rgba(139, 92, 246, 0.1);
    color: rgba(255, 255, 255, 0.8);
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 0.65em;
    font-weight: 500;
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translate(-50%, -50%);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(139, 92, 246, 0.15);
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.1);
    z-index: 2;
    letter-spacing: 0.02em;
    white-space: nowrap;
    pointer-events: none;
    min-width: max-content;
    width: auto;
}

.tool:hover .free-tag {
    transform: translate(-50%, -50%);
}

.tool-header {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: visible;
}

/* Pour éviter le flash initial */
.tool, .widget {
    will-change: opacity;
}

/* Styles des filtres */
.filters-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 0 20px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.filter-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
}

.filter-group:first-child {
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.filter-btn {
    padding: 8px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* État inactif */
.filter-btn {
    opacity: 0.7;
    transform: scale(0.95);
}

/* État hover */
.filter-btn:hover {
    opacity: 0.9;
    transform: scale(1);
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
}

/* État actif */
.filter-btn.active {
    opacity: 1;
    transform: scale(1);
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .filter-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .filter-group {
        gap: 8px;
    }
}

/* Styles pour les résultats de recherche */
.search-results {
    max-width: 1800px;
    margin: 20px auto;
    padding: 0 25px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.results-grid {
    display: grid;
    gap: 25px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: fit-content;
    margin: 0 auto;
    justify-content: center;
    align-items: center;
}

/* Ajustement de la grille en fonction du nombre d'éléments */
.results-grid:has(> .tool:nth-child(-n+4)) {
    grid-template-columns: repeat(2, 100px);
    gap: 20px;
}

.results-grid:has(> .tool:nth-child(n+5):nth-child(-n+9)) {
    grid-template-columns: repeat(3, 100px);
    gap: 20px;
}

.results-grid:has(> .tool:nth-child(n+10):nth-child(-n+16)) {
    grid-template-columns: repeat(4, 100px);
    gap: 20px;
}

.results-grid:has(> .tool:nth-child(n+17)) {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    max-width: 800px;
    gap: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .search-results {
        padding: 0 15px;
    }

    .results-grid {
        gap: 15px;
        padding: 15px;
    }

    .results-grid:has(> .tool:nth-child(-n+4)) {
        grid-template-columns: repeat(2, 85px);
        gap: 15px;
    }

    .results-grid:has(> .tool:nth-child(n+5):nth-child(-n+9)) {
        grid-template-columns: repeat(3, 85px);
        gap: 15px;
    }

    .results-grid:has(> .tool:nth-child(n+10)) {
        grid-template-columns: repeat(auto-fit, 85px);
        gap: 15px;
    }
}

/* Optimisation pour l'orientation paysage sur mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .tools-list {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }

    .tool {
        width: 70px;
        height: 70px;
    }

    .tool img {
        width: 32px;
        height: 32px;
        margin-bottom: 6px;
    }

    .tool span {
        font-size: 0.65rem;
    }
}