/* GLOBAL CONFIG & VARIABLES */
:root {
    --bg-main: #0f172a;
    --sidebar-bg: #020617;
    --panel-bg: rgba(255, 255, 255, 0.03);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --border: rgba(255, 255, 255, 0.1);
    --green: #10b981;
    --radius: 16px;
    --glass: rgba(255, 255, 255, 0.03);
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

body { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg-main); 
    color: var(--text-primary); 
    height: 100vh; 
    overflow: hidden; 
}

/* --- INSANE GLASSMORPHISM AUTH LAYER --- */
.auth-wrapper { 
    height: 100vh; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: #020617;
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before {
    content: "";
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 0% 0%, #1e1b4b 0%, transparent 40%),
                radial-gradient(circle at 100% 100%, #1e3a8a 0%, transparent 40%),
                radial-gradient(circle at 50% 50%, #0f172a 0%, transparent 50%);
    animation: mesh-flow 15s ease infinite alternate;
    z-index: 0;
}

@keyframes mesh-flow {
    0% { transform: translate(-25%, -25%) rotate(0deg); }
    100% { transform: translate(0%, 0%) rotate(5deg); }
}

.auth-box { 
    position: relative;
    z-index: 1;
    background: var(--glass); 
    backdrop-filter: blur(25px) saturate(200%);
    -webkit-backdrop-filter: blur(25px) saturate(200%);
    width: 420px; 
    padding: 48px; 
    border-radius: 28px; 
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    text-align: center;
}

.brand-header { 
    display: flex; 
    flex-direction: column;
    align-items: center; 
    gap: 12px; 
    margin-bottom: 32px; 
}

.brand-logo { 
    width: 60px; 
    height: 60px; 
    background: linear-gradient(135deg, var(--accent), #1d4ed8); 
    color: white; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 18px; 
    font-weight: 800; 
    font-size: 2rem; 
    box-shadow: 0 0 20px var(--accent-glow);
}

.auth-box h2 { 
    font-size: 1.75rem; 
    letter-spacing: -0.03em; 
    color: #fff;
}

.auth-box p { 
    color: var(--text-muted); 
    font-size: 0.9rem; 
    margin-top: 4px;
}

.field { 
    text-align: left; 
    margin-bottom: 20px; 
}

.field label { 
    display: block; 
    font-size: 0.65rem; 
    font-weight: 700; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    margin-bottom: 8px; 
    letter-spacing: 0.1em; 
}

.field input { 
    width: 100%; 
    padding: 14px 16px; 
    background: rgba(255, 255, 255, 0.05); 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-radius: 12px; 
    font-size: 1rem; 
    color: white;
    transition: all 0.3s ease;
}

.field input:focus { 
    background: rgba(255, 255, 255, 0.08); 
    border-color: var(--accent); 
    outline: none; 
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); 
}

.btn-primary { 
    width: 100%; 
    padding: 16px; 
    background: var(--accent); 
    color: white; 
    border: none; 
    border-radius: 12px; 
    font-weight: 700; 
    font-size: 1rem;
    cursor: pointer; 
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-primary:hover { 
    background: #2563eb; 
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px var(--accent-glow);
}

/* --- MAIN APP LAYOUT --- */
.dashboard { 
    display: flex; 
    height: 100vh; 
    background: var(--bg-main);
}

.sidebar { 
    width: 280px; 
    background: var(--sidebar-bg); 
    padding: 32px 24px; 
    display: flex; 
    flex-direction: column; 
    border-right: 1px solid var(--border); 
}

.brand-logo.sm { 
    width: 36px; 
    height: 36px; 
    font-size: 1.1rem; 
    margin-bottom: 32px; 
}

.history-label { 
    font-size: 0.7rem; 
    text-transform: uppercase; 
    font-weight: 700; 
    color: #475569; 
    margin: 32px 0 12px 0; 
    letter-spacing: 0.1em; 
}

.history-item { 
    padding: 12px; 
    font-size: 0.85rem; 
    border-radius: 8px; 
    cursor: pointer; 
    color: var(--text-muted);
    transition: 0.2s; 
    border: 1px solid transparent; 
}

.history-item:hover { 
    background: rgba(255,255,255,0.05); 
    color: white; 
}

/* --- WORKSPACE --- */
.workspace { 
    flex: 1; 
    padding: 40px; 
    display: flex; 
    flex-direction: column; 
    gap: 32px; 
    overflow-y: auto;
}

.workspace-header h1 { 
    font-size: 1.75rem; 
    font-weight: 700; 
}

.badge { 
    background: rgba(59, 130, 246, 0.15); 
    color: var(--accent); 
    padding: 6px 14px; 
    border-radius: 20px; 
    font-size: 0.75rem; 
    font-weight: 600; 
}

.panel { 
    background: var(--glass); 
    border-radius: 20px; 
    border: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
    backdrop-filter: blur(10px);
}

.panel-header { 
    padding: 20px 24px; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.panel-header .title { 
    font-size: 0.75rem; 
    font-weight: 700; 
    color: var(--text-muted); 
    text-transform: uppercase; 
}

.editor-container { 
    padding: 24px; 
}

textarea { 
    width: 100%;
    min-height: 120px;
    background: transparent;
    border: none; 
    resize: none; 
    font-size: 1.1rem; 
    color: white; 
    font-family: inherit; 
}

textarea:focus { outline: none; }

.btn-action { 
    background: var(--text-primary); 
    color: var(--sidebar-bg); 
    border: none; 
    padding: 14px 28px; 
    border-radius: 12px; 
    font-weight: 700; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    transition: 0.2s; 
}

.btn-action:hover { 
    transform: scale(1.02); 
    background: #fff;
}

/* --- FLASHCARD GRID --- */
.flashcard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding-bottom: 40px;
}

.flashcard {
    height: 200px;
    perspective: 1000px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.flashcard.flipped .card-inner { transform: rotateY(180deg); }

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
}

.card-front {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: white;
}

.card-back {
    background: var(--accent);
    color: white;
    transform: rotateY(180deg);
}

.card-icon { 
    font-size: 1.5rem; 
    margin-bottom: 15px; 
    opacity: 0.5; 
}

/* --- UTILITIES & SYSTEM --- */
.hidden { display: none !important; }

.model-badge { 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 0.7rem; 
    background: rgba(255,255,255,0.05); 
    padding: 6px 12px; 
    border-radius: 8px; 
    color: var(--accent); 
}

.btn-ghost { 
    background: transparent; 
    color: var(--text-muted); 
    border: 1px solid var(--border); 
    padding: 12px; 
    border-radius: 12px; 
    width: 100%; 
    cursor: pointer; 
    transition: 0.2s; 
}

.btn-ghost:hover { 
    background: rgba(239, 68, 68, 0.1); 
    color: #ef4444; 
    border-color: #ef4444; 
}

.loading-state {
    grid-column: 1 / -1;
    padding: 60px;
    text-align: center;
    color: var(--text-muted);
}

.pulse { 
    display: inline-block;
    width: 12px; 
    height: 12px; 
    border-radius: 50%; 
    background: var(--green); 
    margin-right: 10px;
    animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}