@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Inter:wght@300;400;600&display=swap');

:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-red: #ef4444;
    --accent-green: #10b981;
    --border: #334155;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    /* CHANGE 1: Scrolling Enable karne ke liye ye update kiya */
    min-height: 100vh; 
    height: auto;
    overflow-y: auto; /* Ab scroll bar aayega */
    padding: 15px;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg-card); }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; border: 2px solid var(--bg-card); }
::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }

.dashboard-container {
    max-width: 1600px; 
    margin: 0 auto; 
    /* CHANGE 2: Height constraint hataya */
    display: flex; 
    flex-direction: column; 
    gap: 15px;
}

.header {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-card); padding: 15px 25px; border-radius: 12px; border: 1px solid var(--border);
}
.logo-section { display: flex; align-items: center; gap: 15px; color: var(--accent-blue); }
.status-indicator { font-size: 0.85rem; color: var(--accent-green); background: rgba(16, 185, 129, 0.1); padding: 5px 12px; border-radius: 20px; display: flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; background: currentColor; border-radius: 50%; box-shadow: 0 0 8px currentColor; animation: pulse 2s infinite; }

/* Main Grid Layout */
.main-grid {
    display: grid; 
    grid-template-columns: 350px 1fr; 
    /* CHANGE 3: Grid rows ko auto kar diya taaki content fit ho */
    grid-template-rows: auto auto; 
    gap: 15px; 
}

/* Cards generic style */
.card { 
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; 
}

/* --- Left Panel --- */
.controls-panel { 
    grid-row: 1 / span 2; 
    /* Height fix */
    height: fit-content; 
}

/* Specs Box */
.specs-box {
    background: rgba(15, 23, 42, 0.6); border: 1px solid #334155; border-radius: 8px; padding: 15px; margin-bottom: 20px;
}
.specs-box h3 { font-size: 0.8rem; color: var(--accent-blue); margin-bottom: 10px; text-transform: uppercase; }
.specs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 0.8rem; margin-bottom: 10px; }
.spec-item { display: flex; justify-content: space-between; background: #0f172a; padding: 5px 8px; border-radius: 4px; border: 1px solid #1e293b; }
.spec-item strong { color: var(--accent-cyan); font-family: 'JetBrains Mono'; }
.formula-box { background: #0f172a; padding: 8px; border-radius: 4px; text-align: center; border: 1px dashed #334155; }
.formula-box code { color: var(--accent-green); font-family: 'JetBrains Mono'; display: block; margin-top: 3px; }

h2 { font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 15px; display: flex; align-items: center; gap: 10px; }
.control-group { margin-bottom: 20px; }
.label-row { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--text-muted); font-size: 0.9rem; }
.input-row { display: flex; gap: 8px; margin-bottom: 10px; }
input[type="number"] { background: #0f172a; border: 1px solid var(--border); color: white; padding: 8px; border-radius: 6px; flex: 1; font-family: 'JetBrains Mono'; }
.unit-tag { display: flex; align-items: center; padding: 0 10px; background: #334155; border-radius: 6px; font-size: 0.8rem; }
.slider { width: 100%; height: 4px; background: #334155; border-radius: 2px; -webkit-appearance: none; }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; background: var(--accent-blue); border-radius: 50%; cursor: pointer; }
.button-group { display: flex; gap: 10px; margin-top: 20px; }
.btn { flex: 1; padding: 12px; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: var(--accent-blue); color: white; }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }

/* --- Right Panel Visuals --- */
.visuals-wrapper { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 15px; }
.motor-card { background: radial-gradient(circle at center, #2d3b4e 0%, #1e293b 100%); position: relative; overflow: hidden; padding: 30px 20px; min-height: 350px; } /* Added min-height */
.motor-header { position: absolute; top: 15px; left: 15px; right: 15px; display: flex; justify-content: space-between; z-index: 10; }
.data-tag { font-size: 0.85rem; color: var(--text-muted); background: rgba(15, 23, 42, 0.6); padding: 5px 10px; border-radius: 4px; }
.data-tag strong { color: var(--text-primary); }

.motor-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 20px; }
.motor-housing { width: 180px; height: 180px; border-radius: 50%; border: 8px solid #475569; background: #0f172a; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 20px rgba(0,0,0,0.8), 0 10px 20px rgba(0,0,0,0.5); }
#motor-fan { font-size: 100px; color: #94a3b8; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5)); transition: color 0.3s ease; }
.motor-base { width: 120px; height: 15px; background: #334155; border-radius: 10px 10px 0 0; margin-top: 5px; }

.digital-panel { background: #000; border: 2px solid #334155; padding: 10px 30px; border-radius: 8px; text-align: center; box-shadow: 0 4px 15px rgba(0,0,0,0.5); min-width: 160px; }
.panel-label { display: block; font-size: 0.75rem; color: #94a3b8; margin-bottom: 5px; letter-spacing: 1px; text-transform: uppercase; }
.panel-screen { font-family: 'JetBrains Mono', monospace; font-size: 2.2rem; font-weight: 700; color: #4ade80; text-shadow: 0 0 10px rgba(74, 222, 128, 0.4); line-height: 1; }
.panel-screen .unit { font-size: 1rem; color: #94a3b8; margin-left: 5px; text-shadow: none; }

.meters-row { display: flex; gap: 15px; flex-wrap: wrap; }
.meter-box { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; min-width: 150px; }
.meter-content h3 { justify-content: center; }
.digital-readout { font-family: 'JetBrains Mono'; font-size: 1.8rem; font-weight: 700; color: white; }
.digital-readout.cyan { color: var(--accent-cyan); }
.formula-hint { display: block; font-size: 0.7rem; color: #64748b; margin-top: 5px; font-family: 'JetBrains Mono'; }

/* --- Tooltip --- */
.tooltip-container { position: relative; display: inline-block; cursor: help; }
.info-icon { color: var(--text-muted); font-size: 0.9rem; transition: color 0.2s; }
.info-icon:hover { color: var(--accent-blue); }
.tooltip-text { visibility: hidden; width: 200px; background-color: #000; color: #fff; text-align: center; border-radius: 6px; padding: 8px; position: absolute; z-index: 100; bottom: 125%; left: 50%; margin-left: -100px; opacity: 0; transition: opacity 0.3s; font-size: 0.75rem; border: 1px solid var(--accent-blue); box-shadow: 0 4px 10px rgba(0,0,0,0.5); font-family: 'JetBrains Mono'; }
.tooltip-container:hover .tooltip-text { visibility: visible; opacity: 1; }

.divider { border: 0; border-top: 1px solid #334155; margin: 20px 0; }

/* --- Table & Graph --- */
.table-panel { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; min-height: 300px; } /* Min height added */
.table-container { flex: 1; overflow-y: auto; max-height: 400px; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { text-align: left; padding: 10px; background: #334155; position: sticky; top: 0; z-index: 5; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-family: 'JetBrains Mono'; }

.graph-panel { grid-column: 2; grid-row: 3; min-height: 300px; } /* Changed row to 3 so it stacks below table */
.chart-container { position: relative; width: 100%; height: 100%; min-height: 250px; }

/* Animation */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

/* Responsive adjustments */
@media (max-width: 1200px) {
    .main-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
    .controls-panel { grid-row: auto; }
    .visuals-wrapper { grid-column: 1; grid-row: auto; }
    .table-panel { grid-column: 1; grid-row: auto; }
    .graph-panel { grid-column: 1; grid-row: auto; }
}