/* Modernized styles for Root Locus Tool - aligned with site design system */

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 16px 20px;
    background-color: #f4f6f8;
    color: #333;
}

/* Main layout container - wider + charts get priority (matches Type II / modern pattern) */
section.tool-page {
    max-width: 1480px;
    margin: 16px auto;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 20px;
}

/* Left controls column - narrower for wider chart area */
.calculator {
    background-color: #f9f9f9;
    padding: 18px 20px 22px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    width: 26%;   /* Maximizing visualization width under the full blue header */
    flex-shrink: 0;
}

/* Visualization area - new layout:
   Top row: Root Locus (left, prominent) + Time domain (right, Step + Impulse stacked)
   Bottom row (full width): Bode plot, much larger (spans under both columns) */
.charts {
    width: 73%;
    padding-left: 8px;
    min-width: 0;
    display: grid;
    /* Two columns on top, Bode spans full width below */
    grid-template-columns: 1.1fr 0.9fr;
    grid-template-rows: auto 2fr;   /* Bottom row (Bode) gets significantly more vertical space */
    gap: 12px;
}

/* Top row container */
.top-row {
    grid-column: 1 / -1;           /* Span both columns */
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 12px;
}

/* Root Locus in top-left */
.viz-rootlocus {
    display: flex;
    flex-direction: column;
}

/* Time domain in top-right (Step + Impulse stacked) */
.viz-timedomain {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Bode plot - full width at bottom, reduced to ~75% of previous tall size */
.viz-bode {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
}

/* Prominent transfer function equation cards */
.equation-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.equation-card .equation-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}

.equation-card .equation-latex {
    font-size: 1.05rem;   /* Significantly larger and more prominent than before */
    line-height: 1.3;
}

.equation-card.closed-loop {
    border-left: 3px solid #1a73e8;
}

.equation-card.open-loop {
    border-left: 3px solid #059669;   /* Green-ish to differentiate from closed-loop */
}

/* Coordinate readouts under charts (matching style from other tools) */
.chart-coordinates {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 2px;
    margin-bottom: 8px;
    padding-left: 4px;
    min-height: 1em;
}

/* Root Locus Explanation section at the bottom */
.explanation-section {
    max-width: 1100px;
    margin: 40px auto 60px;
    padding: 24px 28px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.explanation-section h2 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.35rem;
    color: #1e2937;
    border-bottom: 2px solid #cbd5e1;
    padding-bottom: 8px;
}

.explanation-section p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #334155;
    margin-bottom: 12px;
}

.explanation-section ul {
    margin: 12px 0 16px 20px;
    line-height: 1.55;
}

.explanation-section li {
    margin-bottom: 6px;
    color: #475569;
}

.calculator h2 {
    margin: 0 0 12px 0;
    font-size: 1.05rem;
    color: #1f2937;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 6px;
}

.param-group {
    margin-bottom: 10px;
}

.sub-group {
    margin-left: 18px;
    padding-left: 10px;
    border-left: 2px solid #e5e7eb;
}

.lead-presets {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    width: 100%;
    max-width: 160px;
}

.lead-preset-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    color: #334155;
    cursor: pointer;
    text-align: left;
}

.lead-preset-btn[data-lead-preset="early"] { border-color: #fca5a5; }
.lead-preset-btn[data-lead-preset="target"] { border-color: #86efac; }
.lead-preset-btn[data-lead-preset="late"] { border-color: #fdba74; }

.lead-preset-btn.active { color: #fff; border-color: transparent; }
.lead-preset-btn[data-lead-preset="early"].active { background: #dc2626; }
.lead-preset-btn[data-lead-preset="target"].active { background: #16a34a; }
.lead-preset-btn[data-lead-preset="late"].active { background: #ea580c; }

label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
    margin-bottom: 3px;
}

input[type="number"] {
    width: 100%;
    max-width: 160px;
    padding: 5px 7px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.9rem;
}

input[type="number"]:focus {
    border-color: #1a73e8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

input[type="range"] {
    width: 100%;
    max-width: 160px;
    margin: 2px 0 6px;
    -webkit-appearance: none;
    height: 5px;
    background: #e5e7eb;
    border-radius: 999px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #1a73e8;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #1557b0;
}

/* Button group for action buttons */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 6px;
}

/* Buttons - improved modern styling */
button {
    background-color: #1a73e8;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    transition: background-color 0.1s ease;
}

button:hover {
    background-color: #1557b0;
}

button:active {
    transform: translateY(1px);
}

.lead-preset-btn {
    background: #f8fafc;
    color: #334155;
    border: 2px solid #e2e8f0;
    font-weight: 600;
}

.lead-preset-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

.lead-preset-btn.active:hover {
    color: #fff;
}

#metrics {
    font-size: 0.88rem;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
    line-height: 1.45;
    color: #374151;
}

canvas {
    width: 100%;
    height: auto;
    display: block;
}

/* Root Locus and time-domain plots get solid height */
.viz-rootlocus canvas,
.viz-timedomain canvas {
    min-height: 280px;
}

/* Bode reduced to ~75% of its previous large size */
.viz-bode canvas {
    min-height: 390px;
}

/* Checkbox labels inside param groups */
.param-group label input[type="checkbox"] {
    margin-right: 6px;
    vertical-align: middle;
}
