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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

/* ============================= */
/* ======= BOUTON STICKY ======= */
/* ============================= */

.back-to-exercises-container {
    position: sticky;
    top: 20px; /* Distance du haut quand il devient sticky */
    z-index: 1000;
    margin-bottom: 1rem;
    text-align: right;
}

.back-to-exercises {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.75em;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.back-to-exercises:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.back-to-exercises:active {
    transform: translateY(0);
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: visible;
}

.header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.header p {
    font-size: 1.2em;
    font-style: italic;
}

.content {
    padding: 40px;
    position: relative;
}

.section {
    margin-bottom: 40px;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 15px;
    border-left: 5px solid #667eea;
}

.section-title {
    font-size: 1.8em;
    color: #667eea;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.section-subtitle {
    font-size: 1em;
    color: #888;
    font-style: italic;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: table;
    overflow-x: auto;
}

th {
    background: #667eea;
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: bold;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
}

tr:hover {
    background: #f5f5f5;
}

.example-box {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.example-box strong {
    color: #667eea;
    font-size: 1.1em;
}

.example-box em {
    color: #666;
    display: block;
    margin-top: 5px;
}

.advice-list {
    list-style: none;
    padding: 0;
}

.advice-list li {
    background: white;
    padding: 15px;
    margin: 10px 0;
    border-radius: 8px;
    border-left: 4px solid #27ae60;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.advice-list li strong {
    color: #27ae60;
}

.bad-advice {
    background: #fff5f5;
    border-left: 4px solid #e74c3c !important;
    color: #721c24;
}

.bad-advice strong {
    color: #e74c3c !important;
}

.grammar-box {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    padding: 30px;
    border-radius: 15px;
    margin: 30px 0;
    border: 3px solid #f39c12;
}

.grammar-box h3 {
    color: #d63031;
    font-size: 1.8em;
    margin-bottom: 20px;
    text-align: center;
}

.grammar-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin: 15px 0;
}

.grammar-section h4 {
    color: #667eea;
    font-size: 1.3em;
    margin-bottom: 15px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.formula {
    background: #e8f4f8;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    margin: 10px 0;
    border-left: 4px solid #3498db;
}

.example-sentence {
    background: #f0f0f0;
    padding: 12px;
    border-radius: 6px;
    margin: 8px 0;
    font-style: italic;
}

.rule-box {
    background: #e8f5e9;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #4caf50;
    margin: 20px 0;
}

.rule-box h4 {
    color: #2e7d32;
    margin-bottom: 15px;
}

.tip {
    background: #fff3cd;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #ffc107;
    margin: 15px 0;
}

.tip strong {
    color: #856404;
}

.emoji {
    font-size: 1.5em;
}

/* Media queries pour responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        border-radius: 12px;
    }
    
    .header {
        padding: 25px 15px;
    }
    
    .header h1 {
        font-size: 1.8em;
    }
    
    .header p {
        font-size: 1em;
    }
    
    .content {
        padding: 20px 15px;
    }
    
    .section {
        padding: 15px;
        margin-bottom: 25px;
        border-radius: 12px;
    }
    
    .section-title {
        font-size: 1.4em;
    }
    
    .section-subtitle {
        font-size: 0.9em;
    }
    
    .example-box {
        padding: 15px;
        font-size: 0.95em;
    }
    
    .example-box p {
        font-size: 0.9em;
    }
    
    .advice-list li {
        padding: 12px;
        font-size: 0.95em;
    }
    
    .grammar-box {
        padding: 20px 15px;
    }
    
    .grammar-box h3 {
        font-size: 1.4em;
    }
    
    .grammar-section {
        padding: 15px;
    }
    
    .grammar-section h4 {
        font-size: 1.1em;
    }
    
    .formula {
        padding: 12px;
        font-size: 0.95em;
    }
    
    .example-sentence {
        padding: 10px;
        font-size: 0.9em;
    }
    
    .rule-box {
        padding: 15px;
    }
    
    .rule-box h4 {
        font-size: 1em;
    }
    
    .tip {
        padding: 12px;
        font-size: 0.9em;
    }
    
    table {
        font-size: 0.9em;
    }
    
    th, td {
        padding: 10px 8px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .header {
        padding: 20px 12px;
    }
    
    .header h1 {
        font-size: 1.5em;
    }
    
    .header p {
        font-size: 0.9em;
    }
    
    .content {
        padding: 15px 10px;
    }
    
    .section {
        padding: 12px;
        border-left: 3px solid #667eea;
    }
    
    .section-title {
        font-size: 1.2em;
        gap: 5px;
    }
    
    .grammar-box {
        padding: 15px 12px;
    }
    
    .grammar-box h3 {
        font-size: 1.2em;
    }
    
    .grammar-section h4 {
        font-size: 1em;
    }
    
    table {
        font-size: 0.85em;
    }
    
    th, td {
        padding: 8px 6px;
    }
}

@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
        border-radius: 0;
    }
    
    .section {
        page-break-inside: avoid;
    }
    
    .section:not(:first-of-type) {
        page-break-before: always;
    }
    
    .grammar-box {
        page-break-before: always;
        page-break-inside: avoid;
    }
    
    .grammar-section {
        page-break-inside: avoid;
    }

    /* Premier grammar-section dans un grammar-box n'aura pas de saut de page */
    .grammar-box .grammar-section:first-child {
        page-break-before: auto;
    }
    
    /* Les grammar-section suivants auront un saut de page */
    .grammar-section + .grammar-section {
        page-break-before: always;
        padding-top: 20px;
    }
    
    table {
        page-break-inside: avoid;
    }
    
    .example-box {
        page-break-inside: avoid;
    }
    
    /* Cacher le bouton lors de l'impression */
    .back-to-exercises,
    .back-to-exercises-container { 
        display: none !important; 
    }
}
