/* ==================== Base Styles ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* ==================== Layout ==================== */
.container {
    max-width: 900px;
    margin: 0 auto;
}

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 30px;
    margin-bottom: 20px;
}

/* ==================== Header ==================== */
.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

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

.header p {
    opacity: 0.9;
}

/* ==================== Progress Bar ==================== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

/* ==================== Question Display ==================== */
.question-number {
    color: #667eea;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.question-type {
    display: inline-block;
    background: #e3f2fd;
    color: #1976d2;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-bottom: 15px;
}

.question-text {
    font-size: 1.2rem;
    line-height: 1.6;
    color: #333;
    margin-bottom: 25px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

/* ==================== Options ==================== */
.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
}

.option {
    display: flex;
    align-items: center;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.option:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

/* Disable hover effects on touch devices to prevent sticky highlight */
@media (hover: none) {
    .option:hover {
        border-color: #e0e0e0;
        background: transparent;
    }
    
    .option.selected:hover {
        border-color: #667eea;
        background: #e8eaf6;
    }
}

.option.selected {
    border-color: #667eea;
    background: #e8eaf6;
}

.option.correct {
    border-color: #4caf50;
    background: #e8f5e9;
}

.option.incorrect {
    border-color: #f44336;
    background: #ffebee;
}

.option.disabled {
    cursor: default;
}

.option input {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
    outline: none;
}

/* Remove focus outline on touch devices to prevent sticky highlight */
@media (hover: none) {
    .option input:focus {
        outline: none;
    }
    
    .option:focus,
    .option:focus-within {
        outline: none;
    }
    
    /* Also remove active state highlight */
    .option:active {
        border-color: #e0e0e0;
        background: transparent;
    }
    
    .option.selected:active {
        border-color: #667eea;
        background: #e8eaf6;
    }
}

.option-content {
    display: flex;
    align-items: center;
    flex: 1;
    cursor: pointer;
    width: 100%;
    padding: 15px 20px;
}

.option-label {
    font-weight: 600;
    color: #667eea;
    margin-right: 10px;
    min-width: 25px;
}

.option-text {
    flex: 1;
    color: #333;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    word-break: break-word;
}

/* ==================== Buttons ==================== */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

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

.btn-secondary {
    background: #f5f5f5;
    color: #666;
}

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

.btn-success {
    background: #4caf50;
    color: white;
}

.btn-success:hover {
    background: #45a049;
}

/* ==================== Navigation ==================== */
.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.navigation .btn {
    margin-right: 0;
}

/* ==================== Feedback & Explanation ==================== */
.result-feedback {
    padding: 20px;
    border-radius: 10px;
}

.result-feedback.correct {
    background: #e8f5e9;
    border: 1px solid #4caf50;
}

.result-feedback.incorrect {
    background: #ffebee;
    border: 1px solid #f44336;
}

.result-feedback h3 {
    margin-bottom: 10px;
}

.result-feedback.correct h3 {
    color: #4caf50;
}

.result-feedback.incorrect h3 {
    color: #f44336;
}

.explanation {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.explanation h4 {
    color: #667eea;
    margin-bottom: 10px;
}

.references {
    margin-top: 15px;
}

.references a {
    color: #667eea;
    text-decoration: none;
    display: block;
    margin: 5px 0;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.references a:hover {
    text-decoration: underline;
}

/* ==================== File Upload ==================== */
.file-input {
    width: 100%;
    padding: 40px;
    border: 2px dashed #ccc;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-input:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.file-input.dragover {
    border-color: #667eea;
    background: #e8eaf6;
}

/* ==================== Form Elements ==================== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    cursor: pointer;
}

.checkbox-label input {
    width: 20px;
    height: 20px;
}

.number-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 20px;
}

.number-input:focus {
    outline: none;
    border-color: #667eea;
}

/* ==================== Categories ==================== */
.category-section {
    margin-bottom: 25px;
}

.category-section h4 {
    margin-bottom: 12px;
    color: #333;
    font-weight: 500;
}

.category-select-all {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    font-weight: 500;
    color: #667eea;
}

.category-select-all input {
    width: 20px;
    height: 20px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9ff;
    border-radius: 8px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.category-item:hover {
    background: #e8eaf6;
}

.category-item input {
    width: 18px;
    height: 18px;
}

.category-item label {
    cursor: pointer;
    font-size: 0.95rem;
    flex: 1;
}

.category-count {
    color: #666;
    font-size: 0.85rem;
}

/* ==================== Config Info ==================== */
.config-info {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.config-info p {
    margin: 5px 0;
}

.config-info .filename {
    color: #667eea;
    font-weight: 600;
}

/* ==================== Summary Stats ==================== */
.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

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

.stat-label {
    color: #666;
    font-size: 0.9rem;
    margin-top: 5px;
}

/* ==================== Pass/Fail Status ==================== */
.pass-status {
    text-align: center;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.pass-status.passed {
    background: #e8f5e9;
    color: #2e7d32;
}

.pass-status.failed {
    background: #ffebee;
    color: #c62828;
}

.pass-status h2 {
    font-size: 2rem;
    margin-bottom: 10px;
}

/* ==================== Question Navigator ==================== */
.question-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 10px;
    margin-top: 20px;
}

.question-dot {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.question-dot.unanswered {
    background: #e0e0e0;
    color: #666;
}

.question-dot.correct {
    background: #4caf50;
    color: white;
}

.question-dot.incorrect {
    background: #f44336;
    color: white;
}

.question-dot.current {
    box-shadow: 0 0 0 3px #667eea;
}

.question-dot:hover {
    transform: scale(1.1);
}

.question-dot .pin-icon {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 10px;
    background: #ff9800;
    color: white;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ==================== Error Messages ==================== */
.error-message {
    color: #f44336;
    margin-top: 15px;
    text-align: center;
    padding: 10px;
    background: #ffebee;
    border-radius: 8px;
}

/* ==================== Utility Classes ==================== */
.hidden {
    display: none !important;
}

.categories-expanded {
    max-height: 300px !important;
    opacity: 1 !important;
    margin-top: 8px;
}

.categories-collapsed {
    max-height: 0 !important;
    opacity: 0 !important;
}

#selected-categories-header:hover {
    background: #f8f9ff;
    border-radius: 4px;
    margin: -4px -8px;
    padding: 4px 8px;
}

/* ==================== Modal/Dialog ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

/* ==================== Responsive ==================== */
@media (max-width: 600px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .card {
        padding: 20px;
    }
    
    .question-text {
        font-size: 1rem;
    }
    
    .navigation {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn {
        width: 100%;
        margin-right: 0;
    }
    
    .summary-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .summary-buttons .btn {
        margin-left: 0 !important;
    }
}
