/**
 * Analyseur Grammatical - Styles CSS
 */

.grammar-analyzer-container {
    max-width: 1600px;
    width: 95vw;
    margin: 40px auto 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

/* En-tête */
.tool-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    border-radius: 12px;
    background-color: #f8f9fa;
}

.tool-header h1 {
    margin: 0 0 10px 0;
    font-size: 2.5em;
    font-weight: 700;
}

.tool-description {
    font-size: 1.1em;
    margin: 0;
    opacity: 0.9;
    line-height: 1.6;
}

/* Interface principale */
.main-interface {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

/* Nouvelle colonne éditeur */
.editor-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (max-width: 1024px) {
    .main-interface {
        grid-template-columns: 1fr;
    }
}

/* Panneau de contrôle */
.control-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.analysis-buttons {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.analysis-buttons h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.2em;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.grammar-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.grammar-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
    transform: translateY(-1px);
}

.grammar-btn.active {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

.btn-icon {
    font-size: 16px;
    margin-right: 8px;
}

.count {
    background: #f0f0f0;
    color: #666;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.grammar-btn.active .count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.primary-btn, .secondary-btn, .tertiary-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.primary-btn {
    background: #667eea;
    color: white;
}

.primary-btn:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.secondary-btn {
    background: #f1f3f4;
    color: #333;
}

.secondary-btn:hover {
    background: #e8eaed;
}

.tertiary-btn {
    background: #ffeaa7;
    color: #333;
}

.tertiary-btn:hover {
    background: #fdcb6e;
}

/* Contrôle de longueur des phrases */
.sentence-length-control {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.sentence-length-control h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.2em;
}

.length-controls label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    display: block;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

#sentence-length-slider {
    flex: 1;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

#sentence-length-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

#sentence-length-slider::-webkit-slider-thumb:hover {
    background: #5a6fd8;
    transform: scale(1.1);
}

#sentence-length-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

#sentence-length-value {
    min-width: 30px;
    font-weight: 500;
    color: #667eea;
    font-size: 16px;
}

/* Statistiques */
.statistics-panel {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

/* Complexité */
.complexity-panel {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

/* Dashboard des métriques */
.metrics-dashboard {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.metrics-section {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.metrics-section:last-child {
    border-bottom: none;
}

.metrics-section h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.1em;
    font-weight: 600;
}

/* Statistiques générales */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.metric-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    transition: transform 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.metric-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 5px;
}

.metric-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Scores de lisibilité */
.readability-scores {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.readability-scores-inline {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.score-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.score-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.score-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.score-value {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
}

.score-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.score-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.score-level {
    font-size: 11px;
    color: #666;
    font-weight: 600;
    min-width: 70px;
    text-align: right;
}

/* Métriques avancées */
.advanced-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.advanced-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
}

.advanced-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 3px;
}

.advanced-label {
    font-size: 11px;
    color: #666;
    font-weight: 500;
}

/* N-grams compact */
.ngrams-compact {
    position: relative;
}

.compact-toggle-btn {
    width: 100%;
    padding: 10px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.compact-toggle-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ngrams-popup {
    overflow: hidden;
    transition: max-height 0.5s ease-out;
}

.ngrams-popup .ngrams-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
}

.ngrams-popup .ngram-tab {
    flex: 1;
    padding: 8px 12px;
    background: #f8f9fa;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
}

.ngrams-popup .ngram-tab.active {
    background: white;
    border-bottom-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

.ngrams-popup .ngrams-content {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
}

/* Responsive pour le dashboard */
@media (max-width: 768px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .advanced-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .readability-scores {
        gap: 10px;
    }
    
    .readability-scores-inline {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

.complexity-panel h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.2em;
}

.complexity-scores {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.complexity-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.complexity-label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.score-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-value {
    min-width: 40px;
    font-weight: 600;
    color: #667eea;
    font-size: 16px;
}

.score-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.score-level {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    min-width: 80px;
}

.complexity-details {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.detail-item {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
}

.detail-label {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
}

.detail-value {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.statistics-panel h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.2em;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (min-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.stat-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

/* Éditeur de texte faire en sorte qu'une barre déroulante s'ouvre si le texte dépasse la hauteur de l'écran */
.editor-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 1135px;
    position: relative;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.editor-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.2em;
}

.editor-actions {
    display: flex;
    gap: 8px;
}

.small-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.small-btn:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

/* Section de scraping d'URL */
.url-scraper-section {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.url-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.url-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.url-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.url-input::placeholder {
    color: #999;
    font-style: italic;
}

.scrape-btn {
    padding: 8px 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.scrape-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.scrape-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.text-editor {
    flex: 1;
    min-height: 400px;
    padding: 20px;
    font-size: 16px;
    line-height: 1.6;
    border: none;
    outline: none;
    resize: none;
    font-family: Georgia, serif;
    color: #333;
    overflow-y: auto;
    max-height: calc(1135px - 120px); /* Hauteur totale - header - footer */
}

.text-editor:empty::before {
    content: attr(data-placeholder);
    color: #bbb;
    font-style: italic;
    pointer-events: none;
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    line-height: 1.6;
    font-size: 16px;
}

.text-editor:focus:empty::before {
    opacity: 0.7;
}

.editor-footer {
    padding: 10px 20px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    flex-shrink: 0; /* Empêche le footer de se réduire */
    position: sticky;
    bottom: 0;
    z-index: 10;
}

/* Surlignages */
.highlight {
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    cursor: help;
}

.verbs-highlight {
    background-color: rgba(255, 107, 107, 0.3);
    border-bottom: 2px solid #ff6b6b;
}

.adverbs-highlight {
    background-color: rgba(255, 193, 7, 0.3);
    border-bottom: 2px solid #ffc107;
}

.adjectives-highlight {
    background-color: rgba(40, 167, 69, 0.3);
    border-bottom: 2px solid #28a745;
}

.modals-highlight {
    background-color: rgba(0, 123, 255, 0.3);
    border-bottom: 2px solid #007bff;
}

.passive-highlight {
    background-color: rgba(102, 16, 242, 0.3);
    border-bottom: 2px solid #6610f2;
}

.past-highlight {
    background-color: rgba(255, 153, 0, 0.3);
    border-bottom: 2px solid #ff9900;
}

.long-sentences-highlight {
    background-color: rgba(255, 71, 87, 0.2);
    border-bottom: 2px solid #ff4757;
    border-left: 3px solid #ff4757;
}

.complex-words-highlight {
    background-color: rgba(255, 165, 0, 0.3);
    border-bottom: 2px solid #ffa500;
    font-weight: 600;
}

.complex-sentences-highlight {
    background-color: rgba(138, 43, 226, 0.2);
    border-bottom: 2px solid #8a2be2;
    border-left: 3px solid #8a2be2;
}

/* N-grams toggle compact */
.ngrams-compact {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}



.ngrams-popup {
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 15px;
    overflow: hidden;
}

.ngrams-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
}

.ngram-tab {
    flex: 1;
    padding: 10px 0;
    text-align: center;
    cursor: pointer;
    background: #f0f0f0;
    border: none;
    border-right: 1px solid #eee;
    font-weight: 500;
    color: #555;
    transition: background 0.3s ease;
}

.ngram-tab:last-child {
    border-right: none;
}

.ngram-tab:hover {
    background: #e0e0e0;
}

.ngram-tab.active {
    background: white;
    color: #667eea;
    border-bottom: 2px solid #667eea;
}

.ngrams-content {
    padding: 15px;
}

.ngram-list {
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.ngram-list.active {
    display: block;
}

.ngram-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px dashed #eee;
}

.ngram-item:last-child {
    border-bottom: none;
}

.ngram-word {
    font-weight: 500;
    color: #333;
}

.ngram-word.clickable {
    cursor: pointer;
    text-decoration: underline;
}

.ngram-word.clickable:hover {
    color: #667eea;
}

.ngram-highlight {
    background-color: rgba(255, 233, 120, 0.5); /* Light yellow */
    border-bottom: 2px solid #ffc107;
}

.ngram-count {
    color: #667eea;
    font-weight: 600;
}

/* Panneau de suggestions */
.suggestions-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #667eea;
    color: white;
}

.panel-header h3 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.suggestions-content {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.suggestion-item {
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid;
}

.suggestion-item.warning {
    background: #fff3cd;
    border-left-color: #ffc107;
}

.suggestion-item.info {
    background: #d1ecf1;
    border-left-color: #17a2b8;
}

.suggestion-item.error {
    background: #f8d7da;
    border-left-color: #dc3545;
}

.suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.suggestion-title {
    font-weight: 600;
    color: #333;
}

.suggestion-category {
    font-size: 12px;
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    color: #666;
}

.suggestion-message {
    margin: 0;
    color: #555;
    line-height: 1.5;
}

.no-suggestions {
    text-align: center;
    padding: 30px;
    color: #666;
}

/* Légende des couleurs */
.color-legend {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-legend h4 {
    margin: 0 0 15px 0;
    color: #333;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #333;
}

.color-box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.verbs-color { background-color: rgba(255, 107, 107, 0.6); }
.adverbs-color { background-color: rgba(255, 193, 7, 0.6); }
.adjectives-color { background-color: rgba(40, 167, 69, 0.6); }
.modals-color { background-color: rgba(0, 123, 255, 0.6); }
.passive-color { background-color: rgba(102, 16, 242, 0.6); }
.past-color { background-color: rgba(255, 153, 0, 0.6); }
.long-sentences-color { background-color: rgba(255, 71, 87, 0.6); }
.complex-words-color { background-color: rgba(255, 165, 0, 0.6); }
.complex-sentences-color { background-color: rgba(138, 43, 226, 0.6); }

/* Messages d'état */
.status-message {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1001;
    animation: slideInBottom 0.3s ease;
    max-width: 350px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.status-message.success {
    background: #28a745;
}

.status-message.error {
    background: #dc3545;
}

.status-message.warning {
    background: #ffc107;
    color: #333;
}

.status-message.info {
    background: #17a2b8;
}

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

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

/* Overlay de chargement */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    font-size: 16px;
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .grammar-analyzer-container {
        padding: 10px;
    }
    
    .tool-header h1 {
        font-size: 2em;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .legend-items {
        flex-direction: column;
        gap: 8px;
    }
    
    .suggestions-panel {
        width: 95%;
    }
    
    .text-editor {
        min-height: 300px;
        font-size: 14px;
    }
}