/* S-Parameter Visualization Styles */

/* Main Container */
.sparam-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
    border-radius: 12px;
    padding: 20px;
    font-family: 'Segoe UI', 'Roboto', sans-serif;
    color: #c9d1d9;
    min-height: 900px;
}

/* Top Section: 3D View */
.sparam-3d-section {
    display: flex;
    gap: 20px;
    min-height: 400px;
}

.sparam-3d-container {
    flex: 1;
    background: #0d1117;
    border-radius: 10px;
    border: 1px solid #30363d;
    position: relative;
    overflow: hidden;
}

.sparam-3d-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.sparam-3d-label {
    position: absolute;
    top: 10px;
    left: 15px;
    color: #58a6ff;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 10;
}

/* Port Labels */
.port-label {
    position: absolute;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    z-index: 10;
}

.port-label.port1 {
    left: 20px;
    top: calc(50% + 70px);
    transform: translateY(-50%);
    background: rgba(0, 255, 255, 0.2);
    color: #00ffff;
    border: 1px solid rgba(0, 255, 255, 0.4);
}

.port-label.port2 {
    right: 20px;
    top: calc(50% + 70px);
    transform: translateY(-50%);
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.4);
}

.port-label.dut {
    left: 50%;
    top: 210px;
    transform: translateX(-50%);
    background: rgba(255, 215, 0, 0.2);
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.4);
}

/* 3D Legend Overlay */
.legend-3d {
    position: absolute;
    bottom: 15px;
    left: 15px;
    background: rgba(10, 10, 21, 0.85);
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 11px;
    color: #c9d1d9;
    z-index: 10;
}

.legend-3d-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.legend-3d-item:last-child {
    margin-bottom: 0;
}

.legend-3d-line {
    display: inline-block;
    width: 20px;
    height: 3px;
    border-radius: 2px;
}

.legend-3d-line.incident {
    background: #00ffff;
}

.legend-3d-line.reflected {
    background: #ff6b9d;
}

.legend-3d-line.standing {
    background: #ffd93d;
    height: 2px;
    border: none;
    background-image: repeating-linear-gradient(
        90deg,
        #ffd93d 0px,
        #ffd93d 4px,
        transparent 4px,
        transparent 7px
    );
    background-color: transparent;
}

.legend-3d-line.transmitted {
    background: #00ff88;
}

.legend-3d-line.s22-reflected {
    background: #6bcbff;
}

/* Control Panel */
.sparam-control-panel {
    width: 300px;
    min-width: 300px;
    background: rgba(22, 27, 34, 0.9);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #30363d;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sparam-section-title {
    color: #58a6ff;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    padding-bottom: 8px;
    border-bottom: 1px solid #30363d;
}

/* Slider Controls */
.sparam-slider-group {
    margin-bottom: 15px;
}

.sparam-slider-group.s11 { border-left: 3px solid #ff6b6b; padding-left: 12px; }
.sparam-slider-group.s21 { border-left: 3px solid #00ff88; padding-left: 12px; }

.sparam-slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.sparam-slider-label span:first-child {
    color: #c9d1d9;
    font-size: 12px;
}

.sparam-slider-label .value {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #7ee787;
    min-width: 60px;
    text-align: right;
}

.sparam-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #21262d;
    border-radius: 3px;
    outline: none;
}

.sparam-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #58a6ff;
    cursor: pointer;
    border: 2px solid #0d1117;
    box-shadow: 0 0 8px rgba(88, 166, 255, 0.5);
}

.sparam-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #58a6ff;
    cursor: pointer;
    border: 2px solid #0d1117;
}

/* Spin Box Grid for S-Parameters */
.sparam-spinbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.sparam-spinbox-group {
    background: #0d1117;
    border-radius: 8px;
    padding: 10px;
    border: 1px solid #30363d;
}

.sparam-spinbox-group.s11 { border-left: 3px solid #ff6b9d; }
.sparam-spinbox-group.s12 { border-left: 3px solid #ffd93d; }
.sparam-spinbox-group.s21 { border-left: 3px solid #00ff88; }
.sparam-spinbox-group.s22 { border-left: 3px solid #00ffff; }

.spinbox-label {
    font-size: 11px;
    font-weight: 600;
    color: #c9d1d9;
    margin-bottom: 8px;
    text-align: center;
}

.sparam-spinbox-group.s11 .spinbox-label { color: #ff6b9d; }
.sparam-spinbox-group.s12 .spinbox-label { color: #ffd93d; }
.sparam-spinbox-group.s21 .spinbox-label { color: #00ff88; }
.sparam-spinbox-group.s22 .spinbox-label { color: #00ffff; }

.spinbox-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.spinbox-prefix {
    font-size: 11px;
    color: #8b949e;
    min-width: 28px;
}

.spinbox-suffix {
    font-size: 11px;
    color: #8b949e;
}

.sparam-spinbox {
    flex: 1;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #c9d1d9;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 4px 6px;
    width: 60px;
    text-align: center;
}

.sparam-spinbox:focus {
    border-color: #58a6ff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.sparam-spinbox::-webkit-inner-spin-button,
.sparam-spinbox::-webkit-outer-spin-button {
    opacity: 1;
    height: 20px;
}

/* Power Flow Display */
.power-flow {
    background: #0d1117;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #30363d;
}

.power-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 12px;
}

.power-row:not(:last-child) {
    border-bottom: 1px solid #21262d;
}

.power-label {
    color: #8b949e;
}

.power-value {
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.power-value.incident { color: #00ffff; }
.power-value.reflected { color: #ff6b9d; }
.power-value.transmitted { color: #00ff88; }
.power-value.absorbed { color: #ffd93d; }

/* Bottom Section: Smith Chart and Wave View */
.sparam-bottom-section {
    display: flex;
    gap: 20px;
    min-height: 200px;
}

/* Smith Chart */
.smith-chart-container {
    flex: 1;
    background: #0d1117;
    border-radius: 10px;
    border: 1px solid #30363d;
    padding: 15px;
    display: flex;
    flex-direction: column;
    max-height: 450px;  /* ← Limit height */
    overflow: hidden;
}

.smith-chart-label {
    color: #58a6ff;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.smith-chart-canvas {
    flex: 1;
    background: #0a0a15;
    border-radius: 8px;
}

/* Wave Analysis */
.wave-analysis-container {
    flex: 1;
    background: #0d1117;
    border-radius: 10px;
    border: 1px solid #30363d;
    padding: 15px;
    display: flex;
    flex-direction: column;
    max-height: 450px;  /* ← Limit height */
    overflow: hidden;
}

.wave-analysis-label {
    color: #58a6ff;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.wave-canvas {
    flex: 1;
    background: #0a0a15;
    border-radius: 8px;
}

/* Legend */
.wave-legend {
    display: flex;
    gap: 20px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.legend-line {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.incident { background: #00ffff; }
.legend-line.reflected { background: #ff6b9d; }
.legend-line.transmitted { background: #00ff88; }
.legend-line.s22-reflected { background: #6bcbff; }
.legend-line.standing { background: #ffd93d; }

/* Preset Controls */
.preset-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preset-row {
    display: flex;
    gap: 8px;
}

.preset-dropdown {
    flex: 1;
    padding: 10px 12px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-dropdown:hover {
    border-color: #58a6ff;
}

.preset-dropdown:focus {
    outline: none;
    border-color: #58a6ff;
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.preset-dropdown option {
    background: #21262d;
    color: #c9d1d9;
    padding: 8px;
}

.step-btn {
    flex: 1;
    padding: 8px 12px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.step-btn:hover {
    background: #30363d;
    border-color: #58a6ff;
    color: #58a6ff;
}

.step-btn:active {
    background: rgba(88, 166, 255, 0.2);
}

/* Animation Controls */
.animation-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.anim-btn {
    flex: 1;
    padding: 10px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.anim-btn:hover {
    background: #30363d;
}

.anim-btn.play {
    background: rgba(0, 255, 136, 0.2);
    border-color: #00ff88;
    color: #00ff88;
}

.anim-btn.pause {
    background: rgba(255, 107, 107, 0.2);
    border-color: #ff6b6b;
    color: #ff6b6b;
}

/* Frequency Control */
.freq-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #21262d;
    padding: 10px;
    border-radius: 6px;
}

.freq-label {
    color: #8b949e;
    font-size: 12px;
}

.freq-value {
    font-family: 'Courier New', monospace;
    color: #ffd93d;
    font-size: 14px;
    font-weight: 600;
}

/* Info Panel */
.info-panel {
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
}

.info-panel-title {
    color: #58a6ff;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

.info-panel-content {
    font-size: 11px;
    line-height: 1.5;
    color: #8b949e;
}

/* Impedance Display */
.impedance-display {
    background: #0d1117;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #30363d;
    margin-top: 10px;
}

.impedance-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
}

.impedance-label {
    color: #8b949e;
}

.impedance-value {
    font-family: 'Courier New', monospace;
    color: #da70d6;
}

/* Responsive */
@media (max-width: 1200px) {
    .sparam-3d-section {
        flex-direction: column;
    }
    
    .sparam-control-panel {
        width: 100%;
        min-width: auto;
    }
    
    .sparam-bottom-section {
        flex-direction: column;
    }
}

/* Tooltip */
.sparam-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 11px;
    pointer-events: none;
    z-index: 100;
    max-width: 200px;
}

/* Divider */
.sparam-divider {
    height: 1px;
    background: #30363d;
    margin: 10px 0;
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #21262d;
    border-radius: 6px;
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.running {
    background: #00ff88;
}

.status-dot.paused {
    background: #ffd93d;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Drive Port Toggle */
.drive-toggle-container {
    display: flex;
    gap: 4px;
    background: #0d1117;
    padding: 4px;
    border-radius: 6px;
    border: 1px solid #30363d;
    margin-bottom: 15px;
}

.drive-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #8b949e;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.drive-btn:hover {
    background: rgba(35, 134, 54, 0.3);
    color: #c9d1d9;
}

.drive-btn.active {
    background: #238636;
    color: white;
}

/* Dim inactive S-parameter controls - still usable but visually subdued */
.sparam-spinbox-group.dimmed {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.sparam-spinbox-group.dimmed .spinbox-label {
    color: #6e7681;
}

.sparam-spinbox-group:not(.dimmed) {
    transition: opacity 0.3s ease;
}
