:root {
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent-primary: #0071e3;
    --accent-hover: #0077ed;
    
    /* Couleurs pour les types de fautes */
    --error-spelling: #ff3b30;
    --error-spelling-bg: rgba(255, 59, 48, 0.15);
    --error-grammar: #ff9f0a;
    --error-grammar-bg: rgba(255, 159, 10, 0.15);
    --error-style: #32ade6;
    --error-style-bg: rgba(50, 173, 230, 0.15);
    
    --editor-padding: 2rem;
    --editor-font: 18px/1.7 'Inter', sans-serif;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 2rem;
    background-color: #f5f5f7;
}

/* Glassmorphism Container */
.container {
    display: flex;
    flex: 1;
    padding: 1.5rem;
    height: 100%;
    max-width: 1000px; /* Centré, plus étroit comme une page Word */
    width: 100%;
    
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

.panel {
    flex: 1;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3), 0 4px 15px rgba(0,0,0,0.03);
    position: relative;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.4);
}

.panel-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.actions {
    display: flex;
    gap: 0.75rem;
}

.btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 9px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn.primary {
    background-color: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}
.btn.primary:hover { 
    background-color: var(--accent-hover); 
    transform: translateY(-1px);
}

.btn.outline {
    background-color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0,0,0,0.1);
    color: var(--text-primary);
}
.btn.outline:hover { background-color: white; }

/* 
 * SUPERPOSITION (OVERLAY) POUR CORRECTION TEMPS RÉEL 
 */
.editor-container {
    position: relative;
    flex: 1;
    overflow: hidden; 
}

.backdrop, .textarea {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: var(--editor-padding);
    font: var(--editor-font) !important;
    font-family: 'Inter', sans-serif !important;
    letter-spacing: 0px !important;
    word-spacing: 0px !important;
    text-transform: none !important;
    text-indent: 0 !important;
    border: none;
    outline: none;
    overflow-y: scroll;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

.backdrop {
    z-index: 1;
    color: var(--text-primary); 
    background-color: transparent;
}

.textarea {
    z-index: 2;
    background-color: transparent;
    color: transparent !important; /* Solution 100% garantie : on cache le texte natif */
    caret-color: var(--text-primary) !important; /* Mais on garde le curseur clignotant */
    resize: none;
}

.textarea::placeholder {
    color: #a1a1a6 !important;
}

/* Catégories de fautes */
.error-word {
    color: inherit; /* Le texte de la faute s'affiche normalement */
    border-radius: 3px;
    pointer-events: none; /* Les clics passent à travers vers le textarea */
}

.error-spelling {
    border-bottom: 2px solid var(--error-spelling);
    background-color: var(--error-spelling-bg);
}

.error-grammar {
    border-bottom: 2px solid var(--error-grammar);
    background-color: var(--error-grammar-bg);
}

.error-style {
    border-bottom: 2px dashed var(--error-style);
    background-color: var(--error-style-bg);
}

/* Bulle Intelligente (Tooltip) */
.suggestion-box {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    border-radius: 12px;
    width: 300px;
    z-index: 100;
    display: none;
    overflow: hidden;
    flex-direction: column;
}

.suggestion-box.visible { display: flex; }

.suggestion-header {
    padding: 1rem;
    background: rgba(245, 245, 247, 0.8);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.suggestion-list {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.suggestion-btn {
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.1s;
}

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

/* Loading */
.loading-indicator {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.loading-indicator.hidden { display: none; }

.spinner-small {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0,0,0,0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
