/* Color Palette and Variables */
:root {
    --bg-color: #000000;
    --bg-grad-end: #0f0f0f;
    --sidebar-bg: rgba(10, 10, 10, 0.85);
    
    --primary-red: #ff0000;
    --glow-red: rgba(255, 0, 0, 0.6);
    --dark-red: #8b0000;
    
    --glass-bg: rgba(20, 20, 20, 0.7);
    --glass-border: rgba(255, 0, 0, 0.2);
    
    --text-main: #ffffff;
    --text-muted: #888888;
    
    --btn-bg: rgba(30, 30, 30, 0.8);
    --btn-hover: rgba(50, 50, 50, 0.9);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, var(--bg-color), var(--bg-grad-end));
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow: hidden;
}

h1, h2, h3, .logo-text, .calc-input, .calc-history, .btn, .glass-input {
    font-family: 'Orbitron', sans-serif;
}

/* Flame Cursor Canvas */
#flame-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1000;
    mix-blend-mode: screen;
}

/* Loading Screen */
.loader-bg {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #000;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transition: opacity 1s ease-out;
}
.loader-content {
    text-align: center;
}
.neon-text {
    color: var(--primary-red);
    text-shadow: 0 0 10px var(--glow-red), 0 0 20px var(--glow-red);
}
.spinner {
    width: 50px; height: 50px;
    border: 3px solid rgba(255,0,0,0.2);
    border-top-color: var(--primary-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Main App Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    transition: opacity 1s ease-in;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    z-index: 10;
    overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--primary-red); border-radius: 4px; }

.brand {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.5rem;
    letter-spacing: 2px;
}
.sidebar .nav-title {
    color: var(--primary-red);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 1.5rem 0 0.5rem 10px;
    opacity: 0.8;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.nav-links li:not(.nav-title) {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 15px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.3s ease;
    border: 1px solid transparent;
}
.nav-links li:not(.nav-title):hover {
    color: var(--text-main);
    background: rgba(255,255,255,0.05);
}
.nav-links li.active {
    color: var(--primary-red);
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    box-shadow: inset 0 0 10px rgba(255,0,0,0.2), 0 0 15px rgba(255,0,0,0.1);
}

/* Main Content */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 4rem;
    position: relative;
    z-index: 5;
    overflow-y: auto;
}
header {
    width: 100%;
    max-width: 800px;
    margin-bottom: 2rem;
}
header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: -webkit-linear-gradient(#fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8), inset 0 1px 1px rgba(255,255,255,0.05);
    padding: 30px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
}
.glass-card:hover {
    box-shadow: 0 15px 50px rgba(255,0,0,0.15), inset 0 1px 1px rgba(255,255,255,0.08);
}

/* View Control */
.view {
    display: none;
    width: 100%;
    max-width: 800px;
    animation: fadeIn 0.5s ease-out forwards;
}
.view.active {
    display: flex;
    justify-content: center;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Flying Widget Controls */
@keyframes floatWidget {
    0% { transform: translateY(0px); box-shadow: 0 5px 15px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.05); }
    50% { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(255,0,0,0.15), inset 0 1px 2px rgba(255,255,255,0.1); }
    100% { transform: translateY(0px); box-shadow: 0 5px 15px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.05); }
}

.tools-card {
    max-width: 500px;
}
.calc-display-container {
    background: rgba(0,0,0,0.6);
    border-radius: 15px;
    padding: 15px 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 0, 0, 0.1);
    box-shadow: inset 0 5px 15px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.calc-history {
    font-size: 1rem;
    color: var(--text-muted);
    min-height: 20px;
    margin-bottom: 5px;
}
.calc-input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 2.5rem;
    font-weight: 700;
    text-align: right;
    width: 100%;
    outline: none;
    text-shadow: 0 0 10px rgba(255,255,255,0.2);
}

/* Grid Layouts for Different modes */
.calc-grid {
    display: grid;
    gap: 12px;
    padding: 5px;
}
.calc-grid { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(7, 1fr); }
.std-grid { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(6, 1fr); }
.prog-grid { grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(6, 1fr); }

.btn {
    background: rgba(20, 20, 20, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,0,0,0.2);
    color: var(--text-main);
    font-size: 1.1rem;
    padding: 12px 0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    user-select: none;
    animation: floatWidget 6s infinite ease-in-out;
}
/* Staggered floating delays */
.btn:nth-child(even) { animation-delay: 0.5s; }
.btn:nth-child(3n) { animation-delay: 1.1s; }
.btn:nth-child(4n) { animation-delay: 1.8s; }
.btn:nth-child(5n) { animation-delay: 0.8s; }

.btn:hover {
    animation-play-state: paused;
    background: var(--btn-hover);
    transform: translateY(-5px) scale(1.05) perspective(500px) rotateX(5deg);
    box-shadow: 0 15px 30px rgba(255,0,0,0.3), inset 0 2px 2px rgba(255,255,255,0.2);
    border-color: rgba(255, 0, 0, 0.6);
    z-index: 10;
}
.btn:active {
    transform: translateY(1px);
}

/* Ripple effect */
.btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 0, 0, 0.4);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}
@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}

.fn-btn { color: var(--text-muted); }
.op-btn { 
    color: var(--primary-red); 
    background: rgba(100,0,0,0.2);
    border-color: rgba(255,0,0,0.1);
}
.eq-btn { 
    background: linear-gradient(135deg, var(--dark-red), var(--primary-red));
    box-shadow: 0 0 15px var(--glow-red);
    border: none;
    color: #fff;
}
.eq-btn:hover {
    box-shadow: 0 0 25px var(--glow-red);
}

/* Programmer Bases */
.base-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Orbitron', monospace;
    font-size: 0.9rem;
}
.base-row:hover { background: rgba(255,255,255,0.05); }
.active-base {
    background: rgba(255,0,0,0.1);
    border-left: 3px solid var(--primary-red);
}
.base-label { color: var(--text-muted); width: 40px; }
.base-val { color: var(--text-main); font-weight: bold; flex: 1; text-align: right; overflow:hidden;}
.active-base .base-label, .active-base .base-val { color: var(--primary-red); text-shadow: 0 0 5px var(--glow-red); }

/* Converters */
.converter-card {
    width: 100%;
}
.converter-header {
    margin-bottom: 30px;
    text-align: center;
}
.converter-header h3 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}
.converter-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}
.flex-col-mobile { display: flex; }
@media (max-width: 768px) {
    .flex-col-mobile { flex-direction: column; }
    .swap-btn { transform: rotate(90deg); margin: 10px 0; }
}
.input-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    width: 100%;
}
.glass-input, .glass-select {
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-main);
    padding: 15px;
    border-radius: 12px;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s;
    width: 100%;
}
.glass-input:focus, .glass-select:focus {
    border-color: var(--primary-red);
    box-shadow: 0 0 15px rgba(255,0,0,0.3);
}
.result-glow {
    color: var(--primary-red);
    font-weight: 700;
    text-shadow: 0 0 10px var(--glow-red);
    background: rgba(200,0,0,0.05);
}
.slim-select {
    padding: 12px;
    font-size: 1rem;
    cursor: pointer;
}
.swap-btn {
    background: rgba(30, 30, 30, 0.8);
    border: 1px solid var(--primary-red);
    color: var(--primary-red);
    width: 60px; height: 60px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.swap-btn:hover {
    background: var(--primary-red);
    color: #000;
    box-shadow: 0 0 20px var(--glow-red);
    transform: rotate(180deg);
}

select option {
    background: #111;
    color: #fff;
    padding: 10px;
}

.small-text {
    text-align: center;
    color: var(--text-muted);
    font-weight: 300;
    font-size: 0.9rem;
    margin-top: 30px;
}
