/* ============================================ */
/* EM Polarization Simulator - Styles          */
/* Three.js + jQuery Implementation            */
/* ============================================ */

/* ===== Container & Layout ===== */
.em-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 15px;
    max-width: 800px;
    margin: 0 auto;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
    border-radius: 12px;
    border: 1px solid #30363d;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.em-main-section {
    display: flex;
    gap: 15px;
    min-height: 500px;
}

/* ===== 3D View Container ===== */
.em-3d-container {
    flex: 1;
    min-width: 450px;
    background: #0a0a15;
    border-radius: 10px;
    border: 1px solid #30363d;
    position: relative;
    overflow: hidden;
}

.em-3d-label {
    position: absolute;
    top: 12px;
    left: 12px;
    color: #58a6ff;
    font-size: 13px;
    font-weight: 600;
    z-index: 10;
    background: rgba(13, 17, 23, 0.85);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #30363d;
}

/* Camera Controls */
.em-camera-controls {
    position: absolute;
    top: 45px;
    left: 12px;
    display: flex;
    flex-direction: row;
    gap: 3px;
    z-index: 10;
    background: rgba(13, 17, 23, 0.9);
    padding: 4px;
    border-radius: 6px;
    border: 1px solid #30363d;
}

.em-cam-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #30363d;
    border-radius: 4px;
    background: #21262d;
    color: #c9d1d9;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.em-cam-btn:active {
    background: #1f6feb;
    color: #fff;
}

.em-cam-divider {
    width: 1px;
    background: #30363d;
    margin: 2px 3px;
}

#em-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ===== Axis Labels ===== */
.axis-label {
    position: absolute;
    font-size: 14px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(13, 17, 23, 0.7);
    z-index: 10;
}

.axis-label.x-axis {
    color: #ff6b6b;
    bottom: 50%;
    right: 15px;
}

.axis-label.y-axis {
    color: #69db7c;
    top: 15px;
    left: 50%;
}

.axis-label.z-axis {
    color: #74c0fc;
    bottom: 15px;
    left: 50%;
}

/* ===== Control Panel ===== */
.em-control-panel {
    width: 300px;
    min-width: 300px;
    background: linear-gradient(180deg, #161b22 0%, #0d1117 100%);
    border-radius: 10px;
    border: 1px solid #30363d;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

/* ===== Slider Groups ===== */
.em-slider-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.em-slider-label {
    color: #c9d1d9;
    font-size: 11px;
    font-weight: 500;
    min-width: 80px;
    flex-shrink: 0;
}

.em-slider-value {
    color: #58a6ff;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    min-width: 40px;
    text-align: right;
    flex-shrink: 0;
}

.em-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    min-width: 80px;
    height: 5px;
    background: #21262d;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.em-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: linear-gradient(145deg, #58a6ff, #1f6feb);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(88, 166, 255, 0.4);
    transition: transform 0.15s ease;
}

.em-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.em-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: linear-gradient(145deg, #58a6ff, #1f6feb);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Colored sliders for different parameters */
.em-slider.amp-x::-webkit-slider-thumb {
    background: linear-gradient(145deg, #ff6b6b, #c92a2a);
    box-shadow: 0 2px 6px rgba(255, 107, 107, 0.4);
}

.em-slider.amp-y::-webkit-slider-thumb {
    background: linear-gradient(145deg, #69db7c, #2f9e44);
    box-shadow: 0 2px 6px rgba(105, 219, 124, 0.4);
}

.em-slider.phase::-webkit-slider-thumb {
    background: linear-gradient(145deg, #ffd43b, #fab005);
    box-shadow: 0 2px 6px rgba(255, 212, 59, 0.4);
}

/* ===== Preset Dropdown ===== */
.em-preset-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.em-preset-dropdown {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #30363d;
    border-radius: 6px;
    background: #21262d;
    color: #c9d1d9;
    cursor: pointer;
    transition: all 0.2s ease;
    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='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.em-preset-dropdown:hover {
    background-color: #30363d;
    border-color: #58a6ff;
}

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

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

/* ===== Toggle Switches ===== */
.em-toggle-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.em-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.em-toggle-label {
    color: #c9d1d9;
    font-size: 12px;
}

.em-toggle {
    position: relative;
    width: 44px;
    height: 22px;
}

.em-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.em-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #21262d;
    border: 1px solid #30363d;
    transition: 0.3s;
    border-radius: 22px;
}

.em-toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: #8b949e;
    transition: 0.3s;
    border-radius: 50%;
}

.em-toggle input:checked + .em-toggle-slider {
    background-color: #238636;
    border-color: #3fb950;
}

.em-toggle input:checked + .em-toggle-slider:before {
    transform: translateX(22px);
    background-color: #fff;
}

/* ===== Info Box ===== */
.em-info-box {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 12px;
}

.em-info-title {
    color: #58a6ff;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.em-info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.em-info-label {
    color: #8b949e;
    font-size: 11px;
}

.em-info-value {
    color: #c9d1d9;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.em-info-value.linear { color: #ffd43b; }
.em-info-value.circular { color: #69db7c; }
.em-info-value.elliptical { color: #da77f2; }

/* ===== Bottom Section: Trace Plane ===== */
.em-bottom-section {
    display: flex;
    gap: 15px;
    min-height: 280px;
}

.em-trace-container {
    flex: 1;
    background: #0d1117;
    border-radius: 10px;
    border: 1px solid #30363d;
    padding: 15px;
    position: relative;
}

.em-trace-label {
    color: #58a6ff;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
}

#em-trace-canvas {
    width: 100%;
    height: 220px;
    background: #0a0a15;
    border-radius: 6px;
    border: 1px solid #21262d;
}

/* ===== Field Equations Panel ===== */
.em-equations-container {
    width: 350px;
    background: #0d1117;
    border-radius: 10px;
    border: 1px solid #30363d;
    padding: 15px;
}

.em-equation {
    background: #161b22;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #c9d1d9;
    border-left: 3px solid #58a6ff;
}

.em-equation .e-field { color: #ff6b6b; }
.em-equation .b-field { color: #74c0fc; }
.em-equation .phase { color: #ffd43b; }
.em-equation .math { color: #69db7c; }

/* ===== Legend ===== */
.em-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #21262d;
}

.em-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #8b949e;
}

.em-legend-color {
    width: 16px;
    height: 4px;
    border-radius: 2px;
}

.em-legend-color.e-field { background: #ff6b6b; }
.em-legend-color.b-field { background: #74c0fc; }
.em-legend-color.wave-line { background: #da77f2; }
.em-legend-color.trace { background: #ffd43b; }

/* ===== Animation Controls ===== */
.em-anim-controls {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.em-anim-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #30363d;
    border-radius: 6px;
    background: #21262d;
    color: #c9d1d9;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.em-anim-btn.playing {
    background: linear-gradient(145deg, #1f6feb, #58a6ff);
    border-color: #58a6ff;
    color: #fff;
}

/* ===== Polarization Type Badge ===== */
.em-pol-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    margin-top: 8px;
}

.em-pol-badge.linear {
    background: linear-gradient(145deg, #ffd43b, #fab005);
    color: #1a1a2e;
}

.em-pol-badge.circular {
    background: linear-gradient(145deg, #69db7c, #2f9e44);
    color: #fff;
}

.em-pol-badge.elliptical {
    background: linear-gradient(145deg, #da77f2, #ae3ec9);
    color: #fff;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .em-main-section {
        flex-direction: column;
    }
    
    .em-3d-container {
        min-width: auto;
        min-height: 400px;
    }
    
    .em-control-panel {
        width: 100%;
        max-height: none;
    }
    
    .em-bottom-section {
        flex-direction: column;
    }
    
    .em-equations-container {
        width: 100%;
    }
}

/* ===== 3D View Legend Overlay ===== */
.em-3d-legend {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(13, 17, 23, 0.9);
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 10px 14px;
    z-index: 10;
}

.em-3d-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 11px;
    color: #c9d1d9;
}

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

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

.em-3d-legend-line.e-field { background: #ff6b6b; }
.em-3d-legend-line.b-field { background: #74c0fc; }
.em-3d-legend-line.wave { background: #da77f2; }
.em-3d-legend-line.trace { background: #ffd43b; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #ffd43b; background: transparent; }

/* ===== Divider ===== */
.em-divider {
    height: 1px;
    background: #30363d;
    margin: 5px 0;
}

/* ===== Handedness Indicator ===== */
.em-handedness {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #21262d;
    border-radius: 6px;
    margin-top: 8px;
}

.em-handedness-icon {
    font-size: 18px;
}

.em-handedness-text {
    font-size: 11px;
    color: #c9d1d9;
}

.em-handedness-text.rhcp { color: #69db7c; }
.em-handedness-text.lhcp { color: #f06595; }
