/* Premium Physics Simulation Stylesheet */
:root {
    --bg-gradient: radial-gradient(circle at top left, #0d0e15, #121622 60%, #07090f);
    --panel-bg: rgba(22, 28, 45, 0.6);
    --panel-border: rgba(255, 255, 255, 0.18);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.35);
    
    --obj1: #f43f5e;
    --obj1-glow: rgba(244, 63, 94, 0.4);
    --obj2: #0ea5e9;
    --obj2-glow: rgba(14, 165, 233, 0.4);
    --total: #10b981;
    --total-glow: rgba(16, 185, 129, 0.4);
    
    --canvas-bg: #0f1322;
}

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

body {
    background: var(--bg-gradient);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 1400px;
    height: 85vh;
    max-height: 900px;
    background: rgba(10, 12, 22, 0.3);
    border-radius: 24px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.8), 
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(25px);
    transition: all 0.3s ease;
}

/* HEADER */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 30px;
    background: rgba(10, 14, 26, 0.5);
    border-bottom: 1px solid var(--panel-border);
    backdrop-filter: blur(10px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.logo-icon::after {
    content: '';
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 8px #fff;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    border: 1px solid var(--panel-border);
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.nav-btn svg {
    stroke-width: 2.5;
}

.nav-btn.info {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.2);
}

.nav-btn.info:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.25);
}

.tabs {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.35);
    padding: 4px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.tab-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 8px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary), #2563eb);
    color: #fff;
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* MAIN LAYOUT */
.sim-wrapper {
    flex: 1;
    display: grid;
    grid-template-columns: 1.8fr 1.2fr;
    grid-template-rows: 1.3fr 0.7fr;
    gap: 12px;
    padding: 16px;
    height: 0;
}

/* CANVAS SIMULATION SCREEN */
.sim-container {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
    background: var(--canvas-bg);
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6),
                0 15px 30px rgba(0, 0, 0, 0.3);
}

canvas#simCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.sim-overlay {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 14, 26, 0.85);
    padding: 8px 20px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sim-overlay::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
}

.sim-overlay.hidden {
    opacity: 0;
    transform: translate(-50%, -10px);
}

/* CONTROLS PANEL */
.controls-panel {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    background: var(--panel-bg);
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    padding: 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.controls-panel.hidden {
    display: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 6px;
}

.btn-toggle-panel {
    display: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle-panel:hover {
    background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 1024px) {
    .btn-toggle-panel {
        display: block;
    }
    
    .controls-panel.collapsed {
        height: auto !important;
        max-height: none !important;
        padding-bottom: 12px;
    }
    
    .controls-panel.collapsed > *:not(.panel-header):not(.actions) {
        display: none !important;
    }
}

.panel-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: #fff;
}

.badge {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid rgba(59, 130, 246, 0.25);
    letter-spacing: 0.5px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#controls-fma .control-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

#controls-fma .control-group label {
    width: 85px;
    flex-shrink: 0;
    margin-bottom: 0;
}

#controls-fma .control-group input[type=range] {
    flex-grow: 1;
    margin: 0;
}

#controls-fma .control-group .val-display {
    width: 60px;
    text-align: right;
    flex-shrink: 0;
    display: inline-flex;
    justify-content: flex-end;
    align-items: baseline;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: #fff;
    font-size: 1rem;
}

.control-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
}

.val-display {
    color: #fff;
    font-weight: 700;
    margin-left: auto;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
}

.unit {
    margin-left: 3px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Range Sliders */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    margin: 4px 0;
    touch-action: none;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    transition: background 0.2s;
}

input[type=range]:hover::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.12);
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    border: 3px solid var(--primary);
    transition: transform 0.1s ease, border-color 0.2s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* Two-column layout in collision controls */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.obj-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 12px;
    border-radius: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
}

.obj-controls h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.obj-controls h3::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.obj1 h3 { color: var(--obj1); }
.obj1 h3::before { background: var(--obj1); box-shadow: 0 0 8px var(--obj1-glow); }
.obj2 h3 { color: var(--obj2); }
.obj2 h3::before { background: var(--obj2); box-shadow: 0 0 8px var(--obj2-glow); }

.obj-controls input[type=range]::-webkit-slider-thumb {
    border-color: currentColor;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

/* BUTTONS AND ACTIONS */
.actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.action-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    font-family: 'Inter', sans-serif;
}

.action-btn.play {
    background: linear-gradient(135deg, var(--primary), #2563eb);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.action-btn.play:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-1.5px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.action-btn.play:active {
    transform: translateY(0.5px);
}

.action-btn.play.paused {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.35);
}

.action-btn.play.paused:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
}

.action-btn.reset {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    border: 1px solid var(--panel-border);
}

.action-btn.reset:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.12);
}

/* STATS BOX */
.stats-box {
    background: rgba(0, 0, 0, 0.25);
    padding: 10px;
    border-radius: 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.stat-value {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-value span {
    color: #fff;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
}

/* GRAPH & PLOTTING PANELS */
.chart-container {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    background: var(--panel-bg);
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.bar-chart-container {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    background: var(--panel-bg);
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    padding: 12px 18px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.chart-container.hidden, .bar-chart-container.hidden {
    display: none !important;
}

canvas#fmaChart {
    width: 100%;
    height: 100%;
    display: block;
}

/* Collision Bar Chart styling */
.bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.bar-group h4 {
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.bar-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 12px;
}

.bar-label {
    width: 50px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.bar-track {
    flex: 1;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    overflow: hidden;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
}

.bar {
    height: 100%;
    border-radius: 6px;
    width: 0%;
    transition: width 0.08s linear;
}

.obj1-bar { background: linear-gradient(90deg, #9f1239, var(--obj1)); box-shadow: 0 0 10px var(--obj1-glow); }
.obj2-bar { background: linear-gradient(90deg, #0369a1, var(--obj2)); box-shadow: 0 0 10px var(--obj2-glow); }
.total-bar { background: linear-gradient(90deg, #065f46, var(--total)); box-shadow: 0 0 10px var(--total-glow); }

.bar-wrapper span {
    font-size: 0.8rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    color: #fff;
    width: 55px;
    text-align: right;
}

/* INFO MODAL */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 7, 12, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: rgba(20, 26, 44, 0.95);
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    width: 90%;
    max-width: 520px;
    padding: 28px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transform: translateY(0) scale(1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(10px);
}

.modal-backdrop.hidden .modal-content {
    transform: translateY(30px) scale(0.95);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 14px;
}

.modal-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    line-height: 1;
}

.close-btn:hover {
    color: #fff;
    transform: rotate(90deg);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-body h3 {
    font-family: 'Outfit', sans-serif;
    color: #60a5fa;
    font-size: 1.05rem;
    margin-bottom: 6px;
    font-weight: 600;
}

.modal-body p {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
    font-weight: 450;
}

.modal-body hr {
    border: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
}

/* RESPONSIVE SCALING AND MOBILE */
@media (max-width: 1024px) {
    body {
        overflow-y: auto;
        padding: 12px;
    }
    
    .app-container {
        height: auto;
        max-height: none;
    }
    
    .sim-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        height: auto;
        padding: 16px;
        gap: 16px;
    }
    
    .sim-container {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        aspect-ratio: 16 / 9;
    }
    
    .controls-panel {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
    }
    
    .chart-container, .bar-chart-container {
        grid-column: 1 / 2;
        grid-row: 3 / 4;
        height: 250px;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 16px;
    }
    .header-left {
        width: 100%;
        justify-content: space-between;
    }
    .tabs {
        width: 100%;
        display: flex;
    }
    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 8px 6px;
        font-size: 0.8rem;
    }
    .modal-content {
        max-height: 85vh;
        display: flex;
        flex-direction: column;
        padding: 20px;
    }
    .modal-body {
        overflow-y: auto;
        padding-right: 4px;
    }
    .sim-overlay {
        display: none !important;
    }
}

@media (max-width: 640px) {
    .two-col {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    #controls-fma .control-group {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    #controls-fma .control-group label {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    #controls-fma .control-group .val-display {
        width: auto;
        text-align: right;
    }
}

