/**
 * ═══════════════════════════════════════════════════════════════════════════
 * EDUBLOC - Styles principaux
 * ═══════════════════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════════════════
   VARIABLES CSS
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    /* Couleurs principales */
    --color-primary: #10b981;
    --color-primary-dark: #059669;
    --color-primary-light: #d1fae5;
    
    /* Couleurs de l'interface */
    --color-background: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    
    /* Couleurs de texte */
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;
    
    /* Couleurs de statut */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;
    
    /* Ombres */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Dimensions */
    --header-height: 56px;
    --toolbar-height: 48px;
    --footer-height: 32px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    
    /* Rayons de bordure */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESET ET BASE
   ═══════════════════════════════════════════════════════════════════════════ */

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-background);
    display: flex;
    flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════════════════════
   EN-TÊTE
   ═══════════════════════════════════════════════════════════════════════════ */

.header {
    height: var(--header-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    flex-shrink: 0;
}

.header__left,
.header__right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header__left {
    min-width: 200px;
}

.header__center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.header__right {
    min-width: 200px;
    justify-content: flex-end;
}

.header__back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.header__back:hover {
    background: var(--color-background);
    color: var(--color-text);
}

.header__app {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header__icon {
    font-size: 24px;
}

.header__app-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--color-primary);
}

.header__title-input {
    width: 300px;
    max-width: 100%;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    background: transparent;
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.header__title-input:hover {
    background: var(--color-background);
}

.header__title-input:focus {
    outline: none;
    background: var(--color-surface);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.header__status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    background: var(--color-background);
    font-size: 12px;
    color: var(--color-text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-muted);
    transition: background var(--transition-fast);
}

.header__status.saving .status-dot {
    background: var(--color-warning);
    animation: pulse 1s infinite;
}

.header__status.saved .status-dot {
    background: var(--color-success);
}

.header__status.error .status-dot {
    background: var(--color-error);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.header__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header__btn:hover {
    background: var(--color-background);
    color: var(--color-text);
}

.header__btn:active {
    transform: scale(0.95);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BARRE D'OUTILS
   ═══════════════════════════════════════════════════════════════════════════ */

.toolbar {
    height: var(--toolbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 4px;
    flex-shrink: 0;
    overflow-x: auto;
}

.toolbar__group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.toolbar__separator {
    width: 1px;
    height: 24px;
    background: var(--color-border);
    margin: 0 8px;
}

.toolbar__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toolbar__btn:hover {
    background: var(--color-background);
    color: var(--color-text);
}

.toolbar__btn:active {
    transform: scale(0.95);
}

.toolbar__btn.active {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.toolbar__select {
    height: 32px;
    padding: 0 28px 0 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 13px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: all var(--transition-fast);
}

.toolbar__select:hover {
    border-color: var(--color-primary);
}

.toolbar__select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* ═══════════════════════════════════════════════════════════════════════════
   ZONE D'ÉDITION
   ═══════════════════════════════════════════════════════════════════════════ */

.editor-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    justify-content: center;
    padding: 24px;
    background: var(--color-background);
}

.editor {
    width: 100%;
    max-width: 800px;
    min-height: 100%;
    padding: 48px 64px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow-y: auto;
    outline: none;
    font-size: 16px;
    line-height: 1.8;
    color: var(--color-text);
}

.editor:focus {
    box-shadow: var(--shadow-lg);
}

.editor p {
    margin-bottom: 1em;
}

.editor p:last-child {
    margin-bottom: 0;
}

.editor:empty::before {
    content: "Commencez à écrire...";
    color: var(--color-text-muted);
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PIED DE PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.footer {
    height: var(--footer-height);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 12px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

.footer__left,
.footer__right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer__separator {
    color: var(--color-text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODALES
   ═══════════════════════════════════════════════════════════════════════════ */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal__container {
    position: relative;
    width: 90%;
    max-width: 400px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.modal__title {
    font-size: 16px;
    font-weight: 600;
}

.modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal__close:hover {
    background: var(--color-background);
    color: var(--color-text);
}

.modal__body {
    padding: 20px;
    color: var(--color-text-secondary);
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
    background: var(--color-background);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BOUTONS
   ═══════════════════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn--primary {
    background: var(--color-primary);
    color: white;
}

.btn--primary:hover {
    background: var(--color-primary-dark);
}

.btn--secondary {
    background: var(--color-background);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn--secondary:hover {
    background: var(--color-border-light);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOASTS
   ═══════════════════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.toast.hiding {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast__icon {
    font-size: 18px;
}

.toast__message {
    font-size: 14px;
    color: var(--color-text);
}

.toast--success .toast__icon { color: var(--color-success); }
.toast--error .toast__icon { color: var(--color-error); }
.toast--warning .toast__icon { color: var(--color-warning); }
.toast--info .toast__icon { color: var(--color-info); }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .header {
        padding: 0 12px;
        gap: 8px;
    }
    
    .header__left {
        min-width: auto;
    }
    
    .header__app-name {
        display: none;
    }
    
    .header__title-input {
        width: 150px;
        font-size: 14px;
    }
    
    .header__right {
        min-width: auto;
    }
    
    .header__status .status-text {
        display: none;
    }
    
    .editor-container {
        padding: 12px;
    }
    
    .editor {
        padding: 24px;
        border-radius: var(--radius-md);
    }
    
    .toolbar {
        padding: 0 8px;
    }
    
    .toolbar__separator {
        margin: 0 4px;
    }
}

@media (max-width: 480px) {
    .toolbar__select {
        width: 80px;
        padding-left: 8px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   BOUTON DE CORRECTION IA
   ═══════════════════════════════════════════════════════════════════════════ */

.ai-quick-btn {
    position: absolute;
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    z-index: 999;
    white-space: nowrap;
    transition: all 0.2s ease;
    opacity: 0;
    transform: translateY(-5px) scale(0.9);
    pointer-events: none;
}

.ai-quick-btn.visible {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ai-quick-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.ai-quick-btn:active {
    transform: translateY(0) scale(1);
}

.ai-quick-btn.processing {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    cursor: wait;
}

.ai-quick-btn__icon {
    font-size: 16px;
}

.ai-quick-btn__spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
