:root {
    /* Dark Theme (Default) */
    --theme-bg: #0f172a;
    --theme-card-bg: rgba(30, 41, 59, 0.7);
    --theme-text: #f8fafc;
    --theme-text-dim: #94a3b8;
    --theme-border: rgba(255, 255, 255, 0.1);
    --theme-primary: #6366f1;
    --theme-accent: #818cf8;
    --theme-success: #10b981;
    --theme-warning: #f59e0b;
    --theme-danger: #ef4444;
}

[data-theme="light"] {
    --theme-bg: #f1f5f9;
    --theme-card-bg: rgba(255, 255, 255, 0.8);
    --theme-text: #1e293b;
    --theme-text-dim: #64748b;
    --theme-border: rgba(0, 0, 0, 0.1);
    --theme-primary: #4f46e5;
    --theme-accent: #6366f1;
}

/* Base override for existing pages */
body {
    background-color: var(--theme-bg);
    color: var(--theme-text);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

/* Theme Toggle Button Styles */
.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-border);
    color: var(--theme-text);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    flex-shrink: 0;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle i {
    font-size: 1.2rem;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .theme-toggle {
        width: 44px; /* Larger touch target */
        height: 44px;
        top: 0.75rem;
        right: 0.75rem;
    }
}

/* Map existing variables to theme variables */
body {
    --bg: var(--theme-bg);
    --card-bg: var(--theme-card-bg);
    --text: var(--theme-text);
    --text-dim: var(--theme-text-dim);
    --border: var(--theme-border);
    --primary: var(--theme-primary);
    --text-light: var(--theme-text);
    --text-muted: var(--theme-text-dim);
    --card-border: var(--theme-border);
    --drawer-bg: var(--theme-card-bg);
    --text-color: var(--theme-text);
    --bg-color: var(--theme-bg);
    --primary-color: var(--theme-primary);
}


/* Global Theme Overrides for all modes */
body {
    background: var(--theme-bg);
    color: var(--theme-text);
    background-attachment: fixed;
}

.info-panel, 
.action-panel,
.card,
.master-card {
    background-color: var(--theme-card-bg) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

h1, 
h2, 
h3 {
    color: var(--theme-text) !important;
}

p, 
.text-dim,
.label {
    color: var(--theme-text-dim) !important;
}

.code-block,
#console-emulator,
#event-log {
    background-color: var(--theme-bg) !important;
    border: 1px solid var(--theme-border) !important;
    color: var(--theme-text) !important;
}

.drawer {
    background-color: var(--drawer-bg) !important;
    border-right: 1px solid var(--theme-border) !important;
}

.drawer-item {
    color: var(--theme-text-dim) !important;
}

.drawer-item:hover {
    background-color: rgba(128, 128, 128, 0.1) !important;
    color: var(--theme-text) !important;
}

.drawer-item.active {
    background-color: var(--theme-primary) !important;
    color: #ffffff !important;
}

.top-nav {
    background-color: var(--theme-card-bg) !important;
    border-bottom: 1px solid var(--theme-border) !important;
}

.menu-btn {
    color: var(--theme-text) !important;
}

.variable-display {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: var(--theme-border) !important;
}

input {
    background: var(--theme-bg) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

.back-link {
    color: var(--theme-text-dim) !important;
}


/* Enhanced Code Tag Styling */
code {
    font-family: 'Fira Code', monospace;
    background: rgba(99, 102, 241, 0.15);
    color: var(--theme-accent) !important;
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-block;
    line-height: 1;
}

[data-theme="light"] code {
    background: rgba(79, 70, 229, 0.1);
    border-color: rgba(79, 70, 229, 0.2);
    color: var(--theme-primary) !important;
}

code:hover {
    background: rgba(99, 102, 241, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive Utilities */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    .desktop-only {
        display: none;
    }
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}


/* Floating Download Button for Projects */
.floating-download {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    background: var(--theme-primary);
    color: white !important;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.floating-download:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
    background: var(--theme-accent);
}

@media (max-width: 768px) {
    .floating-download {
        bottom: 1.5rem;
        right: 1.5rem;
        padding: 0.7rem 1.2rem;
        font-size: 0.85rem;
    }
}
