/* =================================================================
   DECK BUILDER - UPLOADS & SECTIONS STYLES
   Split from deck-builder.css for maintainability
   Contains: CSV upload, media upload, section groups, grammar management
   ================================================================= */

/* =================================================================
   DECK BUILDER - CSV & MEDIA UPLOAD SECTIONS
   ================================================================= */

.deck-section {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.deck-section .section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Collapsible section styles */
.deck-section.collapsible .section-title {
    cursor: pointer;
    user-select: none;
    padding: 12px 16px;
    margin: 0 -16px 16px -16px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.deck-section.collapsible .section-title:hover {
    background-color: var(--bg-secondary);
}

.deck-section.collapsible .section-title:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.deck-section .section-title i {
    color: var(--primary);
}

/* Chevron icon for collapsible sections */
.deck-section .section-chevron {
    margin-left: auto;
    font-size: 14px;
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}

.deck-section.collapsed .section-chevron {
    transform: rotate(-90deg);
}

/* Section content wrapper for collapse */
.deck-section .section-content {
    overflow: hidden;
}

.deck-section.collapsed .section-content {
    display: none !important;
}

/* Remove bottom margin when collapsed */
.deck-section.collapsed .section-title {
    margin-bottom: 0;
}

.deck-section .section-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
}

.deck-section .section-description {
    margin: 0 0 20px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.deck-section .section-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.deck-section .section-hint {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.deck-section .section-hint i {
    color: var(--primary);
    margin-right: 4px;
}

/* =================================================================
   NESTED SECTION GROUPS - Build Word/Sentence Lessons
   ================================================================= */

.deck-section-group {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.deck-section-group > .group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.deck-section-group > .group-header:hover {
    background: var(--bg-tertiary, var(--bg-secondary));
}

.deck-section-group > .group-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.deck-section-group > .group-header h2 i {
    font-size: 16px;
    color: var(--primary);
}

/* Build Word Lessons group header - blue gradient */
.deck-section-group > .group-header.group-header-word {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    border: none;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}

.deck-section-group > .group-header.group-header-word:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    border: none;
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.3);
}

.deck-section-group > .group-header.group-header-word h2,
.deck-section-group > .group-header.group-header-word h2 i {
    color: white;
}

/* Build Sentence Lessons group header - orange/amber gradient */
.deck-section-group > .group-header.group-header-sentence {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    border: none;
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.2);
}

.deck-section-group > .group-header.group-header-sentence:hover {
    background: linear-gradient(135deg, #b45309 0%, #d97706 100%);
    border: none;
    box-shadow: 0 3px 8px rgba(217, 119, 6, 0.3);
}

.deck-section-group > .group-header.group-header-sentence h2,
.deck-section-group > .group-header.group-header-sentence h2 i {
    color: white;
}

/* Dark mode group header variants */
[data-theme="dark"] .deck-section-group > .group-header.group-header-word {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .deck-section-group > .group-header.group-header-word:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    box-shadow: 0 3px 8px rgba(59, 130, 246, 0.4);
}

[data-theme="dark"] .deck-section-group > .group-header.group-header-sentence {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .deck-section-group > .group-header.group-header-sentence:hover {
    background: linear-gradient(135deg, #b45309 0%, #d97706 100%);
    box-shadow: 0 3px 8px rgba(245, 158, 11, 0.4);
}

.deck-section-group > .group-content {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.deck-section-group.collapsed > .group-content {
    display: none !important;
}

/* Sentence section ordering */
#buildSentenceLessonsGroup #sentencePoolSection { order: 1; }
#buildSentenceLessonsGroup #sentenceReviewSection { order: 2; }
#buildSentenceLessonsGroup #storyZoneSection { order: 3; }
#buildSentenceLessonsGroup #conversationZoneSection { order: 4; }
#buildSentenceLessonsGroup #sentenceWordsSection { order: 5; }

/* Nested sections inside groups */
.deck-section-group .deck-section:first-child {
    margin-top: 0;
    padding-top: 16px;
    border-top: none;
}

/* =================================================================
   TOP-LEVEL ZONES - Student's Zone & Teacher's Zone
   ================================================================= */

.deck-zone {
    margin-top: 24px;
    padding-top: 0;
    border-top: none;
}

.deck-zone:first-of-type {
    margin-top: 16px;
}

.deck-zone > .zone-header {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    border: none;
    border-radius: 10px;
    padding: 14px 20px;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
    cursor: pointer;
}

.deck-zone > .zone-header:hover {
    background: linear-gradient(135deg, #5558e8 0%, #5558dd 100%);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.deck-zone > .zone-header h2 {
    color: white;
    font-size: 20px;
}

.deck-zone > .zone-header h2 i {
    color: white;
    font-size: 18px;
}

.deck-zone > .zone-header .group-chevron {
    color: rgba(255, 255, 255, 0.8);
    transition: transform 0.2s ease;
}

/* Group header chevron transition */
.deck-section-group > .group-header .group-chevron {
    margin-left: auto;
    transition: transform 0.2s ease;
}

/* Zone content - expanded state */
.deck-zone > .zone-content {
    padding: 8px 0 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Zone collapsed state */
.deck-zone.collapsed > .zone-content {
    display: none !important;
}

/* Nested groups inside zones have less margin */
.deck-zone .deck-section-group {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.deck-zone .deck-section-group:first-child {
    margin-top: 8px;
    padding-top: 0;
    border-top: none;
}

/* Nested sections inside zones */
.deck-zone > .zone-content > .deck-section {
    margin-top: 16px;
    padding-top: 16px;
}

.deck-zone > .zone-content > .deck-section:first-child {
    margin-top: 8px;
    padding-top: 0;
    border-top: none;
}

/* Teacher's Zone header - teal/green gradient */
.deck-zone > .zone-header.zone-header-teacher {
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}

.deck-zone > .zone-header.zone-header-teacher:hover {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
}

/* Dark mode zone styles */
[data-theme="dark"] .deck-zone > .zone-header {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .deck-zone > .zone-header:hover {
    background: linear-gradient(135deg, #5558e8 0%, #7c7ce8 100%);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

[data-theme="dark"] .deck-zone > .zone-header.zone-header-teacher {
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3);
}

[data-theme="dark"] .deck-zone > .zone-header.zone-header-teacher:hover {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
}

/* Global rescan button in header */
.deck-header .rescan-global-btn {
    background: var(--warning);
    color: white;
    border: none;
}

.deck-header .rescan-global-btn:hover {
    background: #e67e22;
}

/* Rescan button styling in sections */
.rescan-section-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.rescan-section-btn:hover {
    background: var(--warning);
    border-color: var(--warning);
    color: white;
}

.rescan-section-btn i {
    margin-right: 6px;
}

/* Reuse admin upload styles */
.deck-section .csv-upload-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.deck-section .upload-options {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.deck-section .radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.deck-section .radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.deck-section .radio-option:hover {
    border-color: var(--primary);
    background: var(--bg-primary);
}

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

.deck-section .radio-option input[type="radio"]:checked + span {
    font-weight: 600;
    color: var(--primary);
}

.deck-section .radio-option:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.deck-section .file-upload-container {
    background: var(--bg-primary);
    padding: 20px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    transition: all 0.2s;
}

.deck-section .file-upload-container:hover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.02);
}

.deck-section .file-upload-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.deck-section .file-upload-label i {
    color: var(--primary);
    margin-right: 8px;
}

.deck-section .file-hint {
    font-size: 12px;
    font-weight: normal;
    color: var(--text-secondary);
    font-style: italic;
}

.deck-section .file-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
}

.deck-section .file-input:hover {
    border-color: var(--primary);
}

.deck-section .file-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.deck-section .file-status {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.deck-section .language-uploads {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .deck-section .section-actions {
        flex-direction: column;
    }

    .deck-section .section-actions .btn {
        width: 100%;
    }

    .deck-section .language-uploads {
        grid-template-columns: 1fr;
    }
}

body.mobile-phone .deck-section .section-actions {
    flex-direction: column;
}

body.mobile-phone .deck-section .section-actions .btn {
    width: 100%;
}

body.mobile-phone .deck-section .language-uploads {
    grid-template-columns: 1fr;
}

/* Dark mode */
[data-theme="dark"] .deck-section .radio-option:has(input[type="radio"]:checked) {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .deck-section .file-upload-container:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* =================================================================
   GRAMMAR MANAGEMENT STYLES
   ================================================================= */

.grammar-upload-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.grammar-upload-row .filter-group {
    margin-bottom: 0;
}

/* Grammar Report Container */
.grammar-report-container {
    margin-top: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.grammar-report-container.hidden {
    display: none;
}

.grammar-report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--primary);
    color: white;
}

.grammar-report-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grammar-report-header .btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 8px;
}

.grammar-report-header .btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

#grammarReportContent {
    padding: 16px;
}

/* Report Summary */
.grammar-report-summary {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.grammar-report-summary .summary-stat {
    flex: 1;
    min-width: 120px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.grammar-report-summary .stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.grammar-report-summary .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Language Report Cards */
.grammar-report-languages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.language-report-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

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

.language-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.coverage-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.coverage-badge.high {
    background: #d1fae5;
    color: #065f46;
}

.coverage-badge.medium {
    background: #fef3c7;
    color: #92400e;
}

.coverage-badge.low {
    background: #fee2e2;
    color: #991b1b;
}

.language-stats {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.lessons-list {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 8px;
}

.lessons-list .list-label {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 120px;
}

.lessons-list .lesson-numbers {
    color: var(--text-secondary);
    word-break: break-word;
}

.lessons-list.missing .lesson-numbers {
    color: var(--error);
}

.report-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    text-align: right;
    color: var(--text-secondary);
}

/* Dark mode for grammar report */
[data-theme="dark"] .coverage-badge.high {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

[data-theme="dark"] .coverage-badge.medium {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

[data-theme="dark"] .coverage-badge.low {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

/* Responsive */
@media (max-width: 768px) {
    .grammar-upload-row {
        flex-direction: column;
    }

    .grammar-report-summary {
        flex-direction: column;
    }

    .lessons-list {
        flex-direction: column;
        gap: 4px;
    }

    .lessons-list .list-label {
        min-width: auto;
    }
}
