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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #2c3e50;
    padding: 10px;
    font-size: 16px;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 30px;
}

/* Mejoras para móviles */
@media (max-width: 768px) {
    body {
        padding: 5px;
        font-size: 15px;
    }

    .container {
        padding: 20px;
        border-radius: 15px;
    }

    header h1 {
        font-size: 1.75rem !important;
        line-height: 1.3;
    }

    header p {
        font-size: 0.9rem;
        line-height: 1.5;
    }
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

header h1 {
    color: #667eea;
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.quiz-selection {
    margin-bottom: 30px;
}

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

.quiz-header-section h2 {
    color: #764ba2;
    font-size: 1.8rem;
}

/* Controles de vista */
.view-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.view-toggle {
    display: flex;
    gap: 5px;
    background: #f0f0f0;
    padding: 3px;
    border-radius: 10px;
}

.btn-view {
    background: transparent;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-view.active {
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    color: #667eea;
}

.btn-view:hover:not(.active) {
    background: rgba(255, 255, 255, 0.5);
}

@media (max-width: 768px) {
    .quiz-header-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .quiz-header-section h2 {
        font-size: 1.4rem;
        text-align: center;
    }
    
    .view-controls {
        justify-content: center;
    }
}

/* Vista de tabla */
.quiz-table-container {
    overflow-x: auto;
    margin-top: 20px;
    border-radius: 10px;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.quiz-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.quiz-table th:nth-child(1),
.quiz-table td:nth-child(1) {
    width: 35%;
}

.quiz-table th:nth-child(2),
.quiz-table td:nth-child(2) {
    width: 10%;
    text-align: center;
}

.quiz-table th:nth-child(3),
.quiz-table td:nth-child(3) {
    width: 12%;
    text-align: center;
}

.quiz-table th:nth-child(4),
.quiz-table td:nth-child(4) {
    width: 12%;
    text-align: center;
}

.quiz-table th:nth-child(5),
.quiz-table td:nth-child(5) {
    width: 16%;
    text-align: center;
}

.quiz-table th {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.quiz-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.quiz-table th.sortable:hover {
    background: linear-gradient(135deg, #5a6fdb, #6b4293);
}

.sort-icon {
    margin-left: 5px;
    opacity: 0.5;
    font-size: 0.9em;
}

.quiz-table th.sort-asc .sort-icon::after {
    content: "↑";
}

.quiz-table th.sort-desc .sort-icon::after {
    content: "↓";
}

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

.quiz-table tr {
    transition: background-color 0.3s;
    cursor: pointer;
}

.quiz-table tbody tr:hover {
    background-color: #f5f5ff;
}

.quiz-table .no-attempts {
    color: #999;
    font-style: italic;
}

.quiz-table .stat-value {
    font-weight: 600;
    color: #667eea;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }

    .quiz-table {
        font-size: 0.9rem;
        table-layout: auto;
    }

    .quiz-table th,
    .quiz-table td {
        padding: 10px 8px;
    }

    /* Redistribuir ancho de columnas en móvil */
    .quiz-table th:nth-child(1),
    .quiz-table td:nth-child(1) {
        width: 40%;
    }

    .quiz-table th:nth-child(2),
    .quiz-table td:nth-child(2) {
        width: 15%;
    }

    .quiz-table th:nth-child(3),
    .quiz-table td:nth-child(3) {
        width: 15%;
    }

    .quiz-table th:nth-child(4),
    .quiz-table td:nth-child(4) {
        width: 15%;
    }
}

/* Vista de tarjetas */
.quiz-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.quiz-list.hidden,
.quiz-table-container.hidden {
    display: none;
}

.quiz-item {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.quiz-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.quiz-header-stats {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.quiz-stats-badge {
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    min-width: 100px;
    text-align: center;
}

.stat-attempts {
    font-weight: bold;
}

.stat-average, .stat-best {
    opacity: 0.95;
}

.quiz-item h3 {
    color: #667eea;
    margin-bottom: 12px;
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
}

.quiz-item p {
    color: #5a6c7d;
    line-height: 1.6;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.quiz-date {
    font-size: 0.85rem;
    color: #999;
    margin-top: 10px;
}

.no-stats {
    font-size: 0.9rem;
    color: #999;
    font-style: italic;
    margin-top: 10px;
}

@media (max-width: 768px) {
    .quiz-list {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .quiz-item {
        padding: 15px;
    }
    
    .quiz-header-stats {
        flex-direction: column;
    }
    
    .quiz-stats-badge {
        width: 100%;
    }
}

/* Estilos del cuestionario */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

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

.quiz-header h2 {
    color: #764ba2;
    font-size: 1.8rem;
}

.quiz-progress {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
}

@media (max-width: 768px) {
    .quiz-header {
        flex-direction: column;
        text-align: center;
    }
    
    .quiz-header h2 {
        font-size: 1.4rem;
        word-break: break-word;
    }
}

.question-container {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    min-height: 300px;
}

.question {
    font-size: 1.2rem;
    color: #2c3e50;
    margin-bottom: 25px;
    line-height: 1.7;
    font-weight: 500;
}

/* Mejoras para móviles en preguntas */
@media (max-width: 768px) {
    .question-container {
        padding: 15px;
        min-height: auto;
    }
    
    .question {
        font-size: 1rem;
        margin-bottom: 20px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .question.question-long-text {
        font-size: 0.95rem;
    }
}

.options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.option {
    background: #f8f9fa;
    padding: 16px 20px;
    border-radius: 12px;
    border: 2px solid #e9ecef;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color: #2c3e50;
}

.option:hover {
    background: #e9ecef;
    border-color: #dee2e6;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.option.selected {
    background: linear-gradient(135deg, #667eea15, #764ba215);
    border-color: #667eea;
    font-weight: 500;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.2);
}

.option-long-text {
    font-size: 0.95rem;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .options {
        gap: 12px;
    }
    
    .option {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    
    .option-long-text {
        font-size: 0.9rem;
    }
}

.quiz-controls {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

@media (max-width: 768px) {
    .quiz-controls {
        flex-direction: column;
    }
    
    .quiz-controls button {
        width: 100%;
    }
}

/* Estilos de los botones */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c82333;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.btn-refresh {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 8px 15px;
    font-size: 0.9rem;
}

.btn-refresh:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.refresh-icon {
    display: inline-block;
    transition: transform 0.3s;
}

.refresh-icon.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Estilos de resultados */
.results-container {
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
}

.results-container h2 {
    color: #764ba2;
    margin-bottom: 10px;
}

.results-quiz-name {
    color: #667eea;
    font-size: 1.3rem;
    margin-bottom: 25px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    font-weight: normal;
}

@media (max-width: 768px) {
    .results-quiz-name {
        font-size: 1.1rem;
        margin-bottom: 20px;
    }
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-item {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #667eea;
    transition: transform 0.2s ease;
}

.stat-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.stat-label {
    display: block;
    color: #5a6c7d;
    margin-bottom: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
    color: #667eea;
}

@media (max-width: 768px) {
    .results-stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-item {
        padding: 15px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}

.wrong-answers {
    text-align: left;
    margin-top: 30px;
}

.answers-header {
    background: linear-gradient(135deg, #667eea20, #764ba220);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.answers-header h3 {
    color: #764ba2;
    margin-bottom: 5px;
}

.answers-header p {
    color: #666;
    font-size: 0.9rem;
}

.wrong-answer, .correct-answer {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.wrong-answer {
    border-left: 4px solid #dc3545;
}

.correct-answer {
    border-left: 4px solid #28a745;
}

.answer-header {
    margin-bottom: 15px;
}

.answer-status {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
}

.incorrect-status {
    background: #dc354520;
    color: #dc3545;
}

.correct-status {
    background: #28a74520;
    color: #28a745;
}

.wrong-question {
    font-size: 1.1rem;
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 600;
    line-height: 1.6;
}

.wrong-explanation {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.wrong-explanation p {
    margin: 8px 0;
}

.correct-answer-text {
    color: #28a745;
    font-weight: 500;
}

.solution {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #e9ecef;
    color: #5a6c7d;
    line-height: 1.7;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .wrong-answer, .correct-answer {
        padding: 15px;
    }
    
    .wrong-question {
        font-size: 1rem;
    }
    
    .wrong-explanation {
        padding: 12px;
    }
}

.results-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .results-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .results-controls button {
        width: 100%;
    }
}

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

.loading-message {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #f5c6cb;
    text-align: center;
}

.error-message h3 {
    margin-bottom: 10px;
}

.no-quizzes-message {
    text-align: center;
    padding: 40px;
    color: #666;
    background: #f8f9fa;
    border-radius: 10px;
}

/* Notificaciones */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transform: translateX(400px);
    transition: transform 0.3s;
    z-index: 1000;
}

.notification.show {
    transform: translateX(0);
}

@media (max-width: 768px) {
    .notification {
        right: 10px;
        left: 10px;
        transform: translateY(-100px);
    }
    
    .notification.show {
        transform: translateY(0);
    }
}