/* Textbook Worksheets Page Styles */

/* Intro section */
.textbook-intro {
    text-align: center;
    max-width: 700px;
    margin: 0 auto 2rem;
}

.textbook-intro p {
    color: #64748b;
    font-size: 1.05rem;
    line-height: 1.7;
}

.night-mode .textbook-intro p {
    color: #94a3b8;
}

/* Grade Level Toggle */
.grade-level-toggle {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    border-radius: 12px;
    padding: 6px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.grade-toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.25s ease;
}

.grade-toggle-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.grade-toggle-btn.active {
    background: white;
    color: #7C3AED;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.grade-toggle-btn .toggle-icon {
    font-size: 1.1rem;
}

.night-mode .grade-level-toggle {
    background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
}

.night-mode .grade-toggle-btn {
    color: rgba(255, 255, 255, 0.7);
}

.night-mode .grade-toggle-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.night-mode .grade-toggle-btn.active {
    background: #1e293b;
    color: #a78bfa;
}

/* Textbook Browser Container */
.textbook-browser-container {
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-radius: 16px;
    border: 2px solid rgba(74, 144, 226, 0.2);
    padding: 1.5rem;
    margin-top: 1rem;
}

.night-mode .textbook-browser-container {
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border-color: rgba(74, 144, 226, 0.3);
}

/* Subject Filter Tabs */
.subject-filter-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    border-bottom: 2px solid var(--primary-purple, #8B5CF6);
}

.subject-tab {
    flex: 1;
    background: var(--card-bg, white);
    border: 2px solid var(--border-color, #e2e8f0);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 0.75rem 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
    margin-bottom: -2px;
    text-align: center;
}

.subject-tab:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(139, 92, 246, 0.02) 100%);
    color: var(--primary-purple, #8B5CF6);
    border-color: var(--primary-purple, #8B5CF6);
}

.subject-tab.active {
    background: var(--card-bg, white);
    color: var(--primary-purple, #8B5CF6);
    border-color: var(--primary-purple, #8B5CF6);
    border-bottom: 2px solid var(--card-bg, white);
    font-weight: 600;
}

.night-mode .subject-tab {
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-color: rgba(74, 144, 226, 0.2);
    color: #e2e8f0;
}

.night-mode .subject-tab:hover {
    border-color: #a78bfa;
    color: #a78bfa;
}

.night-mode .subject-tab.active {
    background: var(--card-bg, #1e293b);
    border-color: var(--primary-purple, #8B5CF6);
    border-bottom: 2px solid var(--card-bg, #1e293b);
    color: var(--primary-purple, #8B5CF6);
}

/* Textbook Grid */
.textbook-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.textbook-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 2px solid transparent;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.textbook-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.15);
    border-color: #8B5CF6;
}

.textbook-cover {
    flex-shrink: 0;
    width: 70px;
    height: 90px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.textbook-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.textbook-info {
    flex: 1;
    min-width: 0;
}

.textbook-card h3 {
    color: #7C3AED;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    line-height: 1.3;
}

.textbook-card .publisher {
    color: #64748b;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.textbook-card .chapter-count {
    font-size: 0.8rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 5px;
}

.textbook-card .chapter-count::before {
    content: "📚";
}

.night-mode .textbook-card {
    background: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.night-mode .textbook-card:hover {
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.25);
}

.night-mode .textbook-card h3 {
    color: #a78bfa;
}

.night-mode .textbook-card .publisher {
    color: #94a3b8;
}

.night-mode .textbook-cover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Breadcrumb */
.textbook-breadcrumb {
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-radius: 8px;
}

.textbook-breadcrumb a {
    color: #8B5CF6;
    text-decoration: none;
}

.textbook-breadcrumb a:hover {
    text-decoration: underline;
}

.textbook-breadcrumb .separator {
    margin: 0 10px;
    color: #94a3b8;
}

.night-mode .textbook-breadcrumb {
    background: #1e293b;
}

.night-mode .textbook-breadcrumb a {
    color: #a78bfa;
}

/* Chapter Accordion */
.chapters-accordion {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tb-chapter {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.tb-chapter-header {
    padding: 1rem 1.25rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    transition: background 0.2s ease;
}

.tb-chapter-header:hover {
    background: #f1f5f9;
}

.tb-chapter-header h3 {
    font-size: 1rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.tb-chapter-number {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.tb-chapter-arrow {
    font-size: 1.1rem;
    color: #94a3b8;
    transition: transform 0.3s ease;
}

.tb-chapter.expanded .tb-chapter-arrow {
    transform: rotate(90deg);
}

.tb-chapter-content {
    display: none;
    padding: 0;
}

.tb-chapter.expanded .tb-chapter-content {
    display: block;
}

.night-mode .tb-chapter {
    background: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.night-mode .tb-chapter-header {
    background: #0f172a;
    border-bottom-color: #334155;
}

.night-mode .tb-chapter-header:hover {
    background: #1e293b;
}

.night-mode .tb-chapter-header h3 {
    color: #f1f5f9;
}

/* Section */
.tb-section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
}

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

.tb-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.tb-section-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tb-section-number {
    color: #64748b;
    font-weight: 600;
    min-width: 45px;
}

.tb-section-name {
    color: #334155;
}

.tb-worksheet-toggle {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #4338ca;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.tb-worksheet-toggle:hover {
    background: linear-gradient(135deg, #c7d2fe 0%, #a5b4fc 100%);
}

.tb-worksheet-count {
    background: #4338ca;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
}

.night-mode .tb-section {
    border-bottom-color: #334155;
}

.night-mode .tb-section-number {
    color: #94a3b8;
}

.night-mode .tb-section-name {
    color: #e2e8f0;
}

.night-mode .tb-worksheet-toggle {
    background: linear-gradient(135deg, #312e81 0%, #3730a3 100%);
    color: #c7d2fe;
}

.night-mode .tb-worksheet-toggle:hover {
    background: linear-gradient(135deg, #3730a3 0%, #4338ca 100%);
}

/* Worksheets Dropdown */
.tb-worksheets-dropdown {
    display: none;
    margin-top: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 10px;
}

.tb-section.expanded .tb-worksheets-dropdown {
    display: block;
}

.tb-worksheets-dropdown h4 {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.tb-worksheet-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tb-worksheet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tb-worksheet-item .name {
    font-weight: 500;
    color: #334155;
}

.tb-worksheet-item .download-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.tb-worksheet-item .download-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
}

.tb-worksheet-item .download-btn::before {
    content: "📄";
    font-size: 0.9rem;
}

.tb-no-worksheets {
    color: #94a3b8;
    font-style: italic;
    padding: 0.75rem;
    text-align: center;
}

.night-mode .tb-worksheets-dropdown {
    background: #0f172a;
}

.night-mode .tb-worksheets-dropdown h4 {
    color: #94a3b8;
}

.night-mode .tb-worksheet-item {
    background: #1e293b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.night-mode .tb-worksheet-item .name {
    color: #e2e8f0;
}

/* No Data Message */
.no-data-message {
    text-align: center;
    padding: 3rem;
    color: #64748b;
}

.night-mode .no-data-message {
    color: #94a3b8;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
    .subject-filter-tabs {
        gap: 4px;
        flex-wrap: wrap;
    }

    .subject-tab {
        padding: 8px 12px;
        font-size: 0.85rem;
        flex: 0 1 auto;
    }

    .textbook-grid {
        grid-template-columns: 1fr;
    }

    .tb-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .tb-worksheet-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .tb-worksheet-item .download-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Responsive - Small phones */
@media (max-width: 480px) {
    .subject-filter-tabs {
        gap: 3px;
    }

    .subject-tab {
        padding: 6px 8px;
        font-size: 0.75rem;
        border-width: 1px;
        border-radius: 6px 6px 0 0;
    }

    .grade-level-selector {
        flex-direction: column;
        gap: 0.5rem;
    }

    .grade-level-btn {
        width: 100%;
        justify-content: center;
    }

    .textbook-card {
        padding: 0.75rem;
    }

    .textbook-card h3 {
        font-size: 1rem;
    }

    .textbook-card .publisher {
        font-size: 0.8rem;
    }

    .tb-chapter-title {
        font-size: 1rem;
    }

    .tb-section-header h4 {
        font-size: 0.9rem;
    }

    .tb-worksheet-item .name {
        font-size: 0.85rem;
    }

    .no-data-message {
        padding: 2rem 1rem;
        font-size: 0.9rem;
    }
}
