/* ============================================================
   components.css - Fordonsprogrammet GY25
   Teacher CMS, schematic, AI insights, floating buttons,
   AI chat, animations, RPG-stilar, media queries
   ============================================================ */
/* --- Teacher CMS Specifics --- */
.teacher-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: wrap;
}
.teacher-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: 'Oswald', sans-serif;
    font-size: 1.1rem;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--card-border);
}

.tab-btn.active {
    color: var(--accent-color);
    background: rgba(5, 150, 105, 0.15);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.1);
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.tab-content.active {
    display: block;
}

.tab-navigation .tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    font-size: 1rem;
    font-weight: 700;
}

.cms-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
}

.cms-sidebar h3 {
    margin-bottom: 1.5rem;
    font-family: 'Oswald', sans-serif;
    color: #fff;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.5rem;
}

.cms-block-item {
    padding: 15px;
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cms-block-item:hover {
    border-color: var(--accent-color);
    background: rgba(5, 150, 105, 0.05);
}

.cms-block-item.active {
    border-color: var(--accent-color);
    background: rgba(5, 150, 105, 0.15);
    box-shadow: 0 0 15px rgba(5, 150, 105, 0.1);
}

.cms-block-item .icon { font-size: 1.5rem; }
.cms-block-item .info { flex: 1; }
.cms-block-item h4 { margin: 0; font-size: 1rem; }
.cms-block-item span { font-size: 0.75rem; color: var(--text-secondary); }

.cms-main-panel {
    min-height: 600px;
}

.cms-action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.cms-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: transform 0.2s;
}

.question-edit-box {
    background: #ffffff;
    border: 1px solid var(--card-border);
    padding: 1.25rem;
    border-radius: 8px;
    margin-top: 1rem;
    position: relative;
}

.question-edit-box::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-color);
    border-radius: 4px 0 0 4px;
}

.cms-input {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.cms-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

@media (max-width: 1000px) {
    .cms-grid { grid-template-columns: 1fr; }
}

/* --- Tillgänglighet: Focus-visible stilar --- */
.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.tab-btn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Skip to main content (tangentbordsanvändare) */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--accent-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0 0 8px 0;
    font-weight: 700;
    z-index: 99999;
    transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* --- Schematic Toolbox --- */
.toolbox-group-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin: 14px 0 6px 0;
    font-weight: 700;
}

.toolbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.tool-btn {
    background: #ffffff;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 8px 4px;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1.2;
    text-align: center;
    transition: all 0.15s ease;
    font-family: var(--font-family);
}

.tool-btn small {
    display: block;
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.2;
}

.tool-btn:hover {
    background: rgba(5, 150, 105, 0.15);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.15);
}

.tool-btn:active {
    transform: translateY(0);
}

/* --- AI Insight Styles --- */
.ai-gap-card {
    background: rgba(255, 110, 110, 0.1);
    border: 1px solid #ff6e6e;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    transition: all 0.2s;
}
.ai-gap-card:hover {
    background: rgba(255, 110, 110, 0.15);
    transform: translateX(5px);
}

.ai-risk-card {
    background: rgba(255, 165, 0, 0.1);
    border: 1px solid orange;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border-left: 5px solid orange;
}

.ai-rec-box {
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid #58a6ff;
    padding: 1.5rem;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.ai-rec-box::after {
    content: "🤖";
    position: absolute;
    right: -10px;
    bottom: -10px;
    font-size: 5rem;
    opacity: 0.1;
    transform: rotate(-15deg);
}

.pulse-orange {
    animation: pulse-orange-shadow 2s infinite;
}

@keyframes pulse-orange-shadow {
    0% { box-shadow: 0 0 0 0 rgba(247, 129, 102, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(247, 129, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(247, 129, 102, 0); }
}
/* --- FLOATING HAND BUTTON (VERKSTADSKÖ) --- */
.floating-hand-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    height: 48px;
    padding: 0 16px 0 12px;
    border-radius: 26px;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid #3b82f6;
    color: #f8fafc;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0,0,0,0.45);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
    font-weight: 700;
    font-size: 0.92rem;
    user-select: none;
}

.floating-hand-btn:hover {
    transform: translateY(-2px) scale(1.03);
    background: #1e293b;
    border-color: #60a5fa;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
}

.floating-hand-btn .hand-icon {
    font-size: 1.35rem;
    line-height: 1;
    display: inline-block;
}

.floating-hand-btn .hand-text {
    display: inline-block;
    letter-spacing: 0.3px;
}

/* Aktivt läge (När handen är uppe / I kö) */
.floating-hand-btn.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-color: #fef08a;
    color: #ffffff;
    animation: handPulse 2s infinite;
    box-shadow: 0 6px 22px rgba(245, 158, 11, 0.45);
}

.floating-hand-btn.active .hand-icon {
    animation: handWave 1.4s infinite alternate ease-in-out;
}

@keyframes handWave {
    from { transform: rotate(-8deg) scale(1); }
    to { transform: rotate(12deg) scale(1.15); }
}

@keyframes handPulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { box-shadow: 0 0 0 14px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* Responsivitet för mobiler */
@media (max-width: 600px) {
    .floating-hand-btn {
        bottom: 20px;
        left: 20px;
        height: 44px;
        padding: 0 12px;
        font-size: 0.85rem;
    }
    .floating-hand-btn .hand-icon {
        font-size: 1.2rem;
    }
}
/* --- AI PERSONAL TRAINER CHAT --- */
.ai-chat-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, var(--accent-color), #34d399);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(5, 150, 105, 0.4);
    z-index: 10000;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-chat-toggle:hover {
    transform: scale(1.1) rotate(10deg);
}

.ai-chat-toggle .ai-icon {
    font-size: 2rem;
}

.ai-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--error-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    border: 2px solid var(--bg-color);
    animation: bounce 2s infinite;
}

/* ── Lennart APL-påminnelse: pulsande animation ─────────────────────── */
@keyframes lennart-pulse {
    0%   { transform: scale(1);    box-shadow: 0 8px 32px rgba(246,173,85,0.4); }
    30%  { transform: scale(1.18); box-shadow: 0 8px 48px rgba(246,173,85,0.9), 0 0 0 8px rgba(246,173,85,0.2); }
    60%  { transform: scale(0.96); box-shadow: 0 8px 24px rgba(246,173,85,0.3); }
    100% { transform: scale(1);    box-shadow: 0 8px 32px rgba(246,173,85,0.4); }
}

.ai-chat-toggle.apl-alert {
    background: linear-gradient(135deg, #f6ad55, #ed8936) !important;
    animation: lennart-pulse 1.6s ease-in-out infinite;
}

.ai-chat-toggle.apl-alert .ai-icon {
    animation: none; /* låt ikonen sitta still, bara knappen pulsar */
}

.ai-chat-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 410px;
    max-width: calc(100vw - 32px);
    height: 570px;
    max-height: calc(100vh - 120px);
    z-index: 10000;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1), height 0.28s cubic-bezier(0.16, 1, 0.3, 1), bottom 0.28s cubic-bezier(0.16, 1, 0.3, 1), right 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chat-container.expanded {
    width: min(880px, calc(100vw - 40px));
    height: calc(100vh - 48px);
    max-height: calc(100vh - 48px);
    bottom: 24px;
    right: 24px;
    box-shadow: 0 16px 56px rgba(0,0,0,0.35);
}

.ai-chat-container.expanded .ai-bubble {
    max-width: 90%;
    font-size: 1rem;
    line-height: 1.55;
}

.ai-chat-container.expanded .ai-chat-messages {
    padding: 1.5rem;
    gap: 1.25rem;
}

.ai-quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--card-border, var(--border));
    background: rgba(0,0,0,0.03);
}

.ai-quick-prompts button {
    border-radius: 14px;
    padding: 5px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1 1 auto;
    text-align: center;
    box-sizing: border-box;
}
.ai-quick-prompts button:hover {
    filter: brightness(0.92);
    transform: translateY(-1px);
}


.ai-chat-window {
    background: var(--card-bg, rgba(255, 255, 255, 0.95));
    backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 48px rgba(0,0,0,0.2);
    overflow: hidden;
}

.ai-chat-header {
    background: var(--header-bg, #ffffff);
    padding: 0.85rem 1.15rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: default;
    user-select: none;
}

.ai-status-dot {
    width: 10px;
    height: 10px;
    background: #3fb950;
    border-radius: 50%;
    box-shadow: 0 0 8px #3fb950;
}

.ai-support-lang-bar {
    background: var(--header-bg, var(--card-bg, #ffffff));
    padding: 0.45rem 1.1rem;
    border-bottom: 1px solid var(--card-border);
    display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.8rem;
}
.ai-support-lang-bar label {
    color: var(--text-secondary, #64748b);
    font-weight: 600; display: flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 0.78rem;
}
#ai-support-lang-select {
    flex: 1; background: var(--input-bg, #ffffff); color: var(--text-primary, #1e293b);
    border: 1px solid var(--input-border, var(--card-border)); border-radius: 6px;
    font-family: var(--font-family, inherit); font-size: 0.78rem; font-weight: 500;
    padding: 4px 8px; outline: none; cursor: pointer; transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}
#ai-support-lang-select:focus { border-color: var(--accent-color); }
#ai-support-lang-select option { background-color: var(--card-bg, #ffffff); color: var(--text-primary, #1e293b); padding: 4px 8px; }
.ai-support-translate-wrap { margin-top: 8px; border-top: 1px dashed var(--card-border, rgba(0,0,0,0.15)); padding-top: 6px; font-size: 0.8rem; }
.ai-support-translate-btn {
    background: none; border: none; padding: 0; color: var(--accent-color, #059669);
    cursor: pointer; font-size: 0.8rem; font-weight: 600; display: flex; align-items: center; gap: 4px; transition: opacity 0.2s;
}
.ai-support-translate-btn:hover { opacity: 0.8; }
.ai-trans-content {
    margin-top: 6px; padding: 8px 10px; background: var(--bg-color, #f4f7f6);
    border-left: 3px solid var(--accent-color, #059669); border-radius: 4px;
    font-size: 0.85rem; line-height: 1.45; color: var(--text-primary, #1e293b);
}
.ai-trans-title { font-weight: 700; color: var(--accent-color, #059669); margin-bottom: 4px; font-size: 0.8rem; }

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--card-border) transparent;
}

.ai-bubble {
    padding: 0.8rem 1rem;
    border-radius: 14px;
    font-size: 0.95rem;
    max-width: 85%;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.ai-bubble.teacher {
    background: var(--input-bg, #f1f5f9);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-bubble.student {
    background: var(--accent-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-chat-input-area {
    padding: 1rem;
    background: var(--card-bg, #ffffff);
    border-top: 1px solid var(--card-border);
    display: flex;
    gap: 10px;
}

#ai-chat-input {
    flex: 1;
    background: var(--input-bg, #f4f7f6);
    border: 1px solid var(--input-border, var(--card-border));
    color: var(--text-primary);
    padding: 0.6rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

#ai-chat-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

#ai-send-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

#ai-send-btn:hover {
    transform: scale(1.1);
    background: var(--accent-hover);
}

.teacher-view-btn {
    background: rgba(5, 150, 105, 0.1);
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.teacher-view-btn:hover {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 0 12px rgba(5, 150, 105, 0.3);
}

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

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-5px);}
    60% {transform: translateY(-3px);}
}

/* --- ALLMÄN MOBILANPASSNING (Elevvy, AI, Uppgifter) --- */
@media (max-width: 768px) {
    /* Header och Layout */
    .header-content {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .header-content h1 {
        font-size: 1.5rem;
    }

    main {
        padding: 1rem 0.5rem;
    }

    /* Landing Page */
    .landing-hero h1 {
        font-size: 2rem;
    }
    .landing-hero h2 {
        font-size: 1.2rem;
    }
    .landing-hero p {
        font-size: 1rem;
        padding: 0 10px;
    }

    /* Dashboard & Blocks */
    .dashboard-grid {
        gap: 1rem;
    }
    .blocks-grid {
        grid-template-columns: 1fr;
    }
    .block-card {
        padding: 1.2rem;
    }

    /* Uppgifter & Quiz */
    .assignments-header {
        flex-direction: column;
        gap: 1rem;
    }
    .assignment-item {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }
    .assignment-points {
        align-self: flex-start;
    }
    .quiz-question {
        padding: 1rem;
    }
    .quiz-q-title {
        font-size: 1.1rem;
    }

    /* Spel-layout */
    .game-player-header {
        padding: 0.5rem 1rem;
        flex-wrap: wrap;
        gap: 10px;
    }
    .game-player-header h3 {
        font-size: 1rem;
    }

    /* Teacher-tabs: flikar scroll på mobil */
    .teacher-tabs {
        flex-wrap: nowrap;
        gap: 0.35rem;
        padding-bottom: 0.75rem;
    }
    .tab-btn {
        font-size: 0.85rem;
        padding: 0.4rem 0.7rem;
        white-space: nowrap;
    }

    /* AI-chat i fullskärm på mobil */
    .ai-chat-container {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        right: 0;
        bottom: 0;
    }
    .ai-chat-window {
        border-radius: 0;
        border: none;
    }
    #ai-expand-btn {
        display: none !important;
    }
    .ai-chat-toggle {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
    }
    .ai-chat-toggle .ai-icon {
        font-size: 1.5rem;
    }
}
/* Typing Animation */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 10px 15px;
}

.ai-typing div {
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.ai-typing div:nth-child(2) { animation-delay: 0.2s; }
.ai-typing div:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* Fullskärmsläge för Uppgifter */
body.quiz-active header {
    display: none !important;
}

body.quiz-active main {
    padding: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    width: 100% !important;
}
body.ai-chat-open #floating-support-btn,
body.ai-chat-open #ai-chat-toggle {
    display: none !important;
}

/* --- RPG Gamification Styles --- */

/* --- RPG Mission Control Styles --- */
.mission-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--card-border, #e2e8e4);
    border-left: 4px solid #38a169;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.mission-card.completed {
    border-left-color: #facc15;
    box-shadow: 0 0 15px rgba(250, 204, 21, 0.1);
}

.mission-card.boss-fight {
    border-left-color: #ff4d4d;
}

.xp-badge {
    background: rgba(56, 161, 105, 0.2);
    color: #48bb78;
    border: 1px solid #38a169;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-family: monospace;
    font-weight: bold;
    margin-left: 10px;
}

.boss-badge {
    background: rgba(255, 77, 77, 0.1);
    color: #ff4d4d;
    border: 1px solid #ff4d4d;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-left: 10px;
    text-transform: uppercase;
}

/* Samlad .quiz-q-title – kombinerar gamla rad 415 och denna */
.quiz-q-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-size: 1.15rem;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.5rem;
}
.quiz-q-title span.level {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--card-border, #e2e8e4);
    color: var(--text-primary);
    vertical-align: middle;
    margin-left: 6px;
}

/* ── Flytande knapp: Tillbaka till toppen ─────────────────────────── */
.scroll-to-top-btn {
    position: fixed;
    bottom: 105px;
    right: 36px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #059669, #10b981);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 24px rgba(5, 150, 105, 0.35), 0 2px 6px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9990;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.85);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.scroll-to-top-btn:hover {
    background: linear-gradient(135deg, #10b981, #34d399);
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 12px 28px rgba(5, 150, 105, 0.5);
}

.scroll-to-top-btn:active {
    transform: translateY(0) scale(0.95);
}

.scroll-to-top-btn.teacher-scroll-btn {
    bottom: 30px;
    right: 30px;
    width: 52px;
    height: 52px;
}

@media (max-width: 600px) {
    .scroll-to-top-btn {
        bottom: 95px;
        right: 20px;
        width: 44px;
        height: 44px;
    }
    .scroll-to-top-btn.teacher-scroll-btn {
        bottom: 20px;
        right: 20px;
    }
}

/* --- DARK MODE COMPONENT OVERRIDES --- */
[data-theme="dark"] .cms-block-item,
[data-theme="dark"] .question-edit-box,
[data-theme="dark"] .tool-btn {
    background: var(--card-bg);
    border-color: var(--card-border);
    color: var(--text-primary);
}
[data-theme="dark"] .tool-btn small {
    color: var(--text-secondary);
}
[data-theme="dark"] .cms-input,
[data-theme="dark"] select.cms-input,
[data-theme="dark"] input.cms-input,
[data-theme="dark"] textarea.cms-input {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .tab-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .quiz-q-title,
[data-theme="dark"] .quiz-q-title * {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .quiz-q-title span.level {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}
[data-theme="dark"] .quiz-checklist-item {
    background: rgba(16, 185, 129, 0.06) !important;
    border-color: var(--card-border) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .quiz-checklist-item * {
    color: var(--text-primary);
}
[data-theme="dark"] #quiz-desc,
[data-theme="dark"] #quiz-desc * {
    color: var(--text-primary);
}
[data-theme="dark"] .quiz-option-label {
    background: var(--input-bg, #0d1322);
    border-color: var(--input-border, #2d3d5f);
    color: var(--text-primary) !important;
}
[data-theme="dark"] .quiz-option-label span { color: var(--text-primary) !important; }
[data-theme="dark"] .quiz-textarea {
    background: var(--input-bg, #0d1322) !important;
    border-color: var(--input-border, #2d3d5f) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .q-image-upload-box {
    background: rgba(16, 185, 129, 0.05) !important;
    border-color: var(--card-border, #23304c) !important;
}
