/* ==========================================================================
   PLL Loop Filter — Local styles
   Uses shared.css for header, base typography, buttons, inputs, and tokens.
   Only tool-specific dashboard layout + dense controls kept here.
   ========================================================================== */

/* Main wide container for this dashboard tool (kept wider than standard for the 4-col layout) */
section#tools {
    max-width: 1800px;
    margin: 16px auto;
    padding: 16px 24px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Chart coordinate readout (still used under the Bode plot) */
.chart-coordinates {
    font-size: 0.85rem;
    color: var(--ai-gray-700);
    margin-top: 8px;
    text-align: center;
    padding: 8px 10px;
    background-color: var(--ai-gray-100);
    border-radius: var(--ai-radius-sm);
    border: 1px solid var(--ai-gray-200);
}

/* ============================================
   NEW PLL LAYOUT (Sidebar + Big Chart)
   ============================================ */

.pll-layout {
    display: grid;
    /* buttons | parameters | plot | results */
    grid-template-columns: 95px 525px 1fr 340px;
    gap: 14px;
    align-items: start;
}

/* Far left narrow button strip */
.pll-button-strip {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
}

.pll-button-strip .button-toolbar.vertical {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Compose with shared .ai-button.small for consistent look + feel */
.pll-button-strip .ai-button.small {
    width: 100%;
    padding: 5px 6px;
    font-size: 0.75rem;
    border-radius: var(--ai-radius-sm);
}

/* Parameters column */
.pll-parameters {
    background: var(--ai-gray-50);
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-lg);
    padding: var(--ai-space-4);
}

.pll-parameters h3 {
    margin: 0 0 var(--ai-space-3) 0;
    font-size: 1.0rem;
    color: var(--ai-gray-800);
    font-weight: 600;
}

/* Two-column parameters (dense for the wide layout) */
.pll-parameters .param-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
}

.pll-parameters .param-group label {
    margin: 2px 0 1px;
    font-size: 0.8rem;
    color: var(--ai-gray-700);
    font-weight: 500;
}

.pll-parameters .param-group input[type="number"] {
    max-width: 88px;
    padding: 4px 6px;
    font-size: 0.85rem;
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-sm);
}

.pll-parameters .param-group input[type="number"]:focus {
    border-color: var(--ai-blue-600);
    outline: none;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.12);
}

/* Range sliders inside the dense parameter grid — match shared look */
.pll-parameters .param-group input[type="range"] {
    accent-color: var(--ai-blue-600);
    height: 5px;
    background: var(--ai-gray-200);
    border-radius: 999px;
    margin: 3px 0 4px;
}
.pll-parameters .param-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--ai-blue-600);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.pll-parameters .param-group .equation {
    font-size: 0.68rem;
    color: var(--ai-gray-600);
    margin-top: 1px;
    line-height: 1.25;
}

.pll-parameters .param-group small {
    font-size: 0.68rem;
    color: var(--ai-gray-500);
}

/* Plot area (hero card) */
.pll-plot-area {
    background: var(--ai-bg-card);
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-lg);
    padding: var(--ai-space-3) var(--ai-space-4);
    min-width: 0;
}

.pll-plot-area h3 {
    margin: 0 0 6px 0;
    font-size: 0.95rem;
    color: var(--ai-gray-800);
    font-weight: 600;
}

/* Results panel to the right of the plot (numeric results only, compact) */
.pll-results-panel {
    background-color: #fff;
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-lg);
    padding: 12px 16px;
    align-self: start;
    font-size: 0.9rem;
    color: var(--ai-gray-700);
}

/* Nice cards inside the results panel (replaces old .results-section / .dc-gain styles) */
.pll-results-panel .results-section > div {
    background: var(--ai-gray-50);
    padding: 10px 12px;
    border-radius: var(--ai-radius-sm);
    border-left: 3px solid var(--ai-blue-600);
    margin-bottom: 10px;
    line-height: 1.35;
}

.pll-results-panel .dc-gain {
    font-weight: 600;
    color: var(--ai-blue-800);
}

.pll-results-panel .pll-metrics {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
}

.pll-results-panel .poles-zeros {
    font-size: 0.8rem;
    line-height: 1.35;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Hide any leftover old transfer styling */
.results-section .transfer {
    display: none;
}

/* G(s) equation placed nicely under the Bode plot */
.transfer-under-plot {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--ai-gray-100);
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-md);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    color: var(--ai-gray-700);
}

.transfer-under-plot .mathjax-eq {
    margin-left: 4px;
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-sm);
    display: inline-block;
    transform: scale(1.5);
    transform-origin: left center;
}

/* Plot canvas - let it use the width of its column well */
.pll-plot-area .chart-section canvas {
    width: 100% !important;
    height: 400px !important;   /* a bit taller for better visibility */
    min-height: 380px;
}

/* Tighter gap to the G(s) equation now that it lives directly below the chart in this card */
.pll-plot-area .chart-section {
    margin-bottom: 8px;
}

/* Schematic (kept at bottom, uses a few local tweaks) */
.schematic-section {
    text-align: center;
    margin-top: var(--ai-space-6);
}
.schematic {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 380px;
    margin: 0 auto;
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-md);
    box-shadow: var(--ai-shadow-sm);
}

/* Responsive fallback (keeps the 4-col experience great on wide screens) */
@media (max-width: 1100px) {
    .pll-layout {
        grid-template-columns: 1fr;
    }
}

/* Explanation section at the bottom (similar to Root Locus tool) */
.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: 14px;
}

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

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