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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

.main-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Desktop */
.sidebar {
    width: 280px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    padding: 20px;
}

.sidebar-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.2);
}

.sidebar-title {
    font-size: 1.3rem;
    color: #667eea;
    font-weight: 700;
    margin-bottom: 8px;
}

.sidebar-subtitle {
    font-size: 0.85rem;
    color: #666;
}

.categories-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-btn {
    background: #f8f9ff;
    color: #667eea;
    border: none;
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 2px solid transparent;
}

.category-btn::before {
    content: '📁';
    font-size: 1.2rem;
}

.category-btn[data-category="all"]::before {
    content: '🗂️';
}

.category-btn:hover {
    background: #eef1ff;
    transform: translateX(5px);
    border-color: #667eea;
}

.category-btn.active {
    background: #667eea;
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    border-color: #667eea;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
}

h1 {
    color: white;
    font-size: 2.2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    flex: 1;
}

.upload-btn {
    background: #FF6B6B;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.upload-btn:hover {
    background: #FF5252;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* Mobile Categories Menu */
.mobile-categories {
    display: none;
    overflow-x: auto;
    margin-bottom: 20px;
    padding: 15px 0;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.mobile-categories::-webkit-scrollbar {
    height: 6px;
}

.mobile-categories::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.mobile-categories::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.mobile-categories .categories-list {
    flex-direction: row;
    padding: 0 15px;
    gap: 10px;
}

.mobile-categories .category-btn {
    white-space: nowrap;
    min-width: auto;
}

/* Gallery */
.gallery-container {
    min-height: 400px;
}

.category {
    margin-bottom: 50px;
}

.category-title {
    color: white;
    font-size: 1.6rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid rgba(255, 255, 255, 0.3);
    text-transform: capitalize;
}

.grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
}

.card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
}

.card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.card-body {
    padding: 12px;
}

.card-title {
    font-size: 0.9rem;
    color: #333;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Lightbox Améliorée */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.97);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.lightbox-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.lightbox-controls {
    position: absolute;
    top: -60px;
    right: 0;
    display: flex;
    gap: 10px;
}

.lightbox-btn {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.lightbox-btn:hover {
    background: white;
    transform: scale(1.1);
}

.lightbox-download {
    background: #4CAF50;
    color: white;
}

.lightbox-download:hover {
    background: #45a049;
}

.lightbox-close {
    background: #f44336;
    color: white;
}

.lightbox-close:hover {
    background: #da190b;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: none;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.lightbox-nav:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 30px;
}

.lightbox-next {
    right: 30px;
}

.lightbox-caption {
    margin-top: 20px;
    text-align: center;
    color: white;
    font-size: 1.1rem;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.lightbox-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lightbox-name {
    font-weight: 700;
    font-size: 1.2rem;
}

.lightbox-category {
    font-size: 0.95rem;
    opacity: 0.9;
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: white;
    font-size: 1.2rem;
}

.loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

.empty-message {
    text-align: center;
    color: white;
    font-size: 1.2rem;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1024px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-categories {
        display: block;
    }

    .grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .card-image {
        height: 180px;
    }
}

@media (max-width: 768px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
    }

    .upload-btn {
        justify-content: center;
    }

    .card-image {
        height: 200px;
    }

    .lightbox-nav {
        width: 45px;
        height: 45px;
        font-size: 24px;
    }

    .lightbox-prev {
        left: 15px;
    }

    .lightbox-next {
        right: 15px;
    }

    .lightbox-controls {
        top: -55px;
        gap: 8px;
    }

    .lightbox-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0;
    }

    .main-content {
        padding: 15px;
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .card-image {
        height: 250px;
    }

    .lightbox-content {
        max-width: 98%;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-controls {
        top: auto;
        bottom: -55px;
        right: 50%;
        transform: translateX(50%);
    }
}
