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

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

/* Password Protection Overlay */
.password-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.password-modal {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.password-modal h2 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 2em;
}

.password-modal p {
    color: #666;
    margin-bottom: 20px;
}

.password-modal form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.password-modal input[type="password"] {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.password-modal input[type="password"]:focus {
    outline: none;
    border-color: #667eea;
}

.password-error {
    color: #e74c3c;
    font-size: 0.9em;
    margin-top: -10px;
}

.password-error.hidden {
    display: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

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

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.review-badge {
    background: #ffc107;
    color: #333;
    padding: 10px 20px;
    border-radius: 20px;
    margin-top: 15px;
    display: inline-block;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.review-badge.hidden {
    display: none;
}

/* Subject Tabs */
.tabs-container {
    background: #f8f9fa;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    border-bottom: 2px solid #dee2e6;
}

.tabs-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
}

.tab {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.tab:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

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

.tab-name {
    font-weight: 600;
    cursor: pointer;
}

.tab.active .tab-name {
    color: white;
}

.tab-actions {
    display: flex;
    gap: 5px;
}

.tab-action-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 1.1em;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.tab-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.tab.active .tab-action-btn {
    color: white;
}

.tab.active .tab-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tabs-actions {
    flex-shrink: 0;
}

/* Dialog/Modal */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.dialog-overlay.hidden {
    display: none;
}

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

.dialog-modal h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #667eea;
}

.dialog-modal input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.dialog-modal input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Sections */
section {
    padding: 40px;
    border-bottom: 1px solid #e0e0e0;
}

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

section h2 {
    color: #667eea;
    margin-bottom: 0;
    font-size: 1.8em;
}

section h3 {
    color: #555;
    margin-bottom: 15px;
    font-size: 1.3em;
}

/* Collapsible Sections */
.collapsible-section {
    padding: 0;
}

.section-header-collapsible {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 30px 40px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.section-header-collapsible:hover {
    background: rgba(102, 126, 234, 0.05);
}

.collapse-icon {
    font-size: 1.2em;
    color: #667eea;
    transition: transform 0.3s ease;
    font-weight: bold;
}

.collapsible-section.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.section-content {
    padding: 0 40px 40px 40px;
    max-height: none;
    overflow: visible;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.collapsible-section.collapsed .section-content {
    max-height: 0;
    opacity: 0;
    padding: 0 40px;
    pointer-events: none;
}

/* Upload Area */
.upload-area {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.upload-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

#fileInput,
#documentInput {
    flex: 1;
    min-width: 250px;
    padding: 12px;
    border: 2px dashed #667eea;
    border-radius: 6px;
    background: white;
    cursor: pointer;
}

#fileInput:hover,
#documentInput:hover {
    border-color: #764ba2;
}

.help-text {
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
}

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

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

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

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

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

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
    padding: 8px 16px;
    font-size: 0.9em;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-success {
    background: #28a745;
    color: white;
    padding: 10px 20px;
    margin-top: 10px;
}

.btn-success:hover {
    background: #218838;
}

/* File List */
.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.file-list {
    display: grid;
    gap: 15px;
}

.file-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
}

.file-item:hover {
    border-color: #667eea;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.1);
}

.file-item.selected {
    background: #e7eaff;
    border-color: #667eea;
}

.file-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.file-meta {
    display: flex;
    gap: 20px;
    font-size: 0.85em;
    color: #666;
}

.file-actions {
    display: flex;
    gap: 10px;
}

/* Document Storage */
.document-list {
    display: grid;
    gap: 15px;
}

.document-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
}

.document-item:hover {
    border-color: #667eea;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.1);
}

.document-icon {
    font-size: 2em;
    min-width: 40px;
    text-align: center;
}

.document-info {
    flex: 1;
}

.document-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    word-break: break-word;
}

.document-meta {
    display: flex;
    gap: 20px;
    font-size: 0.85em;
    color: #666;
}

.document-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.document-actions .btn,
.document-actions a.btn,
.document-actions button.btn {
    min-width: 100px;
    text-align: center;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    box-sizing: border-box;
    text-decoration: none !important;
    line-height: 1;
    border: none;
    cursor: pointer;
    margin: 0;
    vertical-align: middle;
}

.document-actions .btn-sm,
.document-actions a.btn-sm,
.document-actions button.btn-sm {
    padding: 10px 20px;
    font-size: 0.9rem;
    height: 40px;
    min-width: 100px;
    margin: 0;
    vertical-align: middle;
}

/* Quiz Controls */
.quiz-controls {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.selected-files-info {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

.word-count {
    color: #667eea;
}

.quiz-options {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.quiz-options label {
    font-weight: 600;
}

.quiz-options input[type="number"] {
    width: 80px;
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1em;
}

.quiz-type-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-width: 300px;
}

.quiz-type-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-type-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

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

.quiz-type-option input[type="radio"] {
    cursor: pointer;
}

.quiz-type-option input[type="radio"]:checked + span {
    font-weight: 600;
    color: #667eea;
}

.quiz-type-option span {
    font-weight: normal;
}

.quiz-number-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Quiz Display */
.quiz-display {
    margin-top: 30px;
}

.quiz-display.hidden {
    display: none;
}

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

.quiz-header h3 {
    margin: 0;
}

.question-card {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid #e0e0e0;
}

.question-header {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: flex-start;
}

.btn-super-quiz {
    background: none;
    border: 2px solid #ffd700;
    color: #ffd700;
    font-size: 1.5em;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    margin-left: auto;
    line-height: 1;
}

.btn-super-quiz:hover {
    background: #fff9e6;
    transform: scale(1.1);
}

.btn-super-quiz.saved {
    background: #ffd700;
    color: white;
    border-color: #ffd700;
}

.question-number {
    background: #667eea;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.question-text {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
}

.question-options {
    margin: 20px 0;
    display: grid;
    gap: 10px;
}

.option-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.option-label input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.short-answer-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
}

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

.feedback {
    margin-top: 15px;
    padding: 15px;
    border-radius: 6px;
    display: none;
}

.feedback.show {
    display: block;
}

.feedback.correct {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.feedback.incorrect {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.feedback-text {
    font-weight: 600;
    margin-bottom: 5px;
}

/* Quiz Results */
.quiz-results {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    margin-top: 30px;
}

.quiz-results.hidden {
    display: none;
}

#scoreDisplay {
    font-size: 1.5em;
    font-weight: 600;
    color: #667eea;
    margin: 20px 0;
}

/* Status Messages */
.status-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.status-message.hidden {
    display: none;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

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

/* Review Section */
.review-section {
    background: #f8f9fa;
}

.section-header-with-badge {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
}

.count-badge {
    background: #667eea;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9em;
}

.review-empty {
    background: white;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.review-empty p {
    margin: 0;
}

.subtitle-text {
    color: #666;
    font-size: 0.95em;
    margin-bottom: 20px;
}

.review-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.review-list {
    display: grid;
    gap: 30px;
}

.review-group {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.review-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.review-group-title {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.review-group-files {
    font-weight: 600;
    color: #667eea;
    font-size: 1.05em;
}

.review-group-date {
    color: #666;
    font-size: 0.9em;
}

.review-group-count {
    background: #667eea;
    color: white;
    padding: 6px 15px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 600;
}

.review-group-items {
    display: grid;
    gap: 15px;
}

.review-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    transition: all 0.3s ease;
}

.review-item:hover {
    border-color: #667eea;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.1);
}

.review-item.selected {
    background: #e7eaff;
    border-color: #667eea;
}

.review-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

.review-info {
    flex: 1;
}

.review-question-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    font-size: 1.05em;
}

.review-details {
    background: white;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.review-answer-block {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.review-answer-block:last-of-type {
    margin-bottom: 0;
}

.label-incorrect {
    color: #dc3545;
    font-weight: 600;
    font-size: 0.9em;
}

.label-correct {
    color: #28a745;
    font-weight: 600;
    font-size: 0.9em;
}

.answer-text {
    color: #333;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
}

.review-feedback-inline {
    margin-top: 10px;
    padding: 10px;
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    border-radius: 4px;
    font-size: 0.9em;
    color: #856404;
}

.review-explanation-inline {
    margin-top: 10px;
    padding: 10px;
    background: #d1ecf1;
    border-left: 3px solid #17a2b8;
    border-radius: 4px;
    font-size: 0.9em;
    color: #0c5460;
}

.review-meta {
    display: flex;
    gap: 20px;
    font-size: 0.85em;
    color: #666;
    margin-top: 8px;
}

.review-actions {
    display: flex;
    gap: 10px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9em;
}

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

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

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        padding: 30px 20px;
    }

    header h1 {
        font-size: 2em;
    }

    section {
        padding: 25px 20px;
    }

    .upload-controls,
    .quiz-options {
        flex-direction: column;
        align-items: stretch;
    }

    .file-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .file-meta {
        flex-direction: column;
        gap: 5px;
    }
}
