:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --bg: #f8fafc;
    --card: #ffffff;
    --text-main: #0f172a;
    --text-sub: #64748b;
    --danger: #ef4444;
    --border: #e2e8f0;
}

/* Transition douce pour tout le site */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}


/* Variables pour le Mode Sombre */
[data-theme="dark"] {
    --bg: #0f172a;
    --card: #1e293b;
    --text-main: #f1f5f9;
    --text-sub: #94a3b8;
    --border: #334155;
}

/* Positionnement du bouton en haut à droite */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    z-index: 1001; /* Pour rester au-dessus de tout */
}
.theme-toggle:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

/* On s'assure que le container parent permet le positionnement absolu */
body {
    position: relative;
    min-height: 100vh;
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    margin: 0; 
    display: flex; 
    justify-content: center; 
    padding: 40px 20px;
}

.app-container { width: 100%; max-width: 1100px; }

header { text-align: center; margin-bottom: 30px; }
.logo { font-size: 26px; font-weight: 800; letter-spacing: -1px; }
.logo span { color: var(--primary); }
.subtitle { color: var(--text-sub); margin-top: 5px; font-size: 14px; }

/* --- ZONE UPLOAD --- */
.upload-section {
    background: var(--card); border: 3px dashed #cbd5e1; border-radius: 24px;
    padding: 60px 20px; text-align: center; transition: all 0.3s ease;
}
.upload-section.highlight { border-color: var(--primary); background: #eef2ff; }
.upload-card { cursor: pointer; display: block; }
.icon-circle { font-size: 40px; margin-bottom: 15px; }

.format-badges { display: flex; justify-content: center; gap: 8px; margin-top: 15px; }
.badge { 
    background: #e0e7ff; color: var(--primary); 
    padding: 6px 14px; border-radius: 20px; 
    font-size: 12px; font-weight: 700; 
}

/* --- GRID EDITOR --- */
.editor-grid { display: grid; grid-template-columns: 1fr 340px; gap: 30px; }

.preview-card {
    background: var(--card); border-radius: 24px; padding: 25px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05); 
    display: flex; flex-direction: column; /* Aligne canvas + hint verticalement */
    justify-content: center; align-items: center; min-height: 500px;
}

.canvas-wrapper {
    border-radius: 12px; overflow: hidden;
    background-image: linear-gradient(45deg, #eee 25%, transparent 25%), 
                      linear-gradient(-45deg, #eee 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #eee 75%), 
                      linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 16px 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

canvas { 
    max-width: 100%; height: auto; display: block; 
    cursor: crosshair; /* Curseur pipette */
    transition: transform 0.1s ease;
}
canvas:active { transform: scale(0.99); }

.canvas-hint {
    margin-top: 20px; font-size: 13px; color: var(--text-sub);
    background: #f1f5f9; padding: 8px 16px; border-radius: 12px;
    font-weight: 600;
}

/* --- SIDEBAR & CONTROLS --- */
.sidebar { display: flex; flex-direction: column; gap: 20px; }
.control-group { background: var(--card); padding: 20px; border-radius: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.control-group h3 { margin: 0 0 15px 0; font-size: 13px; text-transform: uppercase; color: var(--text-sub); letter-spacing: 0.5px; }

.label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 600; font-size: 14px; }

/* Pastille de couleur sélectionnée */
#color-preview {
    width: 24px; height: 24px; border-radius: 6px;
    border: 2px solid #e2e8f0; background-color: transparent;
    transition: background-color 0.3s ease;
}

input[type=range] { width: 100%; accent-color: var(--primary); cursor: pointer; }
.hint { display: block; margin-top: 8px; font-size: 11px; color: var(--text-sub); }

.resize-inputs { display: flex; gap: 10px; margin-bottom: 12px; }
.input-box { flex: 1; }
.input-box label { display: block; font-size: 10px; color: var(--text-sub); margin-bottom: 4px; font-weight: 700; }
.input-box input { 
    width: 100%; padding: 10px; border-radius: 10px; 
    border: 1px solid #e2e8f0; font-weight: 700; box-sizing: border-box;
}

.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-sub); cursor: pointer; }

select { 
    width: 100%; padding: 12px; border-radius: 12px; 
    border: 1px solid #e2e8f0; font-weight: 600; font-family: inherit;
    margin-bottom: 10px; cursor: pointer; 
}
.file-info { font-size: 12px; color: var(--primary); font-weight: 700; text-align: right; }

/* --- BOUTONS --- */
.btn-primary {
    background: var(--primary); color: white; border: none; width: 100%; padding: 18px;
    border-radius: 18px; font-weight: 800; font-size: 16px; cursor: pointer; transition: 0.2s;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}
.btn-primary:hover { background: var(--primary-light); transform: translateY(-2px); }

.btn-row { display: flex; gap: 10px; margin-top: 10px; }
.btn-ghost { 
    flex: 1; background: #fff; border: 1px solid #e2e8f0; 
    padding: 12px; border-radius: 14px; cursor: pointer; 
    font-weight: 700; font-size: 12px; transition: 0.2s;
}
.btn-ghost:hover { background: #f8fafc; border-color: var(--primary); color: var(--primary); }
.btn-ghost.danger:hover { color: var(--danger); border-color: var(--danger); background: #fef2f2; }

/* --- AIDE & MODAL --- */
.help-trigger {
    position: fixed; bottom: 20px; right: 20px;
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--primary); color: white; border: none;
    font-weight: 800; font-size: 20px; cursor: pointer;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 1000;
}
.help-trigger:hover { transform: scale(1.1) rotate(10deg); }

.modal {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px); display: flex;
    align-items: center; justify-content: center; z-index: 2000;
}
.modal-content {
    background: white; padding: 40px; border-radius: 28px;
    max-width: 500px; width: 90%; position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.close-modal {
    position: absolute; top: 20px; right: 25px;
    font-size: 28px; cursor: pointer; color: var(--text-sub);
}

.help-grid { display: flex; flex-direction: column; gap: 20px; margin-top: 25px; }
.help-item h4 { margin: 0 0 6px 0; color: var(--primary); font-size: 16px; }
.help-item p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text-sub); }

/* --- RESPONSIVE --- */
@media (max-width: 950px) { 
    .editor-grid { grid-template-columns: 1fr; } 
    .sidebar { order: 2; }
    .preview-card { order: 1; min-height: 400px; }
}

.seo-content {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid #e2e8f0;
    text-align: left;
}

.seo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.seo-content h3 {
    color: var(--primary);
    font-size: 18px;
    margin-bottom: 12px;
}

.seo-content p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-sub);
}

.seo-content strong {
    color: var(--text-main);
}
.share-section {
    margin-top: 10px;
    padding: 15px;
    text-align: center;
    border-top: 1px solid #f1f5f9;
}

.share-section p {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-sub);
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.share-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.share-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    text-decoration: none;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.1);
}

.app-footer {
    margin-top: 50px;
    padding: 30px;
    text-align: center;
    color: var(--text-sub);
    font-size: 14px;
    border-top: 1px solid #e2e8f0;
    width: 100%;
}

.app-footer strong {
    color: var(--primary);
    font-weight: 800;
}

.footer-links {
    margin-top: 8px;
}

.footer-links a {
    color: var(--text-sub);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

/* Petit ajustement pour le subtitle du header */
.subtitle strong {
    color: var(--text-main);
}

/* Transition globale douce sur les couleurs */
body, .control-group, .preview-card, header, footer, .upload-section {
    transition: background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                color 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                border-color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Effet au survol du bouton en haut à droite */
.theme-toggle:active {
    transform: scale(0.95);
}

/* Adaptation du damier de transparence selon le thème */
[data-theme="dark"] .canvas-wrapper {
    background-image: linear-gradient(45deg, #1e293b 25%, transparent 25%), 
                      linear-gradient(-45deg, #1e293b 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #1e293b 75%), 
                      linear-gradient(-45deg, transparent 75%, #1e293b 75%);
    background-color: #0f172a; /* Fond du damier plus sombre */
    border: 1px solid var(--primary);
}

[data-theme="dark"] .canvas-hint {
    background: #1e293b;
    color: var(--primary-light);
}

/* Style du conteneur de navigation */
.main-nav {
    display: flex;
    gap: 15px;
    padding: 20px;
    background-color: transparent;
    border-radius: 12px;
    justify-content: center;
}



/* Style du bouton INACTIF (par défaut) */
.nav-link {
    text-decoration: none;
    color: #555;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 500;
    padding: 10px 22px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
    
    /* Le contour du bouton inactif */
    border: 2px solid #e0e0e0; 
    background-color: transparent;
}

/* Effet au survol du bouton inactif */
.nav-link:hover {
    border-color: #b0b0b0; /* Le contour fonce un peu */
    background-color: rgba(0, 0, 0, 0.02);
    color: #222;
}

/* Style du bouton ACTIF */
.nav-link.active {
    border-color: #007AFF; /* Couleur d'accentuation (Bleu iOS/Moderne) */
    color: #007AFF;
    background-color: rgba(0, 122, 255, 0.05); /* Très léger fond coloré */
    font-weight: 600;
}
