/* Reset y variables base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colores modo oscuro */
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #888888;
    --accent-primary: #4a90e2;
    --accent-secondary: #7b68ee;
    --accent-success: #4caf50;
    --accent-warning: #ff9800;
    --accent-error: #f44336;
    --border-color: #404040;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Contenedor principal */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Pantallas */
.screen {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.header, .quiz-header, .results-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px 0;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.progress-info {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.total-sentences {
    color: var(--text-secondary);
}

.timer-display {
    width: 130px;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: var(--bg-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.timer-display:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

/* Secciones de contenido */
.input-section, .quiz-content, .results-content {
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
}

/* Sección de párrafos guardados */
.paragraph-list {
    margin-bottom: 30px;
}

.paragraphs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.paragraphs-header h3 {
    font-size: 1.3rem;
    margin: 0;
    color: var(--text-primary);
}

.data-management-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.paragraph-list h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.saved-paragraphs {
    display: grid;
    gap: 15px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
    padding-top: 2px;
}

.saved-paragraph {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    transition: all 0.2s ease;
}

/* .saved-paragraph:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
} */

.saved-paragraph-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.saved-paragraph-preview {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

.saved-paragraph-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Nueva sección de párrafo */
.new-paragraph-section h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.paragraph-input {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.2s ease;
}

.paragraph-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.paragraph-input::placeholder {
    color: var(--text-muted);
}

/* Instrucciones */
.instructions {
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--shadow);
}

.instructions h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: var(--text-secondary);
}

.instructions li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--accent-success);
    font-weight: bold;
}

/* Pantalla de Quiz */
.sentence-display {
    text-align: center;
    margin-bottom: 20px;
}

.sentence-text {
    font-size: 1.4rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.writing-section {
    text-align: center;
}

.writing-prompt {
    margin-bottom: 20px;
    text-align: center;
}

.writing-prompt p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.user-input {
    width: 100%;
    padding: 25px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.5;
    resize: vertical;
    height: 100px;
    margin-bottom: 20px;
    transition: border-color 0.2s ease;
}

.editable-textarea {
    /* --- Estilos para centrar --- */
    display: flex;
    justify-content: center; /* Centrado horizontal del bloque de texto */
    align-items: center;     /* Centrado vertical */
    text-align: center;
}

.user-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.writing-buttons {
    display: flex;
    gap: 15px;
    justify-content: left;
    flex-wrap: wrap;
}

/* Pantalla de Resultados */
.rank-section {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 3px solid var(--accent-primary);
}

.rank-display {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.rank-S { color: var(--accent-success); }
.rank-A { color: var(--accent-primary); }
.rank-B { color: var(--accent-warning); }
.rank-C { color: var(--accent-error); }

.rank-description {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.detailed-results {
    margin-bottom: 30px;
}

.detailed-results h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.sentence-results {
    display: grid;
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.sentence-result {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid var(--accent-primary);
}

.sentence-text {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    line-height: 1.5;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sentence-attempts {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.total-attempts {
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    color: var(--text-primary);
}

.total-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.sentence-stats {
    display: flex;
    gap: 25px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.sentence-stats .stat-item {
    flex-direction: row;
    gap: 8px;
}

.sentence-stats .stat-label {
    font-size: 0.85rem;
}

.sentence-stats .stat-value {
    font-size: 1rem;
    font-weight: 600;
}

/* Botones */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-width: 120px;
}

/* Indicador de atajo de teclado */
.keyboard-hint {
    font-size: 0.75rem;
    opacity: 0.7;
    font-weight: 400;
    margin-left: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

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

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    background: var(--bg-secondary);
    color: var(--text-muted);
    border-color: var(--border-color);
}

/* Estados ocultos */
.hidden {
    display: none !important;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Notificaciones */
.notification {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 25px 25px 0 25px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-align: center;
}

.modal-body {
    padding: 0 25px 25px 25px;
}

.modal-message {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 25px;
    line-height: 1.6;
    text-align: center;
}

/* Indicador de similitud */
.similarity-indicator {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    border: 2px solid var(--border-color);
}

.similarity-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-right: 10px;
}

.similarity-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.similarity-bar {
    width: 100%;
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 15px;
    border: 1px solid var(--border-color);
}

.similarity-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-error), var(--accent-warning), var(--accent-success));
    border-radius: 6px;
    transition: width 0.5s ease;
}

/* Pista del error */
.error-hint {
    background: rgba(244, 67, 54, 0.1);
    border: 2px solid var(--accent-error);
    border-radius: 12px;
    padding: 15px;
    margin: 20px 0;
}

.error-hint-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}

.error-hint-text {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: center;
}

.text-correct {
    color: var(--text-primary);
}

.text-error {
    color: rgb(255, 0, 0);
    font-weight: 700;
}

.text-missing {
    color: rgb(255, 165, 0);
    font-weight: 700;
    font-size: 1.2rem;
}

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

.modal-btn {
    padding: 15px 20px;
    font-size: 1rem;
    text-align: center;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.modal-warning {
    background: rgba(255, 152, 0, 0.1);
    border: 2px solid var(--accent-warning);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
}

.modal-warning p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.6;
}

.modal-warning strong {
    color: var(--accent-warning);
}

/* Mensaje cuando no hay párrafos */
.no-paragraphs {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 40px 20px;
}

/* Mejor rango en lista de párrafos */
.best-rank {
    font-size: 0.8rem;
    color: var(--accent-success);
    font-weight: 600;
}

/* Modal de historial */
.modal-history {
    max-width: 650px;
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal-btn:hover {
    color: var(--text-primary);
}

.history-content {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px;
}

.history-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.history-header h4 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.history-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.history-item {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 15px;
    border-left: 4px solid var(--accent-primary);
    transition: transform 0.2s ease;
}

.history-item:hover {
    transform: translateX(4px);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.history-rank {
    font-size: 1.3rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.history-rank.rank-S {
    color: var(--accent-success);
    border: 2px solid var(--accent-success);
}

.history-rank.rank-A {
    color: var(--accent-primary);
    border: 2px solid var(--accent-primary);
}

.history-rank.rank-B {
    color: var(--accent-warning);
    border: 2px solid var(--accent-warning);
}

.history-rank.rank-C {
    color: var(--accent-error);
    border: 2px solid var(--accent-error);
}

.history-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.history-stats {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
}

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

.history-stat .stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.history-stat .stat-value {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .title {
        font-size: 2rem;
    }

    .paragraphs-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .data-management-buttons {
        width: 100%;
    }

    .data-management-buttons .btn-small {
        flex: 1;
        min-width: 140px;
    }

    .quiz-header {
        flex-direction: column;
        gap: 15px;
    }

    .timer-display {
        font-size: 1rem;
        padding: 6px 12px;
    }

    .writing-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
        max-width: 250px;
    }

    .input-section, .quiz-content, .results-content {
        padding: 20px;
    }

    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    .modal-options {
        gap: 10px;
    }

    .modal-btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .history-content {
        max-height: 50vh;
    }

    .history-rank {
        font-size: 1.1rem;
    }

    .history-stats {
        gap: 15px;
    }

    .sentence-results {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.8rem;
    }

    .sentence-text {
        font-size: 1.1rem;
        padding: 20px;
    }

    .user-input {
        min-height: 80px;
    }
}
