/* =========================================
   1. RESET & BASES
   ========================================= */
:root {
    --primary: #000;
    --bg: #f2f2f2;
    --text: #333;
    --glass: rgba(255, 255, 255, 0.95);
    --shadow: 0 10px 30px rgba(0,0,0,0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden; /* App Mode par défaut */
    position: fixed; width: 100%; height: 100%;
}

a { text-decoration: none; color: inherit; transition: 0.3s; }
button, input { font-family: inherit; outline: none; }

/* =========================================
   2. NAVIGATION & HEADER
   ========================================= */
nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 20px; background: #fff; position: sticky; top: 0; z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.logo { font-size: 1.4rem; font-weight: 700; }
.logo span { color: #777; }

/* --- MOBILE PAR DÉFAUT : On cache les liens et le bouton Créer --- */
.nav-links { display: none; } 

/* Bouton Hamburger (Visible sur mobile) */
.hamburger-btn {
    display: block; 
    background: none; border: none; 
    font-size: 1.5rem; color: var(--primary); 
    cursor: pointer;
}

/* Menu Plein Écran (Overlay) */
.mobile-menu-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.98);
    z-index: 2000;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 40px;
    opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s;
}
.mobile-menu-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; }
.mobile-menu-overlay a { font-size: 2rem; font-weight: 700; color: var(--primary); }
.mobile-menu-overlay .cta-mobile { background: var(--primary); color: #fff; padding: 15px 40px; border-radius: 50px; font-size: 1.2rem; }
.close-menu-btn { position: absolute; top: 20px; right: 20px; background: none; border: none; font-size: 2rem; color: #888; cursor: pointer; }

/* =========================================
   3. ACCUEIL (Hero)
   ========================================= */
.hero {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 80px 5% 40px 5%; gap: 30px; background: #f8f9fa;
    overflow-y: auto; height: 100%;
}
.hero-text h1 { font-size: 2.5rem; line-height: 1.2; margin-bottom: 15px; font-weight: 800; }
.hero-image {
    width: 100%; height: 350px; position: relative; border-radius: 20px; overflow: hidden;
    box-shadow: 10px 10px 0 #eee; flex-shrink: 0;
}
.slideshow-img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1s; }
.slideshow-img.active { opacity: 1; }
.btn-main { display: inline-block; background: #000; color: #fff; padding: 12px 30px; border-radius: 50px; font-weight: 600; margin-top: 10px; }

/* =========================================
   4. GALERIE
   ========================================= */
.gallery-section { padding: 40px 5%; text-align: center; }
.mosaic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 20px; }
.mosaic-item { aspect-ratio: 1/1; border-radius: 10px; overflow: hidden; position: relative; cursor: pointer; }
.mosaic-item img { width: 100%; height: 100%; object-fit: cover; transition: 0.3s; }

#lightbox-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); z-index: 3000; display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: 0.3s; }
#lightbox-modal.active { opacity: 1; pointer-events: auto; }
#lightbox-image { max-width: 95%; max-height: 65vh; border-radius: 5px; margin-bottom: 20px; }
.lightbox-footer { text-align: center; color: white; z-index: 3001; }
.lightbox-footer h3 { font-size: 1.2rem; margin-bottom: 10px; font-weight: 700; }
.nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.1); color: white; width: 50px; height: 50px; border-radius: 50%; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; }
.prev { left: 20px; } .next { right: 20px; }
.close-btn { position: absolute; top: 20px; right: 20px; color: #fff; background: none; border: none; font-size: 2rem; cursor: pointer; }

/* =========================================
   5. STUDIO 3D & SHARE
   ========================================= */
.studio-body { background: #eef0f4; }
#canvas-container { width: 100%; height: 100%; outline: none; }

/* Studio Header */
.studio-header {
    position: absolute; top: 0; left: 0; width: 100%;
    padding: 15px 20px; display: flex; justify-content: space-between; align-items: center;
    z-index: 50; pointer-events: none;
}
.studio-header > * { pointer-events: auto; }
.back-btn { width: 40px; height: 40px; background: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(0,0,0,0.1); color: #000; }
.back-btn span { display: none; }
.logo-small { font-weight: 800; font-size: 1.2rem; background: rgba(255,255,255,0.8); backdrop-filter: blur(5px); padding: 5px 15px; border-radius: 20px; }
.btn-save { background: #000; color: #fff; border: none; padding: 10px 20px; border-radius: 30px; font-weight: 600; font-size: 0.85rem; box-shadow: 0 4px 10px rgba(0,0,0,0.2); cursor: pointer; display: flex; align-items: center; gap: 5px; }

/* BARRE D'OUTILS (DOCK MOBILE) */
.mobile-dock-panel {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: #fff; border-radius: 25px 25px 0 0;
    padding: 15px 20px 35px 20px; /* Marge iPhone */
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    z-index: 100;
    display: flex; justify-content: space-around; align-items: center;
    top: auto !important; transform: none !important;
}
.mobile-dock-panel h3, .hint, .tool-item label { display: none !important; }
.tool-item { margin: 0; position: relative; }

/* Boutons Ronds */
.custom-btn-round {
    width: 55px; height: 55px; border-radius: 18px; background: #fff; border: 1px solid #eee;
    display: flex !important; align-items: center; justify-content: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05); position: relative; overflow: hidden; cursor: pointer;
}
.custom-btn-round i { font-size: 1.5rem; color: #333; z-index: 2; }
input[type="file"], input[type="color"] { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; padding: 0; border: none; }
.color-wrapper { background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red); }

/* PANNEAUX ÉDITION */
.secondary-panel {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: #fff; border-radius: 25px 25px 0 0;
    padding: 20px 20px 40px 20px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.15); z-index: 101;
    display: none; flex-direction: column; gap: 15px;
    top: auto !important; transform: none !important;
}
.secondary-panel h3 { display: none !important; }
.sliders-container { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.secondary-panel label { display: flex !important; font-size: 0.65rem; color: #888; justify-content: space-between; width: 100%; font-weight: 600; }
input[type=range] { width: 100%; height: 4px; background: #e0e0e0; border-radius: 10px; appearance: none; margin: 2px 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; background: #000; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.action-buttons { display: flex; gap: 10px; }
.btn-action { width: 100%; height: 45px; border: none; border-radius: 15px; font-size: 1rem; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* Spécifique Peinture */
.paint-row { display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.brush-preview { width: 25px; height: 25px; border-radius: 50%; background: #000; border: 2px solid #ddd; }

/* BIBLIOTHÈQUE */
#sticker-library {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: #fff; border-radius: 25px 25px 0 0;
    padding: 20px; box-shadow: 0 -10px 40px rgba(0,0,0,0.25);
    z-index: 102; display: none; flex-direction: column; max-height: 60vh;
}
.library-header { display: flex; justify-content: space-between; border-bottom: 1px solid #eee; padding-bottom: 10px; margin-bottom: 10px; cursor: grab; }
.library-header h3 { font-size: 0.9rem; text-transform: uppercase; font-weight: 800; color: #333; margin: 0; display: block !important; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 12px; overflow-y: auto; padding: 5px; }
.sticker-item { aspect-ratio: 1/1; background: #f9f9f9; border: 1px solid #eee; border-radius: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.sticker-item img { width: 80%; height: 80%; object-fit: contain; pointer-events: none; }
.upload-card { background: #000 !important; color: #fff !important; flex-direction: column; }
.upload-card span { font-size: 0.6rem; font-weight: 700; margin-top: 4px; text-transform: uppercase; }

/* Page Partage */
.share-container { max-width: 800px; margin: 40px auto; padding: 20px; background: #fff; border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.1); }
.share-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; margin-bottom: 20px; }
.share-img { width: 100%; border-radius: 10px; border: 1px solid #eee; cursor: zoom-in; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 5px; color: #555; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 12px; border: 2px solid #eee; border-radius: 10px; font-family: 'Poppins', sans-serif; font-size: 0.95rem; }
.btn-send { width: 100%; background: #000; color: #fff; padding: 15px; border: none; border-radius: 50px; font-size: 1rem; font-weight: 600; cursor: pointer; }

/* =========================================
   7. MODE PC (> 900px)
   ========================================= */
@media (min-width: 900px) {
    /* Navigation PC */
    nav { padding: 15px 5%; }
    .hamburger-btn { display: none; } /* Cache hamburger */
    
    /* Réaffiche le menu complet sur PC */
    .nav-links { 
        display: flex !important; 
        align-items: center !important; 
        gap: 35px; height: 100%;
    }
    
    /* Les liens textes */
    .nav-links a:not(.cta-nav) { 
        display: block; font-size: 1rem; font-weight: 500; color: var(--text);
    }
    
    /* Le bouton Créer aligné */
    .cta-nav {
        display: inline-flex !important; align-items: center !important; justify-content: center !important;
        background-color: #000 !important; color: #fff !important;
        padding: 10px 25px !important; border-radius: 30px !important;
        font-size: 0.95rem !important; font-weight: 600 !important; line-height: 1;
    }

    /* Hero PC */
    .hero { flex-direction: row; text-align: left; padding: 0 10%; gap: 60px; overflow: hidden; }
    .hero-text { flex: 1; max-width: 600px; }
    .hero-image { flex: 1; height: 550px; }
    .hero-text h1 { font-size: 4rem; }

    /* Studio 3D PC */
    .studio-header { padding: 20px 40px; }
    .back-btn { width: auto; height: auto; padding: 10px 25px; border-radius: 30px; }
    .back-btn span { display: inline; margin-left: 10px; font-weight: 600; }

    /* Sidebar Gauche */
    .mobile-dock-panel {
        position: absolute !important; bottom: auto !important; top: 50% !important;
        width: 280px !important; border-radius: 20px !important;
        flex-direction: column; padding: 30px; gap: 25px;
        transform: translateY(-50%) !important;
        box-shadow: 0 10px 40px rgba(0,0,0,0.08);
        left: 40px !important; right: auto !important;
    }
    .mobile-dock-panel h3 { display: block !important; width: 100%; font-size: 0.8rem; text-transform: uppercase; color: #999; border-bottom: 1px solid #eee; margin-bottom: 15px; padding-bottom: 10px; cursor: move; }
    .tool-item label { display: block !important; font-size: 0.9rem; font-weight: 600; margin-bottom: 10px; }
    .tool-item { margin-bottom: 20px; width: 100%; }

    .custom-btn-round { width: 100%; height: auto; padding: 15px 20px; border-radius: 12px; justify-content: flex-start; gap: 15px; font-size: 0.95rem; font-weight: 500; background: #fff; border: 1px solid #e0e0e0; box-shadow: none; }
    .custom-btn-round i { font-size: 1.2rem; }
    #open-library-btn::after { content: "Bibliothèque Stickers"; color: #555; }
    #paint-mode-btn::after { content: "Mode Dessin"; color: #555; }
    #text-mode-btn::after { content: "Ajouter Texte"; color: #555; }
    #color-btn-visual::after { content: "Couleur Principale"; color: #555; }
    
    input[type="file"] { position: static; opacity: 1; width: auto; height: auto; margin-top: 5px; pointer-events: auto; }
    .color-wrapper { width: 100%; height: 40px; border-radius: 8px; background: none; border: 1px solid #ddd; }
    input[type="color"] { width: 100%; height: 100%; opacity: 1; top: 0; left: 0; }

    /* Sidebar Droite */
    .secondary-panel {
        position: absolute !important; bottom: auto !important; top: 50% !important; 
        right: 40px !important; left: auto !important; 
        width: 280px !important; border-radius: 20px !important;
        transform: translateY(-50%) !important; display: none; 
        flex-direction: column; padding: 30px; background: rgba(255,255,255,0.95);
        box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    }
    .secondary-panel h3 { display: block !important; font-size: 0.8rem !important; margin-bottom: 15px !important; text-transform: uppercase; color:#999; border-bottom:1px solid #eee; padding-bottom:10px; cursor:move; }
    .sliders-container { gap: 20px; }
    input[type=range] { height: 6px; margin: 10px 0; }
    .action-buttons { width: 100%; gap: 15px; }
    .btn-action { width: auto; flex: 1; height: auto; padding: 12px; border-radius: 10px; }

    #sticker-library { width: 450px; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 20px; max-height: 80vh; }
}

/* Loader */
#loader-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #fff; z-index: 9999; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.spinner { width: 40px; height: 40px; border: 4px solid #eee; border-top-color: #000; border-radius: 50%; animation: spin 1s infinite; }
@keyframes spin { to { transform: rotate(360deg); } }