/**
 * StudySphere AI — Ultimate Design System
 * Focus: Glassmorphism, Vibrant Accents, and Smooth Transitions.
 */

:root {
    --ss-primary: #6C47FF;
    --ss-secondary: #00D1FF;
    --ss-accent-warm: #FF6B6B;
    --ss-accent-cool: #10B981;
    --ss-aura-gradient: linear-gradient(135deg, #6C47FF, #10B981);
    --ss-glass-bg: rgba(255, 255, 255, 0.7);
    --ss-glass-border: rgba(255, 255, 255, 0.3);
}

/* 💎 GLOBAL FIDELITY HARDENING 💎 */
:root {
    --ds-body-bg: #f8fafc !important;
}

body,
html {
    background-color: var(--ds-body-bg) !important;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

#content {
    background-color: var(--ds-body-bg) !important;
    height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scroll-behavior: smooth;
}

/* Glassmorphism Enhancements */
.card-glass {
    background: rgba(255, 255, 255, 0.65) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
}

/* ─── Global Base Enhancements ────────────────────────────────────────── */
body {
    font-family: 'Public Sans', sans-serif !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.card {
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
    border: none !important;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(108, 71, 255, 0.08) !important;
}

/* ─── Aura AI Components ────────────────────────────────────────────────── */
.aura-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: var(--ss-aura-gradient);
    box-shadow: 0 0 25px rgba(108, 71, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    cursor: pointer;
    z-index: 2000;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: aura-glow 3s infinite;
}

.aura-fab:hover {
    transform: scale(1.15) rotate(15deg);
    box-shadow: 0 0 40px rgba(108, 71, 255, 0.8);
}

@keyframes aura-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(108, 71, 255, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(108, 71, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(108, 71, 255, 0);
    }
}

/* ─── Mastery Radar Extensions ─────────────────────────────────────────── */
.radar-container {
    background: var(--ss-glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--ss-glass-border);
    border-radius: 24px;
    padding: 20px;
}

/* ─── Pomodoro Premium ─────────────────────────────────────────────────── */
.timer-display {
    font-size: 8.5rem;
    font-weight: 800;
    background: var(--ss-aura-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -2px;
}

.timer-circle {
    width: 380px;
    height: 380px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 12px solid #F1F5F9;
}

/* ─── Study Gem Buttons ────────────────────────────────────────────────── */
.btn-gem {
    background: linear-gradient(45deg, #F59E0B, #D97706);
    color: white !important;
    border: none;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-gem:hover {
    background: linear-gradient(45deg, #D97706, #B45309);
    transform: translateY(-2px);
}

/* ─── Aura AI FAB Pulse Animation ─────────────────────────────────────── */
@keyframes aura-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(108, 71, 255, 0.7);
    }

    50% {
        box-shadow: 0 0 0 14px rgba(108, 71, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(108, 71, 255, 0);
    }
}

/* ─── Chat Typing Dots ─────────────────────────────────────────────────── */
@keyframes typingDot {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1.0);
        opacity: 1.0;
    }
}

/* ─── Chat UI Enhancements ─────────────────────────────────────────────── */
#chat-messages {
    scrollbar-width: thin;
    scrollbar-color: #6C47FF transparent;
}

#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #6C47FF;
    border-radius: 100px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 15px;
    margin-bottom: 12px;
    line-height: 1.6;
    font-size: 0.95rem;
}

.user-message {
    background: var(--ss-aura-gradient);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 3px;
}

.ai-message {
    background: #F3F4F6;
    color: #1F2937;
    border-bottom-left-radius: 3px;
    max-width: 85%;
}

.ai-message pre {
    font-size: 0.85rem;
    overflow-x: auto;
}

/* ─── Leaderboard Row Highlight ───────────────────────────────────────── */
.table-primary td {
    background-color: rgba(108, 71, 255, 0.08) !important;
    border-left: 3px solid #6C47FF;
}

/* ─── Pomodoro Enhancements ───────────────────────────────────────────── */
.pomodoro-ring {
    stroke-dasharray: 1005;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
    stroke: url(#timerGradient);
    stroke-width: 10;
    fill: none;
    stroke-linecap: round;
}

/* ─── Notes Page ──────────────────────────────────────────────────────── */
.note-card {
    border-left: 4px solid var(--ss-primary) !important;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.note-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(108, 71, 255, 0.15) !important;
}

/* ─── PDF/Material Cards ──────────────────────────────────────────────── */
.pdf-card {
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.25s ease;
}

.pdf-card:hover {
    transform: scale(1.02);
}

/* ─── Flashcard Flip ──────────────────────────────────────────────────── */
.flashcard-scene {
    perspective: 1000px;
}

.flashcard {
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
    cursor: pointer;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.flashcard-back {
    transform: rotateY(180deg);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* ─── Layout & Sidebar Hardening (MNC Premium Edition) ────────────────── */
#miniSidebar {
    width: 260px;
    height: 100vh !important;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1060;
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(25px) !important;
    -webkit-backdrop-filter: blur(25px) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.4) !important;
    transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.03) !important;
    overflow-y: auto;
    overflow-x: hidden;
}

#content {
    margin-left: 260px;
    width: calc(100% - 260px);
    height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    background: radial-gradient(at 0% 0%, rgba(108, 71, 235, 0.04) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 209, 255, 0.04) 0px, transparent 50%),
        #F8FAFC !important;
    scroll-behavior: smooth;
}

/* Collapsed Sidebar Support (matching theme JS classes) */
html.collapsed #miniSidebar {
    width: 80px;
}

html.collapsed #content {
    margin-left: 80px;
    width: calc(100% - 80px);
}

/* Mobile Responsiveness for Layout */
@media (max-width: 991.98px) {
    #miniSidebar {
        transform: translateX(-100%);
        visibility: hidden;
    }

    #content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    html.collapsed #miniSidebar {
        transform: translateX(-100%);
        visibility: hidden;
    }
}

/* Sidebar Logo & Menu Polish */
.brand-logo {
    padding: 28px 24px;
}

.sidebar-nav-fixed .nav-item .nav-link {
    display: flex;
    align-items: center;
    padding: 14px 24px !important;
    color: #475569 !important;
    font-weight: 500;
    font-size: 0.925rem;
    border-radius: 0 50px 50px 0;
    margin-right: 20px;
    transition: all 0.3s ease;
}

.sidebar-nav-fixed .nav-item .nav-link:hover {
    color: var(--ss-primary) !important;
    background: rgba(108, 71, 255, 0.06);
    transform: translateX(5px);
}

.sidebar-nav-fixed .nav-item .nav-link.active {
    color: white !important;
    background: var(--ss-aura-gradient);
    box-shadow: 0 10px 20px -5px rgba(108, 71, 255, 0.3);
}

/* Content Container Spacing */
.custom-container {
    padding: 2.5rem !important;
    max-width: 1600px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .custom-container {
        padding: 1.5rem !important;
    }
}

/* Hide horizontal scroll caused by overflow-x hidden on content */
body {
    overflow-x: hidden;
}

/* ─── Premium Welcome Banner & UI Adjustments ───────────────────────────── */
.bg-gradient-brand {
    background: linear-gradient(-45deg, #6C47FF, #10B981, #0ea5e9, #6C47FF);
    background-size: 300% 300%;
    animation: gradient-flow 12s ease infinite;
    box-shadow: 0 15px 35px -10px rgba(108, 71, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes gradient-flow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.btn-outline-white {
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.btn-outline-white:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: white;
    color: white;
}

/* Flashcard Level Tier Animations */
@keyframes unlock-tier {
    0% {
        transform: scale(0.9) translateY(40px);
        opacity: 0;
        filter: brightness(0.2) contrast(1.5) blur(20px);
    }

    60% {
        transform: scale(1.03) translateY(-10px);
        opacity: 1;
        filter: brightness(1.3) contrast(1.1) blur(5px);
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
        filter: brightness(1) contrast(1) blur(0px);
    }
}

@keyframes glimmer {
    0% {
        left: -100%;
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        left: 200%;
        opacity: 0;
    }
}

.tier-card-animated {
    animation: unlock-tier 1.2s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25) !important;
    position: relative;
    overflow: hidden;
    will-change: transform, opacity;
}

.tier-card-animated::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-20deg);
    animation: glimmer 3s infinite linear;
}

.tier-gold {
    background: linear-gradient(135deg, #CFB53B, #8A6E00) !important;
    color: #FFF !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.tier-silver {
    background: linear-gradient(135deg, #A8B2BD, #4B5563) !important;
    color: #FFF !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.tier-bronze {
    background: linear-gradient(135deg, #9C6E4A, #5C3A21) !important;
    color: #FFF !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Glassmorphism Cards */
.card-glass {
    background: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1) !important;
}

.flash-xp {
    transition: color 0.3s ease;
}

@keyframes reveal-blur {
    0% {
        filter: blur(15px);
        opacity: 0;
        transform: translateY(10px);
    }

    100% {
        filter: blur(0px);
        opacity: 1;
        transform: translateY(0);
    }
}

.card-reveal {
    animation: reveal-blur 0.8s ease-out forwards;
}

/* AI Tool Vibrancy */
.btn-aura-summary {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-aura-gems {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-aura-quiz {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-aura-translate {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-aura-roadmap {
    background: linear-gradient(135deg, #ec4899, #be185d);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-aura-forge {
    background: linear-gradient(135deg, #14b8a6, #0f766e);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-aura-summary:hover,
.btn-aura-gems:hover,
.btn-aura-quiz:hover,
.btn-aura-translate:hover,
.btn-aura-roadmap:hover,
.btn-aura-forge:hover {
    transform: scale(1.15) translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.response-pre {
    white-space: pre-wrap;
    font-family: inherit;
    line-height: 1.6;
}

/* ─── UI Utilities ────────────────────────────────────────────────────── */
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selection-item {
    transition: all 0.2s ease;
    border-left: 4px solid transparent !important;
}

.selection-item:hover {
    background-color: rgba(108, 71, 255, 0.05) !important;
    border-left-color: var(--ss-primary) !important;
    transform: translateX(4px);
}