/* modern.css - Premium UI Overrides for Dark/Light Themes */

:root {
    --brand-500: 99, 102, 241; /* rgb(99, 102, 241) is #6366f1 */
    --brand-glow: rgba(99, 102, 241, 0.4);
    --glass-bg: rgba(255, 255, 255, 0.96);
    --glass-border: rgba(15, 23, 42, 0.10);
    --body-bg: #f8fafc;
    --text-primary: #1e293b;
    --card-shadow: 0 16px 40px -24px rgba(15, 23, 42, 0.35);
}

html.dark {
    --glass-bg: rgba(15, 23, 42, 0.96);
    --glass-border: rgba(148, 163, 184, 0.22);
    --body-bg: #020617;
    --text-primary: #f9fafb;
    --card-shadow: 0 22px 60px -26px rgba(0, 0, 0, 0.75);
}

body {
    background-color: var(--body-bg);
    color: var(--text-primary);
    background-image:
        radial-gradient(circle at 0% 0%, rgba(var(--brand-500), 0.06), transparent 32rem),
        radial-gradient(circle at 100% 100%, rgba(16, 185, 129, 0.05), transparent 30rem);
    background-attachment: fixed;
    transition: background-color 0.3s ease, color 0.3s ease;
}

html.dark body {
    background-color: var(--body-bg) !important;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(var(--brand-500), 0.16), transparent 34rem),
        radial-gradient(circle at 100% 100%, rgba(6, 182, 212, 0.10), transparent 32rem) !important;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px) saturate(135%);
    -webkit-backdrop-filter: blur(10px) saturate(135%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--card-shadow);
    border-radius: 1.5rem;
}

html.dark .glass-panel {
    color: #f8fafc;
}

/* Input Consistency */
.dark-input {
    background-color: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1; /* Darker border for light theme contrast */
    transition: all 0.2s ease;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
}

html.dark .dark-input {
    background-color: rgba(15, 23, 42, 0.8) !important;
    color: #f9fafb !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.dark-input:focus {
    border-color: rgb(var(--brand-500)) !important;
    box-shadow: 0 0 0 4px rgba(var(--brand-500), 0.15);
}

/* Marker Grid Stabilization */
.marker-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)) !important;
    gap: 10px;
    width: 100% !important;
    margin-top: 10px;
}

.marker-item {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #f1f5f9;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 0 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 44px !important;
    height: 44px !important;
    overflow: hidden;
}

.marker-item input {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
}

html.dark .marker-item {
    background: rgba(255, 255, 255, 0.05);
}

.marker-item svg, .marker-item img {
    width: 24px !important;
    height: 24px !important;
    fill: #475569;
    display: block !important;
    transition: all 0.2s ease;
    pointer-events: none;
    object-fit: contain;
}

html.dark .marker-item svg, html.dark .marker-item img {
    fill: #94a3b8 !important;
}

.marker-item:hover {
    border-color: rgba(var(--brand-500), 0.3);
    background: rgba(var(--brand-500), 0.05);
}

.marker-item.active {
    border-color: rgb(var(--brand-500)) !important;
    background: rgba(var(--brand-500), 0.1) !important;
    transform: scale(1.05);
}

.marker-item.active svg {
    fill: rgb(var(--brand-500)) !important;
}

/* Elite Tab Buttons */
.type-btn {
    background: #ffffff !important;
    color: #4b5563 !important;
    border: 1px solid #f1f5f9 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

html.dark .type-btn {
    background: #1e293b !important;
    color: #94a3b8 !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2) !important;
}

.type-btn i {
    color: rgb(var(--brand-500)) !important;
    transition: transform 0.3s ease;
}

.type-btn.active {
    background: #4f46e5 !important;
    color: #ffffff !important;
    border-color: #4f46e5 !important;
    box-shadow: 0 10px 15px -3px var(--brand-glow) !important;
    transform: translateY(-2px);
}

html.dark .type-btn.active {
    background: #4f46e5 !important;
    color: #ffffff !important;
    border-color: #4f46e5 !important;
}

.type-btn.active i {
    color: #ffffff !important; /* Force white icon on brand background */
}

.type-btn:hover:not(.active) {
    border-color: rgb(var(--brand-500)) !important;
    background: rgba(var(--brand-500), 0.05) !important;
}

.format-btn {
    min-height: 4rem;
    line-height: 1;
}

.format-btn i,
.format-btn span {
    pointer-events: none;
}

/* Section Header Labels */
.section-step {
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #94a3b8;
    margin-bottom: 0.75rem;
    display: block;
}

/* Fix Filename Input Group */
.group:focus-within i {
    color: rgb(var(--brand-500)) !important;
}

/* Animations */
.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.animate-shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

.glow-btn {
    box-shadow: 0 5px 15px -3px var(--brand-glow);
}
.glow-btn:hover {
    box-shadow: 0 8px 25px -5px var(--brand-glow);
}

/* --- Mastery Notify: Ether-Glass V4 (Frosted Glassmorphism) --- */
#mastery-notify-container {
    position: fixed;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 40000;
    display: flex;
    flex-direction: column;
    gap: 16px;
    pointer-events: none;
    width: 100%;
    max-width: 460px;
    align-items: center;
}

.mastery-toast {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(50px) saturate(180%);
    -webkit-backdrop-filter: blur(50px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 28px;
    padding: 18px 32px;
    display: flex;
    align-items: center;
    gap: 24px;
    box-shadow: 
        0 15px 35px -5px rgba(0, 0, 0, 0.3),
        inset 0 0 15px rgba(255, 255, 255, 0.05);
    animation: toast-ether-in 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: all 0.5s ease;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    width: fit-content;
    min-width: 360px;
}

/* Glass Aura Tints */
.toast-success { border-color: rgba(16, 185, 129, 0.3); background: rgba(16, 185, 129, 0.03); }
.toast-error { border-color: rgba(244, 63, 94, 0.3); background: rgba(244, 63, 94, 0.03); }
.toast-info { border-color: rgba(99, 102, 241, 0.3); background: rgba(99, 102, 241, 0.03); }

@keyframes toast-ether-in {
    0% { transform: translateY(-30px) scale(0.95); opacity: 0; filter: blur(5px); }
    100% { transform: translateY(0) scale(1); opacity: 1; filter: blur(0); }
}

.mastery-toast.toast-out {
    transform: translateY(-10px) scale(0.98); opacity: 0; filter: blur(15px); transition: all 0.4s ease;
}

.toast-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 22px;
}

.toast-success .toast-icon { background: linear-gradient(135deg, rgba(16, 185, 129, 0.8), #10b981); color: white; box-shadow: 0 8px 16px rgba(16, 185, 129, 0.4); }
.toast-error .toast-icon { background: linear-gradient(135deg, rgba(244, 63, 94, 0.8), #f43f5e); color: white; box-shadow: 0 8px 16px rgba(244, 63, 94, 0.4); }
.toast-info .toast-icon { background: linear-gradient(135deg, rgba(99, 102, 241, 0.8), #6366f1); color: white; box-shadow: 0 8px 16px rgba(99, 102, 241, 0.4); }

.toast-content { flex-grow: 1; }
.toast-title { font-size: 15px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.12em; color: #FFFFFF !important; margin-bottom: 3px; text-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.toast-message { font-size: 13px; font-weight: 700; color: #FFFFFF !important; opacity: 0.9; line-height: 1.4; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
}

/* --- Mastery Modal: High-Fidelity Dialogs --- */
.modal-fade-in { animation: modal-fade-in 0.3s ease forwards; }
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }

#mastery-modal-box { transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.4s ease; }
#mastery-modal-overlay.opacity-0 #mastery-modal-box { transform: scale(0.9) translateY(20px); opacity: 0; }

/* --- Mastery Modular Suite (Phase 5) --- */
.custom-scrollbar::-webkit-scrollbar { height: 4px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.1); border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.3); }

.nav-pills .nav-link { color: #64748b; background: transparent; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.nav-pills .nav-link.active { background: rgb(var(--brand-500)) !important; color: white !important; box-shadow: 0 10px 20px -5px rgba(var(--brand-500), 0.4); transform: scale(1.05); }
.nav-pills .nav-link:hover:not(.active) { background: rgba(var(--brand-500), 0.05); color: rgb(var(--brand-500)); }

.marker-node { border: 2px solid transparent; }
.marker-node.active { border-color: rgb(var(--brand-500)) !important; background: rgba(var(--brand-500), 0.1) !important; transform: scale(1.1); box-shadow: 0 10px 25px -10px rgba(var(--brand-500), 0.5); }
.marker-node.active svg { color: rgb(var(--brand-500)) !important; }

/* AI Background Sparkles */
@keyframes sparkles {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}
.fa-wand-magic-sparkles.animate-pulse { animation: sparkles 2s infinite ease-in-out; }

/* Download Nodes Styling */
.download-node {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}
.download-node:hover {
    background: rgba(var(--brand-500), 0.1);
    border-color: rgba(var(--brand-500), 0.3);
    transform: translateX(5px);
}
.download-node i { width: 32px; font-size: 16px; color: rgb(var(--brand-500)); }
.download-node span { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; }
