:root {
    --bg-primary: #040812;
    --bg-secondary: #080c18;
    --card-bg: rgba(13, 20, 38, 0.55);
    --border-color: rgba(255, 255, 255, 0.05);
    --text-primary: #f8fafc;
    --text-secondary: #8ea5c6;
    --accent-color: #00ff66;
    --accent-glow: rgba(0, 255, 102, 0.4);
    --bg-radial: rgba(0, 255, 102, 0.03);
    --panel-glow: rgba(14, 165, 233, 0.12);
}

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

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 10% 20%, var(--bg-radial) 0%, transparent 45%),
        radial-gradient(circle at 90% 80%, rgba(30, 41, 59, 0.15) 0%, transparent 45%);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-image 0.5s ease;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1.5rem;
    gap: 1rem;
}

/* Header Styles */
.app-header {
    background: linear-gradient(90deg, rgba(13, 20, 38, 0.4) 0%, rgba(8, 12, 24, 0.4) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.85rem 1.75rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.prism-icon {
    font-size: 1.6rem;
    color: var(--accent-color);
    filter: drop-shadow(0 0 10px var(--accent-glow));
    animation: pulse-glow 2.5s infinite ease-in-out;
}

.logo h1 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 3px;
    background: linear-gradient(135deg, #ffffff 0%, #a5bdf3 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
}

/* Header Credit & Photo Integration */
.header-credit {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    cursor: default;
}

.credit-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
}

.developer-tag {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-color);
    text-shadow: 0 0 8px var(--accent-glow);
}

.developer-name {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: #f8fafc;
    letter-spacing: 0.5px;
}

.header-avatar-container {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    border: 1.5px solid var(--accent-color);
    box-shadow: 0 0 12px var(--accent-glow);
    background: #03050a;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
}

.header-profile-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover; /* focuses on the face in a circular crop */
}

.header-credit:hover .header-avatar-container {
    border-color: #ffffff;
    box-shadow: 0 0 16px rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
}

/* Main Layout */
.app-main {
    display: flex;
    flex: 1;
    gap: 1.25rem;
    min-height: 0;
}

/* Card Styles */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    padding: 1.5rem;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.09);
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Visual Simulation Area */
.canvas-card {
    flex: 1.7;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
    height: 100%;
}

.canvas-card:hover {
    border-color: rgba(0, 255, 102, 0.15);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 255, 102, 0.02);
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-badge {
    padding: 0.45rem 1rem;
    border-radius: 9999px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.status-refraction {
    background-color: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.35);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
}

.status-tir {
    background-color: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.35);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.25);
    animation: pulse-tir-badge 1.5s infinite alternate;
}

.status-missing {
    background-color: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.canvas-tips {
    font-size: 0.775rem;
    color: var(--text-secondary);
}

.canvas-container {
    flex: 1;
    position: relative;
    border-radius: 14px;
    background-color: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.03);
    overflow: hidden;
    /* Grid background */
    background-size: 40px 40px;
    background-image: 
        linear-gradient(to right, rgba(255, 255, 255, 0.012) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.012) 1px, transparent 1px);
}

#opticsCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Sidebar Area */
.sidebar {
    flex: 1;
    min-width: 380px;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    padding-right: 0.25rem;
}

/* Scrollbar Styling for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

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

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* Compact Profile Card (Bottom of Sidebar) */
.profile-card {
    background: linear-gradient(135deg, rgba(13, 20, 38, 0.4) 0%, rgba(7, 10, 20, 0.4) 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.85rem 1.25rem;
    border-radius: 14px;
}

.profile-card:hover {
    border-color: rgba(0, 255, 102, 0.12);
    box-shadow: 0 8px 25px rgba(0, 255, 102, 0.03);
}

.profile-layout-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.compact-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.profile-card .profile-name {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: 0.5px;
}

.profile-card .profile-title {
    font-size: 0.725rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.status-tag {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 700;
    background: rgba(0, 210, 255, 0.08);
    border: 1px solid rgba(0, 210, 255, 0.2);
    color: #00d2ff;
    text-transform: uppercase;
    letter-spacing: 0.75px;
}

/* Control Titles & Subtitle */
.controls-card h2, .dashboard-card h2 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.6rem;
    color: #e2e8f0;
    text-transform: uppercase;
}

/* Sliders and Controls */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.control-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.math-sym {
    font-style: italic;
    font-family: 'Times New Roman', Times, serif;
    font-weight: 600;
    font-size: 0.95rem;
}

.value-display {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Range Slider Styling */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: #0f1524;
    outline: none;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
    transition: transform 0.1s, box-shadow 0.1s, background-color 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.25);
    box-shadow: 0 0 15px var(--accent-glow);
    background: var(--accent-color);
}

/* Color Picker */
.group-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.color-picker-grid {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.15rem;
}

.color-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.color-btn:hover {
    transform: scale(1.2);
}

.color-btn.active {
    border-color: #fff;
    transform: scale(1.15);
    box-shadow: 0 0 14px var(--accent-glow);
}

/* Checkbox Toggle Switch Styles */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 0.75rem;
}

.toggle-switch {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-round {
    width: 34px;
    height: 18px;
    background-color: #0f1524;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: .3s;
    border-radius: 34px;
    margin-right: 0.75rem;
    position: relative;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: #8ea5c6;
    transition: .3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .slider-round {
    background-color: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-glow);
}

.toggle-switch input:checked + .slider-round:before {
    transform: translateX(16px);
    background-color: #fff;
}

.toggle-label {
    font-size: 0.825rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Physics Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.stat-item {
    background: rgba(8, 12, 24, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.03);
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-label {
    font-size: 0.725rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Explanation Box */
.explanation-box {
    background: rgba(8, 12, 24, 0.55);
    border-left: 3px solid var(--accent-color);
    border-radius: 0 8px 8px 0;
    padding: 0.9rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.25rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.explanation-box h3 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.75px;
    color: #e2e8f0;
}

.explanation-box p {
    font-size: 0.8rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.explanation-box p strong {
    color: #fff;
}

/* Footer Section */
.app-footer {
    text-align: center;
    padding: 0.75rem 0;
    font-size: 0.775rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.highlight-name {
    color: var(--accent-color);
    font-weight: 600;
    text-shadow: 0 0 8px var(--accent-glow);
}

/* Animations */
@keyframes pulse-glow {
    0%, 100% {
        filter: drop-shadow(0 0 5px var(--accent-glow));
    }
    50% {
        filter: drop-shadow(0 0 12px var(--accent-glow));
    }
}

@keyframes pulse-tir-badge {
    0% {
        box-shadow: 0 0 4px rgba(239, 68, 68, 0.15);
        border-color: rgba(239, 68, 68, 0.35);
    }
    100% {
        box-shadow: 0 0 14px rgba(239, 68, 68, 0.5);
        border-color: rgba(239, 68, 68, 0.7);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .app-container {
        height: auto;
        overflow-y: auto;
    }
    
    .app-main {
        flex-direction: column;
        height: auto;
    }
    
    .canvas-card {
        height: 520px;
    }
    
    .sidebar {
        width: 100%;
        max-width: 100%;
        overflow-y: visible;
    }
}
