/**
 * 3D Phased Array Beamforming Simulator Styles
 * Dark mode, scientific aesthetic
 * Max width: 800px, Font: Courier New, Background: Black
 */

.antenna3d-container {
    max-width: 800px;
    margin: 0 auto;
    background-color: #000000;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    padding: 10px;
    position: relative; /* Ensure absolute children position relative to this */
}

.top-panel {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-bottom: 10px;
    align-items: stretch; /* Make both children same height */
}

.canvas2d-container {
    flex: 0 0 auto; /* Don't grow or shrink */
    width: 300px; /* Set width to match height for 1:1 aspect ratio */
    height: 300px;
    aspect-ratio: 1 / 1; /* Ensure 1:1 aspect ratio */
    background-color: #000000;
    border: 1px solid #333333;
    position: relative;
}

.array2d-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.canvas2d-label {
    position: absolute;
    top: 5px;
    left: 5px;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 3px 6px;
    border-radius: 3px;
    pointer-events: none;
}

.three-container {
    width: 100%;
    height: 600px;
    background-color: #000000;
    border: 1px solid #333333;
    position: relative;
    margin-bottom: 10px;
}

.three-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: relative; /* Base layer */
    z-index: 1;
}

.ui-panel {
    position: relative;
    background-color: rgba(0, 0, 0, 0.8);
    border: 1px solid #333333;
    padding: 15px;
    border-radius: 5px;
    flex: 1; /* Fill remaining space */
    min-width: 250px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.ui-panel h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: bold;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.control-section {
    margin-bottom: 15px;
}

.control-section:last-child {
    margin-bottom: 0;
}

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

.control-group:last-child {
    margin-bottom: 0;
}

.control-group.control-inline {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.control-group.control-inline label {
    margin-bottom: 0;
    flex-shrink: 0;
    white-space: nowrap;
}

.control-group.control-inline .select-control {
    flex: 1;
    min-width: 0;
}

.button-group {
    display: flex;
    flex-direction: row;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center; /* Center align buttons horizontally */
}

.button-group .btn {
    margin: 0;
    flex: 0 0 auto;
    white-space: nowrap;
}

.control-group label {
    display: block;
    font-size: 11px;
    color: #cccccc;
    margin-bottom: 5px;
}

.control-group.control-slider-inline {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.control-group.control-slider-inline label {
    display: inline-block;
    margin-bottom: 0;
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 11px;
    color: #cccccc;
    min-width: fit-content;
}

.control-group.control-slider-inline input[type="range"] {
    flex: 1;
    min-width: 0;
    height: 6px;
    background-color: #333333;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.control-group.control-slider-inline .slider-value {
    display: inline-block;
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 11px;
    color: #00ffff;
    min-width: 40px;
    text-align: right;
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    background-color: #333333;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background-color: #00ffff;
    border-radius: 50%;
    cursor: pointer;
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background-color: #00ffff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.control-group input[type="checkbox"] {
    margin-right: 5px;
    cursor: pointer;
}

.control-group input[type="checkbox"]:checked {
    accent-color: #00ffff;
}

.control-group select.select-control {
    width: 100%;
    padding: 6px 8px;
    background-color: #003333;
    border: 1px solid #00aaaa;
    color: #00ffff;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2300ffff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 30px;
}

.control-group select.select-control:hover {
    border-color: #00ffff;
    background-color: #004444;
}

.control-group select.select-control:focus {
    border-color: #00ffff;
    background-color: #004444;
}

.control-group select.select-control option {
    background-color: #000000;
    color: #00ffff;
    padding: 5px;
}

.btn {
    background-color: #003333;
    border: 1px solid #00aaaa;
    color: #00ffff;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    padding: 6px 12px;
    margin: 3px;
    cursor: pointer;
    border-radius: 3px;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn:hover {
    background-color: #004444;
    border-color: #00ffff;
}

.btn:active {
    background-color: #005555;
}

.plot-panel {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: 10px;
}

.plot-container {
    flex: 1;
    height: 300px;
    min-height: 300px;
    width: 100%;
    background-color: #000000;
    border: 1px solid #333333;
    position: relative;
}

.plot-container > div {
    width: 100% !important;
    height: 100% !important;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .top-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .canvas2d-container {
        width: 100%;
        max-width: 100%;
        aspect-ratio: 1 / 1; /* Maintain square aspect ratio */
        margin: 0 auto; /* Center it when stacked */
    }
    
    .ui-panel {
        width: 100%;
        max-width: none;
        flex: 1 1 auto; /* Allow it to grow when stacked vertically */
    }
    
    .plot-panel {
        flex-direction: column;
    }
    
    .plot-container {
        width: 100%;
    }
}

/* Override Plotly default styles for dark theme */
.plot-container .js-plotly-plot {
    background-color: #000000 !important;
}

.plot-container .plotly .gridlayer {
    stroke: #333333 !important;
}

.plot-container .plotly .axislayer {
    fill: #ffffff !important;
}
