/* ==========================================================================
   DESIGN SYSTEM & VARIABLES (Poppins & Light/Dark Theme System)
   ========================================================================== */
:root {
    --font-sans: 'Poppins', 'Inter', sans-serif;
    --font-code: 'Fira Code', monospace;

    /* Light Theme (Default Base) */
    --bg-app: #f3f4f6;
    --bg-sidebar: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.06);
    --card-border: rgba(0, 0, 0, 0.08);

    --text-main: #1f2937;
    --text-muted: #6b7280;

    --primary-grad: linear-gradient(135deg, #6d28d9 0%, #4338ca 100%);
    --accent-glow: rgba(109, 40, 217, 0.15);

    --sidebar-width: 280px;
    --radius-lg: 16px;
    --radius-md: 12px;
}


/* ==========================================================================
   CORE BODY & LAYOUT WRAPPERS
   ========================================================================== */
body {
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-main);
    transition: background-color 0.4s ease, color 0.4s ease;
    overflow-x: hidden;
    margin: 0;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    padding: 2.5rem;
    min-width: 0;
    transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
}

@media (max-width: 991.98px) {
    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }
}

/* ==========================================================================
   NAVIGATION SIDEBAR STYLING
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--glass-border);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    display: flex;
    flex-column: initial;
    flex-direction: column;
    padding: 2rem 1.5rem;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.02);
    transition: transform 0.3s ease, background-color 0.4s ease;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2.5rem;
}

.brand i {
    -webkit-text-fill-color: initial;
    color: #7c3aed;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.nav-item a:hover {
    color: var(--text-main);
    background-color: rgba(124, 58, 237, 0.06);
}

.nav-item.active a {
    background: var(--primary-grad);
    color: #ffffff !important;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary-grad);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 4px 10px var(--accent-glow);
}

/* ==========================================================================
   GLASSMORPHISM UNIQUE CARD ARCHITECTURE
   ========================================================================== */
.glass-card {
    background-color: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, background-color 0.4s ease;
}

.glass-card:hover {
    box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   BUTTON DESIGN LINES
   ========================================================================== */
.btn-premium {
    background: var(--primary-grad);
    color: #ffffff !important;
    border: none;
    padding: 0.65rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 14px var(--accent-glow);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
    opacity: 0.95;
}

.btn-secondary-premium {
    background: rgba(0, 0, 0, 0.02);
    color: var(--text-main) !important;
    border: 1px solid var(--card-border);
    padding: 0.65rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.btn-secondary-premium:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: var(--text-muted);
}

.btn-danger-premium {
    background: rgba(244, 63, 94, 0.1);
    color: #f43f5e !important;
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 0.65rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.btn-danger-premium:hover {
    background: #f43f5e;
    color: #ffffff !important;
}

/* ==========================================================================
   ANALYTICS & STATS METRICS DISPLAY GRID
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-val {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-top: 0.25rem;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ==========================================================================
   MONACO EDITOR WRAPPERS & CONTAINER OVERLAYS
   ========================================================================== */
.editor-container {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--card-border);
    min-height: 350px;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(243, 244, 246, 0.95);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Glow Pulser Animation */
.spinner-glow {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-grad);
    animation: pulseGlow 1.8s infinite ease-in-out;
}

@keyframes pulseGlow {
    0% {
        transform: scale(0.6);
        opacity: 0.1;
        box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.7);
    }

    50% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 25px 10px rgba(124, 58, 237, 0.4);
    }

    100% {
        transform: scale(0.6);
        opacity: 0.1;
        box-shadow: 0 0 0 0 rgba(124, 58, 237, 0);
    }
}

/* Typing Indicator Animation Structure */
.typing-indicator {
    display: flex;
    gap: 6px;
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    background: #7c3aed;
    border-radius: 50%;
    animation: bounceDots 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounceDots {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1.0);
    }
}

/* Custom premium scrollbar styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.25);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 58, 237, 0.5);
}


/* ==========================================================================
   INTERACTIVE CHAT UI/UX COMPONENT STYLES
   ========================================================================== */
.chat-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 380px;
    position: relative;
}

.chat-history-box {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    margin-bottom: 1rem;
    max-height: 290px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-bubble {
    max-width: 85%;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.5;
    animation: fadeInBubble 0.25s ease forwards;
    position: relative;
    word-break: break-word;
}

.chat-bubble p:last-child {
    margin-bottom: 0;
}

.chat-bubble-user {
    align-self: flex-end;
    background: var(--primary-grad);
    color: #ffffff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.chat-bubble-ai {
    align-self: flex-start;
    background: rgba(0, 0, 0, 0.02);
    color: var(--text-main);
    border: 1px solid var(--card-border);
    border-bottom-left-radius: 2px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* Ensure code blocks look premium inside chat bubbles */
.chat-bubble-ai pre {
    background: rgba(0, 0, 0, 0.05) !important;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    padding: 0.75rem;
    margin: 0.75rem 0;
    overflow-x: auto;
}

.chat-bubble-ai code {
    font-family: var(--font-code);
    font-size: 0.82rem;
    color: inherit;
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    border-top: 1px solid var(--card-border);
    padding-top: 0.85rem;
}

.chat-input-box {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.01);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 0.65rem 1rem;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none !important;
    transition: all 0.2s ease;
    resize: none;
    height: 42px;
}

.chat-input-box:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.chat-send-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--primary-grad);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 10px var(--accent-glow);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    opacity: 0.95;
    box-shadow: 0 6px 15px var(--accent-glow);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    transform: none;
    box-shadow: none;
    cursor: not-allowed;
}

/* Chat bubble time tag */
.chat-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
    text-align: right;
}

.chat-bubble-user .chat-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Chat loading/typing container */
.chat-bubble-ai.chat-bubble-loading {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.65rem 1rem;
}

@keyframes fadeInBubble {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}