/* =====================================================
   SUBJECT-BASE.CSS - Gemensam styling för alla ämnen
   =====================================================
   Använder CSS-variabler för ämnesspecifika färger.
   Varje ämne definierar sina egna värden för:
   - --subject-primary
   - --subject-secondary  
   - --subject-gradient
   - --subject-icon (via content i ::before)
   ===================================================== */

/* =====================================================
   HERO NAVIGATION
   ===================================================== */

.hero-nav {
    position: absolute;
    top: 20px;
    left: 50px;
    z-index: 10;
}

.hero-back-btn {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    color: white;
    border: 2px solid rgba(255,255,255,0.2);
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hero-back-btn:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.4);
    transform: translateY(-2px);
}

/* =====================================================
   HERO SECTION (gemensam struktur)
   ===================================================== */

.subject-hero {
    background: linear-gradient(135deg, rgba(var(--subject-primary-rgb), 0.15), rgba(15, 15, 15, 0.9));
    padding: 60px 50px 10px;
    margin-top: 70px;
    position: relative;
}

.subject-hero h1 {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 15px;
    background: var(--subject-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subject-hero p {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
    max-width: 600px;
    line-height: 1.6;
}

/* =====================================================
   HERO STATS
   ===================================================== */

.hero-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 25px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.05);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 14px;
    font-weight: 500;
}

/* =====================================================
   BREADCRUMB NAVIGATION
   ===================================================== */

.breadcrumb {
    padding: 8px 50px;
    margin-top: 70px;
}

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 20px;
}

.breadcrumb-nav a {
    color: var(--subject-primary);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.3s;
}

.breadcrumb-nav a:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.breadcrumb-nav span {
    color: rgba(255,255,255,0.4);
}

/* =====================================================
   CONTENT SECTION
   ===================================================== */

.content {
    padding: 5px 40px;
    margin-top: -40px;
}

.section {
    margin-bottom: 40px;
}

.section:first-child {
    margin-top: 0;
}

/* =====================================================
   SECTION HEADER
   ===================================================== */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.section-header h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary, white);
}

.section-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

#videoCount {
    color: rgba(255,255,255,0.6);
    font-size: 14px;
}

/* =====================================================
   KURSER GRID
   ===================================================== */

.kurser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

/* =====================================================
   KURSKORT
   ===================================================== */

.kurs-card {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 1px solid rgba(var(--subject-primary-rgb), 0.2);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    height: 320px;
}

.kurs-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 35px rgba(var(--subject-primary-rgb), 0.2);
    border-color: rgba(var(--subject-primary-rgb), 0.5);
}

.kurs-card:focus {
    outline: 2px solid var(--subject-primary);
    outline-offset: 2px;
}

.kurs-header {
    height: 160px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    color: white;
    border-radius: 12px 12px 0 0;
    background: var(--subject-gradient);
}

.kurs-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.kurs-level {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.kurs-content {
    padding: 25px;
    height: 160px;
    display: flex;
    flex-direction: column;
}

.kurs-title {
    font-size: 22px;
    font-weight: 700;
    color: white;
    margin-bottom: 6px;
    line-height: 1.2;
}

.kurs-description {
    font-size: 14px;
    color: rgba(255,255,255,0.8);
    line-height: 1.4;
    flex: 1;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kurs-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: rgba(255,255,255,0.6);
}

.kurs-stats {
    display: flex;
    gap: 15px;
}

.kurs-duration {
    background: rgba(var(--subject-primary-rgb), 0.2);
    color: var(--subject-primary);
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
}

/* =====================================================
   VIDEOKORT GRID
   ===================================================== */

.kategori-videos {
    display: grid;
    grid-template-columns: repeat(auto-fill, 300px);
    gap: 20px;
    justify-content: center;
    padding: 0 20px;
}

/* =====================================================
   VIDEOKORT (subject-video-card)
   ===================================================== */

.subject-video-card {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 1px solid rgba(var(--subject-primary-rgb), 0.2);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeInUp 0.5s ease forwards;
    height: 340px;
    width: 300px;
    max-width: 300px;
}

.subject-video-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 35px rgba(var(--subject-primary-rgb), 0.2);
    border-color: rgba(var(--subject-primary-rgb), 0.5);
}

.subject-video-thumbnail {
    height: 180px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    overflow: hidden;
    background: var(--subject-gradient);
}

.video-category-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* =====================================================
   FAVORITE BUTTON
   ===================================================== */

.favorite-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.8);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    backdrop-filter: blur(10px);
    z-index: 10;
    color: rgba(255,255,255,0.7);
}

.favorite-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
    color: #ffeb3b;
}

.favorite-btn.favorited {
    background: rgba(var(--subject-primary-rgb), 0.9);
    color: #ffeb3b;
}

.favorite-btn.favorited:hover {
    background: var(--subject-primary);
    color: #fff;
}

/* =====================================================
   SHARE BUTTON
   ===================================================== */

.share-button {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.8);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    backdrop-filter: blur(10px);
    z-index: 10;
    color: rgba(255,255,255,0.7);
    opacity: 0;
    transform: translateY(10px);
}

.subject-video-card:hover .share-button {
    opacity: 1;
    transform: translateY(0);
}

.share-button:hover {
    background: rgba(var(--subject-primary-rgb), 0.9);
    color: white;
    transform: scale(1.1);
}

/* =====================================================
   PLAY BUTTON
   ===================================================== */

.play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--subject-primary);
    opacity: 0;
    transition: all 0.3s ease;
    cursor: pointer;
}

.subject-video-card:hover .play-button {
    opacity: 1;
}

.play-button:hover {
    transform: translate(-50%, -50%) scale(1.1);
    background: var(--subject-gradient);
    color: white;
}

/* =====================================================
   VIDEO CONTENT
   ===================================================== */

.subject-video-content {
    padding: 16px;
    height: 160px;
    display: flex;
    flex-direction: column;
}

.subject-video-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: white;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.subject-video-description {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 12px;
    flex: 1;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.subject-video-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    margin-top: auto;
}

.video-stats {
    display: flex;
    gap: 15px;
}

.video-duration {
    background: rgba(var(--subject-primary-rgb), 0.2);
    color: var(--subject-primary);
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
}

/* =====================================================
   KATEGORI SEKTIONER
   ===================================================== */

.kategori-sektion {
    margin-bottom: 50px;
}

.kategori-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(255,255,255,0.03);
    border-radius: 15px;
    border-left: 4px solid var(--subject-primary);
}

.kategori-icon {
    font-size: 32px;
}

.kategori-info h3 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
    color: white;
}

.kategori-info p {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    margin: 0;
}

/* =====================================================
   BUTTONS
   ===================================================== */

.btn-sekundär {
    background: transparent;
    border: 2px solid rgba(var(--subject-primary-rgb), 0.5);
    color: var(--subject-primary);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease !important;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 10;
}

/* ✅ FIX: Se till att allt inuti knappen är klickbart */
.btn-sekundär * {
    pointer-events: none;
}

.btn-sekundär:hover {
    background: rgba(var(--subject-primary-rgb), 0.15) !important;
    border-color: var(--subject-primary) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(var(--subject-primary-rgb), 0.2) !important;
    color: var(--subject-primary) !important;
}

.btn-sekundär:active {
    transform: translateY(0) !important;
    box-shadow: none !important;
}

.load-more-btn {
    display: block;
    margin: 40px auto;
    padding: 15px 40px;
    background: var(--subject-gradient);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.load-more-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(var(--subject-primary-rgb), 0.4);
}

/* =====================================================
   FILTER BUTTONS
   ===================================================== */

.category-filter {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 25px;
    padding: 15px 0;
}

.filter-btn {
    padding: 10px 20px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background: rgba(var(--subject-primary-rgb), 0.2);
    border-color: rgba(var(--subject-primary-rgb), 0.5);
}

.filter-btn.active {
    background: var(--subject-gradient);
    border-color: transparent;
    color: white;
}

/* =====================================================
   SEARCH RESULTS
   ===================================================== */

.search-results {
    margin-bottom: 30px;
}

.search-results-header {
    font-size: 18px;
    color: rgba(255,255,255,0.8);
    margin-bottom: 20px;
}

.search-highlight {
    background: linear-gradient(135deg, rgba(var(--subject-primary-rgb), 0.3), rgba(var(--subject-secondary-rgb), 0.3));
    color: var(--subject-primary);
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
}

/* =====================================================
   NOTIFICATION
   ===================================================== */

.notification {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95), rgba(22, 33, 62, 0.95));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(var(--subject-primary-rgb), 0.3);
    border-radius: 15px;
    padding: 20px 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    max-width: 350px;
    animation: slideIn 0.5s ease;
    display: none;
}

.notification.show {
    display: block;
}

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

/* =====================================================
   QUIZ FIXES
   ===================================================== */

.quiz-button {
    display: none !important;
}

.quiz-overlay {
    display: none !important;
}

.quiz-overlay.show {
    display: flex !important;
}

.subject-video-thumbnail .quiz-button,
.video-thumbnail .quiz-button {
    display: none !important;
}

/* =====================================================
   ANIMATIONS
   ===================================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation för kort */
.subject-video-card:nth-child(1) { animation-delay: 0.1s !important; }
.subject-video-card:nth-child(2) { animation-delay: 0.15s !important; }
.subject-video-card:nth-child(3) { animation-delay: 0.2s !important; }
.subject-video-card:nth-child(4) { animation-delay: 0.25s !important; }
.subject-video-card:nth-child(5) { animation-delay: 0.3s !important; }
.subject-video-card:nth-child(6) { animation-delay: 0.35s !important; }

/* Smooth section title transition */
#sectionTitle, #videoCount {
    transition: all 0.3s ease-in-out !important;
}

/* =====================================================
   LIGHT MODE FIXES
   ===================================================== */

body.light-mode .section-header h2 {
    background: linear-gradient(135deg, #1d1d1f, #4a4a4a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.light-mode .hero-back-btn {
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

body.light-mode .hero-back-btn:hover {
    background: rgba(0, 0, 0, 0.15);
    border-color: rgba(0, 0, 0, 0.3);
}

body.light-mode .kurs-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px var(--shadow-color);
}

body.light-mode .kurs-card:hover {
    box-shadow: 0 12px 30px var(--shadow-color);
}

body.light-mode .kurs-title,
body.light-mode .subject-video-title,
body.light-mode .kategori-info h3 {
    color: var(--text-primary);
}

body.light-mode .kurs-description,
body.light-mode .subject-video-description,
body.light-mode .kategori-info p {
    color: var(--text-secondary);
}

body.light-mode .subject-video-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px var(--shadow-color);
}

body.light-mode .subject-video-card:hover {
    box-shadow: 0 12px 30px var(--shadow-color);
}

body.light-mode .kurs-meta,
body.light-mode .subject-video-meta {
    color: var(--text-tertiary);
}

body.light-mode .breadcrumb-nav {
    color: var(--text-tertiary);
}

body.light-mode .breadcrumb-nav a {
    color: var(--subject-primary);
}

body.light-mode .subject-hero {
    background: linear-gradient(135deg, rgba(var(--subject-primary-rgb), 0.1), rgba(245, 245, 247, 0.95));
}

body.light-mode .stat-item {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

body.light-mode .kurs-duration,
body.light-mode .video-duration {
    background: rgba(var(--subject-primary-rgb), 0.15);
}

body.light-mode .video-category-badge {
    background: rgba(0, 0, 0, 0.7);
}

body.light-mode .search-highlight {
    background: rgba(var(--subject-primary-rgb), 0.2);
}

body.light-mode .kategori-header {
    background: rgba(0, 0, 0, 0.03);
}

body.light-mode .filter-btn {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

body.light-mode .filter-btn:hover,
body.light-mode .filter-btn.active {
    background: var(--subject-gradient);
    color: white;
    border-color: transparent;
}

body.light-mode .play-button {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

body.light-mode .play-button:hover {
    background: var(--subject-gradient);
    color: white;
}

body.light-mode .notification {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 40px var(--shadow-color);
}

body.light-mode .btn-sekundär {
    border-color: rgba(var(--subject-primary-rgb), 0.5);
}

body.light-mode .btn-sekundär:hover {
    background: rgba(var(--subject-primary-rgb), 0.1);
}

/* =====================================================
   MOBILE MENU OVERLAY FIX
   ===================================================== */

@media (max-width: 768px) {
    .mobile-menu-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(0, 0, 0, 0.98) !important;
        backdrop-filter: blur(10px) !important;
        z-index: 9999 !important;
        display: none !important;
    }
    
    .mobile-menu-overlay.active {
        display: flex !important;
        opacity: 1 !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .mobile-menu-close {
        z-index: 10000 !important;
    }
    
    .mobile-menu-links {
        z-index: 10000 !important;
    }
}

/* =====================================================
   RESPONSIVE - TABLET
   ===================================================== */

@media (min-width: 769px) and (max-width: 1024px) {
    .kurser-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .kategori-videos {
        grid-template-columns: repeat(auto-fill, minmax(300px, 300px));
        justify-content: center;
        gap: 20px;
    }
}

/* =====================================================
   RESPONSIVE - MOBILE
   ===================================================== */

@media (max-width: 768px) {
    .subject-hero {
        padding: 60px 20px 20px;
        margin-top: 60px;
    }
    
    .subject-hero h1 {
        font-size: 32px;
    }
    
    .subject-hero p {
        font-size: 15px;
    }
    
    .hero-stats {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .hero-nav {
        left: 20px;
        top: 15px;
    }
    
    .hero-back-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .breadcrumb {
        padding: 8px 20px;
        margin-top: 60px;
    }
    
    .content {
        padding: 5px 20px;
        margin-top: -10px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .kurser-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .kurs-card {
        height: 260px;
    }
    
    .kurs-header {
        height: 130px;
        font-size: 40px;
    }
    
    .kurs-content {
        padding: 16px;
        height: 130px;
    }
    
    .kurs-title {
        font-size: 20px;
    }
    
    .section-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .category-filter {
        padding: 10px 20px;
        margin-left: -20px;
        margin-right: -20px;
    }
    
    .filter-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .kategori-videos {
        grid-template-columns: 1fr;
        gap: 16px;
        max-width: 300px;
        margin: 0 auto;
        padding: 0 10px;
    }
    
    .subject-video-card {
        width: 100%;
        max-width: 300px;
        height: 340px;
        margin: 0 auto;
    }
    
    .subject-video-thumbnail {
        height: 180px;
    }
    
    .subject-video-content {
        height: 160px;
        padding: 14px;
    }
    
    .kategori-header {
        padding: 15px;
        flex-direction: column;
        text-align: center;
    }
    
    .kategori-icon {
        font-size: 28px;
    }
    
    .notification {
        left: 20px;
        right: 20px;
        bottom: 20px;
        max-width: none;
    }
}

/* =====================================================
   GRID OVERRIDES (säkerhet)
   ===================================================== */

.content .kategori-videos .subject-video-card {
    width: 300px !important;
    max-width: 300px !important;
    min-width: 300px !important;
    flex: none !important;
}

.section .kategori-videos {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, 300px) !important;
    justify-content: center !important;
}

.section .subject-video-card {
    width: 300px !important;
    max-width: 300px !important;
}

@media (max-width: 768px) {
    .content .kategori-videos .subject-video-card,
    .section .subject-video-card {
        width: 100% !important;
        max-width: 300px !important;
        min-width: auto !important;
    }
    
    .section .kategori-videos {
        grid-template-columns: 1fr !important;
    }
}