/* Subject Picker Card (Layer 1) */
.subject-picker-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.subject-picker-card:hover {
    transform: translateX(10px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    background: var(--bg-body);
}

.subject-link {
    display: flex;
    align-items: center;
    padding: 1.5rem 2rem;
    text-decoration: none;
    color: inherit;
    gap: 2rem;
}

.subject-icon {
    width: 60px;
    height: 60px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.8rem;
}

.subject-info {
    flex-grow: 1;
}

.subject-info h3 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--text-main);
}

.subject-info p {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.subject-picker-card i.fa-chevron-right {
    color: var(--primary-color);
    opacity: 0.5;
    transition: transform 0.3s;
}

.subject-picker-card:hover i.fa-chevron-right {
    opacity: 1;
    transform: translateX(5px);
}

/* Subject Section Container */
.subject-section {
    margin-bottom: 3rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem;
}

.subject-section h3 {
    font-size: 1.75rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--bg-subtle);
}

/* Course Card */
.course-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.course-card:hover {
    border-color: var(--primary-color);
}

.course-card h4 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.course-link {
    color: inherit;
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 0;
}

.course-link .course-id {
    font-weight: 700;
    color: var(--primary-color);
    background: var(--bg-surface);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.course-link .course-title-text {
    flex-grow: 1;
    margin-left: 1rem;
    font-size: 1.1rem;
}

.course-link i.fa-arrow-right {
    font-size: 0.9rem;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
    color: var(--primary-color);
}

.course-card:hover .course-link i.fa-arrow-right {
    opacity: 1;
    transform: translateX(0);
}

.course-card:hover {
    background: var(--bg-surface);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Material List */
.material-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    list-style: none;
    padding: 0;
}

.material-list li {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    overflow: hidden; /* Ensure link doesn't overflow rounded corners */
}

.material-list li a {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    width: 100%;
    height: 100%;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
}

.material-list li:hover {
    border-color: var(--primary-color);
    background: var(--bg-subtle);
}

.material-list li i {
    font-size: 1.3rem;
    min-width: 24px;
    text-align: center;
    transition: var(--transition-base);
}

/* Icon Colors */
.material-list li i.fa-file-pdf { color: #f43f5e; }
.material-list li i.fa-youtube, .material-list li i.fa-video { color: #ef4444; }
.material-list li i.fa-external-link-alt, .material-list li i.fa-globe { color: var(--primary-color); }
.material-list li i.fa-image { color: #10b981; }
.material-list li i.fa-file-alt, .material-list li i.fa-sticky-note { color: #f59e0b; }

.material-list li:hover a {
    color: var(--primary-color);
}

.material-list li p.material-info-text {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* YouTube Thumbnail Container */
.youtube-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
}

/* YouTube Image */
.youtube-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Play Overlay */
.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.6) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

/* Play Button */
.play-button {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #ef4444;
}

/* Overlay Text */
.overlay-text {
    text-align: center;
    color: white;
}

.click-text {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.course-title-display {
    font-size: 0.95rem;
    margin: 0.5rem 0 0 0;
    opacity: 0.95;
    font-weight: 500;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Coming Soon Placeholder */
.youtube-thumbnail.coming-soon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: not-allowed;
}

.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

/* Coming Soon Badge */
.coming-soon-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    position: relative;
    z-index: 1;
}

.coming-soon-badge i {
    font-size: 1.2rem;
}

/* Course Title in Coming Soon */
.course-title-elegant {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    margin: 0;
    text-align: center;
    max-width: 90%;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

/* Material Title below thumbnail */
.material-list li .material-title {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Special Layout for Video Items */
.material-list li:has(.youtube-thumbnail) {
    grid-column: span 1;
    flex-direction: column;
    align-items: flex-start;
    padding: 0;
    overflow: visible;
    border: none;
    background: transparent;
}

.material-list li:has(.youtube-thumbnail) i:first-child {
    display: none;
}

.material-list li:has(.youtube-thumbnail):hover {
    background: transparent;
    border-color: transparent;
}

/* Info Box */
.role-info-box {
    background: #e0f2fe;
    /* Light blue bg */
    border: 1px solid #bae6fd;
    color: #0369a1;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.role-info-box i {
    font-size: 1.5rem;
}

.loading-text,
.info-text,
.error-text {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.error-text {
    color: #ef4444;
}

/* Dark Mode Overrides for Better Visibility */
body.dark-theme .subject-section {
    background: var(--bg-surface);
    border-color: var(--border-color);
}

body.dark-theme .course-card {
    background: var(--bg-subtle);
    border-color: var(--border-color);
}

body.dark-theme .course-card:hover {
    border-color: var(--primary-color);
}

body.dark-theme .material-list li {
    background: var(--bg-surface);
    border-color: var(--border-color);
}

body.dark-theme .material-list li:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary-color);
}

body.dark-theme .material-list li a {
    color: var(--text-main);
}

body.dark-theme .role-info-box {
    background: rgba(14, 165, 233, 0.15);
    border-color: rgba(14, 165, 233, 0.3);
    color: #7dd3fc;
}

body.dark-theme .role-info-box strong {
    color: #38bdf8;
}

body.dark-theme .loading-text,
body.dark-theme .info-text {
    color: var(--text-muted);
}

body.dark-theme .error-text {
    color: #fca5a5;
}

/* ================================================
   MOBILE RESPONSIVENESS AND LAYOUT FIXES FOR ADSENSE
   ================================================ */

/* Responsive Grid for Layer 1 Subject Cards on Desktop */
#subjects-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
    width: 100%;
}

/* Responsive Grid for Layer 2 Course Cards on Desktop */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr)) !important;
    gap: 2rem;
    width: 100%;
}

/* Mobile Adjustments (under 768px) */
@media (max-width: 768px) {
    #subjects-container {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .course-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem;
    }

    .subject-section {
        padding: 1.25rem 1rem;
        margin-bottom: 2rem;
    }

    .subject-picker-card:hover {
        transform: none; /* Disable horizontal translate on hover for better touch performance */
    }

    .subject-link {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1.25rem 1rem;
    }

    .subject-link i.fa-chevron-right {
        align-self: flex-end;
        margin-top: -1.5rem;
    }

    .course-card {
        padding: 1.25rem 1rem;
    }

    .course-link {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .course-link .course-title-text {
        margin-left: 0;
        font-size: 1.05rem;
        line-height: 1.3;
    }

    .course-link i.fa-arrow-right {
        display: none; /* Hide arrow on mobile to save precious screen space */
    }

    /* Keep side paddings clean on mobile so content never touches edge */
    .container {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
    }
}

@media (max-width: 480px) {
    #subjects-container, .course-grid {
        grid-template-columns: 1fr !important;
    }

    .subject-info h3 {
        font-size: 1.2rem;
    }

    .subject-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
}