@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

:root {
    --bg-app: #0f172a; --bg-sidebar: #1e293b; --bg-card: #1e293b; --bg-input: #334155;
    --text-main: #f1f5f9; --text-muted: #94a3b8; --border: #475569;
    --primary: #3b82f6; --success: #10b981; --danger: #ef4444;
}
body.light-mode {
    --bg-app: #f3f4f6; --bg-sidebar: #ffffff; --bg-card: #ffffff; --bg-input: #f9fafb;
    --text-main: #1f2937; --text-muted: #6b7280; --border: #e5e7eb;
}
* { box-sizing: border-box; outline: none; }
body { margin: 0; font-family: 'Inter', sans-serif; background: var(--bg-app); color: var(--text-main); height: 100vh; display: flex; overflow: hidden; }

/* Sidebar */
.sidebar { width: 260px; background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px; flex-shrink: 0; }
.logo { font-size: 1.25rem; font-weight: 700; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }
.logo span { color: var(--primary); }
.user-info { padding: 10px; background: rgba(255,255,255,0.05); border-radius: 8px; margin-bottom: 20px; font-size: 0.85rem; display: flex; gap: 10px; align-items: center;}
.btn-new { background: var(--primary); color: white; border: none; padding: 12px; border-radius: 8px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; width: 100%; }
.project-list { flex: 1; overflow-y: auto; margin-top: 20px; }
.project-item { padding: 10px; cursor: pointer; display: flex; justify-content: space-between; color: var(--text-muted); border-radius: 6px; }
.project-item:hover { background: rgba(255,255,255,0.05); }
.project-item.active { background: rgba(59, 130, 246, 0.2); color: var(--primary); }
.theme-toggle { cursor: pointer; padding: 10px 0; color: var(--text-muted); display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.theme-toggle:hover { color: var(--text-main); }

/* Main */
.editor-wrapper { flex: 1; display: flex; flex-direction: column; }
.editor-toolbar { height: 70px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; padding: 0 40px; background: var(--bg-app); }
#script-title { background: transparent; border: none; color: var(--text-main); font-size: 1.5rem; font-weight: 700; width: 60%; }
.actions { display: flex; gap: 10px; }
.btn-action { padding: 8px 16px; border-radius: 8px; border: none; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 5px; }
.btn-save { background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border); }
.btn-export { background: var(--success); color: white; }

.editor-content { flex: 1; overflow-y: auto; padding: 40px; }
.blocks-container { max-width: 800px; margin: 0 auto; padding-bottom: 100px; }
.section-label { text-align: center; margin: 40px 0 20px; font-size: 0.8rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }

/* Blocks */
.block-group { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; position: relative; }
.block-group::before { content: ''; position: absolute; left: 0; top: 20px; bottom: 20px; width: 4px; border-radius: 0 4px 4px 0; }
.hook::before { background: #f59e0b; } .body-content::before { background: #3b82f6; }
.cta::before { background: #ec4899; } .sponsor::before { background: #10b981; } .conclusion::before { background: #8b5cf6; }

.block-header { display: flex; align-items: center; margin-bottom: 15px; padding-left: 10px; }
.block-header h3 { margin: 0; font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; }
textarea { width: 100%; background: var(--bg-input); border: 1px solid transparent; color: var(--text-main); padding: 15px; border-radius: 8px; min-height: 100px; resize: vertical; font-family: inherit; }
textarea:focus { border-color: var(--primary); }
.large-area { min-height: 300px; }
.word-counter-badge { font-size: 0.75rem; margin-left: 10px; background: rgba(255,255,255,0.1); padding: 2px 8px; border-radius: 10px; color: var(--text-muted); }

/* Tooltip & Login & Modal */
.tooltip { margin-left: 10px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 12px; cursor: help; position: relative; }
.tooltip:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; right: -10px; background: #0f172a; border: 1px solid var(--border); padding: 10px; border-radius: 6px; width: 250px; z-index: 100; font-size: 0.85rem; pointer-events: none; }

/* PAGE LOGIN CORRIGÉE */
.login-page { display: flex; align-items: center; justify-content: center; width: 100%; height: 100vh; overflow: hidden; }
.login-container { 
    width: 90%; /* Prend 90% de la largeur sur mobile */
    max-width: 400px; /* Mais ne dépasse jamais 400px */
    background: var(--bg-card); 
    padding: 40px; 
    border-radius: 12px; 
    border: 1px solid var(--border); 
}
.form-group { margin-bottom: 15px; } .form-group label { display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 0.9rem; }
.form-group input { width: 100%; background: var(--bg-input); border: 1px solid var(--border); padding: 10px; border-radius: 6px; color: var(--text-main); }
.switch-auth { text-align: center; font-size: 0.9rem; margin-top: 20px; } .switch-auth a { color: var(--primary); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 999; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-box { background: var(--bg-card); padding: 30px; border-radius: 12px; width: 90%; max-width: 600px; border: 1px solid var(--border); }
.modal-header { display: flex; justify-content: space-between; margin-bottom: 20px; }
.close-modal { cursor: pointer; }

/* AJOUTS IA */
.btn-ai-magic {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-right: 15px;
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.4);
    transition: transform 0.2s;
}
.btn-ai-magic:hover { transform: scale(1.05); box-shadow: 0 6px 15px rgba(168, 85, 247, 0.6); }

/* --- GESTION AFFICHAGE DESKTOP --- */
@media (min-width: 769px) {
    .sidebar-header-row { display: block; }
    .header-icons { display: none; }
    .sidebar-actions-row { display: block; }
    #mobile-menu-btn { display: none !important; }
    .btn-new { margin-top: 0; width: 100%; }
    .project-list { position: relative; top: auto; width: auto; background: transparent; box-shadow: none; display: block !important; border: none; }
}

/* =========================================
   RESPONSIVE MOBILE
   ========================================= */
@media (max-width: 768px) {
    body { flex-direction: column; height: auto; overflow-y: auto; }

    /* Login sur mobile : moins de padding pour gagner de la place */
    .login-container { padding: 25px; }

    .sidebar {
        width: 100%; height: auto; padding: 10px 15px; border-right: none; border-bottom: 1px solid var(--border);
        display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 100;
    }

    .sidebar-header-row { display: flex; justify-content: space-between; align-items: center; width: 100%; }
    .logo { margin-bottom: 0; font-size: 1.1rem; }
    
    .header-icons { display: flex; gap: 15px; }
    .header-icons .theme-toggle { padding: 0; font-size: 0; }
    .header-icons .theme-toggle span { font-size: 1.5rem; margin: 0; }

    .sidebar-actions-row { display: flex; gap: 10px; width: 100%; }

    #mobile-menu-btn {
        display: flex !important; flex: 0.4; justify-content: center;
        background: var(--bg-input); border: 1px solid var(--border); color: var(--text-main);
        padding: 10px; border-radius: 8px; align-items: center; gap: 5px; font-weight: 600;
    }
    .btn-new {
        flex: 0.6; width: auto !important; justify-content: center; margin-top: 0 !important;
        padding: 10px; font-size: 0.9rem;
    }

    .sidebar .project-list {
        display: none; position: absolute; top: 100%; left: 0; width: 100%; max-height: 300px;
        overflow-y: auto; background: var(--bg-card); border-bottom: 1px solid var(--primary);
        box-shadow: 0 10px 20px rgba(0,0,0,0.5); padding: 10px; z-index: 999;
    }
    .sidebar .project-list.open { display: block; }

    .desktop-only { display: none !important; }

    .editor-wrapper { width: 100%; height: auto; overflow: visible; }
    .editor-toolbar { height: auto; flex-direction: column; gap: 15px; padding: 15px; margin-top: 0; }
    #script-title { width: 100%; text-align: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
    .actions { width: 100%; justify-content: space-between; flex-wrap: wrap; }
    .btn-action { flex: 1; justify-content: center; padding: 12px; }
    .btn-ai-magic { width: 100%; justify-content: center; margin-right: 0; margin-bottom: 10px; }
    
    .editor-content { padding: 15px; overflow: visible; }
    .blocks-container { padding-bottom: 60px; }
    textarea { font-size: 16px !important; }
    
    .modal-box { width: 95%; max-height: 90vh; }
}


/* Checkbox pour la sélection Audio */
.audio-check {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
    accent-color: var(--success); /* La case sera verte quand cochée */
    vertical-align: middle;
}