/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    color: #e0e0e0;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ===== Header ===== */
.simulator-header {
    background: rgba(20, 20, 40, 0.95);
    backdrop-filter: blur(10px);
    padding: 1.5rem 2rem;
    border-bottom: 2px solid rgba(100, 255, 218, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header-content h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.3rem;
}

.header-content .subtitle {
    font-size: 0.95rem;
    color: #a0a0b0;
    font-weight: 400;
}

.back-btn {
    padding: 0.7rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

/* ===== Main Container ===== */
.main-container {
    display: flex;
    height: calc(100vh - 100px);
    gap: 0;
}

/* ===== Control Sidebar ===== */
.control-sidebar {
    width: 350px;
    background: rgba(20, 20, 40, 0.9);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    overflow-y: auto;
    border-right: 2px solid rgba(100, 255, 218, 0.2);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
}

.control-sidebar::-webkit-scrollbar {
    width: 8px;
}

.control-sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.control-sidebar::-webkit-scrollbar-thumb {
    background: rgba(100, 255, 218, 0.3);
    border-radius: 10px;
}

.control-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 255, 218, 0.5);
}

.control-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #64ffda;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Spectrum Control ===== */
.spectrum-control {
    margin-top: 1rem;
}

.spectrum-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.label-realistic {
    color: #4ade80;
}

.label-stylized {
    color: #f472b6;
}

.style-slider {
    width: 100%;
    height: 12px;
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
    background:
        /* Segment dividers */
        repeating-linear-gradient(
            to right,
            transparent 0px,
            transparent calc(100% / 7 - 2px),
            rgba(20, 20, 40, 0.8) calc(100% / 7 - 2px),
            rgba(20, 20, 40, 0.8) calc(100% / 7),
            transparent calc(100% / 7)
        ),
        /* Color gradient */
        linear-gradient(to right, #4ade80 0%, #f472b6 100%);
    cursor: pointer;
    margin-bottom: 0.8rem;
    position: relative;
}

.style-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 32px;
    border-radius: 3px;
    background: white;
    cursor: grab;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    border: 2px solid #667eea;
}

.style-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
}

.style-slider::-moz-range-thumb {
    width: 12px;
    height: 32px;
    border-radius: 3px;
    background: white;
    cursor: grab;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    border: 2px solid #667eea;
}

.style-slider::-moz-range-thumb:active {
    cursor: grabbing;
}

.spectrum-value {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #64ffda;
}

/* ===== View Mode Buttons ===== */
.view-mode-buttons,
.material-buttons,
.geometry-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
}

.view-btn,
.material-btn,
.geometry-btn,
.toggle-btn,
.camera-btn {
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.view-btn:hover,
.material-btn:hover,
.geometry-btn:hover,
.toggle-btn:hover,
.camera-btn:hover {
    background: rgba(100, 255, 218, 0.2);
    border-color: #64ffda;
    transform: translateX(4px);
}

.view-btn.active,
.material-btn.active,
.geometry-btn.active,
.toggle-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

/* ===== Material Selection ===== */
#materialSelection {
    display: none;
}

#materialSelection.show {
    display: block;
}

/* ===== Lighting Controls ===== */
.lighting-controls {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.env-selector {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.env-selector label {
    font-size: 0.9rem;
    color: #a0a0b0;
    font-weight: 600;
}

.env-selector select {
    padding: 0.7rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.env-selector select:hover,
.env-selector select:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: #64ffda;
    outline: none;
}

/* ===== Camera Controls ===== */
.camera-controls {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* ===== Displacement Controls ===== */
.displacement-controls {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.control-group-inline {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.control-group-inline label {
    font-size: 0.9rem;
    color: #a0a0b0;
    font-weight: 600;
}

.control-group-inline input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 10px;
    outline: none;
    -webkit-appearance: none;
    background: rgba(100, 255, 218, 0.3);
    cursor: pointer;
}

.control-group-inline input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #64ffda;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.control-group-inline input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #64ffda;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    border: none;
}

.control-group-inline span {
    font-size: 0.9rem;
    color: #64ffda;
    font-weight: 600;
    text-align: right;
}

.control-group-inline select {
    padding: 0.7rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-group-inline select:hover,
.control-group-inline select:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: #64ffda;
    outline: none;
}

.displacement-info {
    background: rgba(100, 255, 218, 0.1);
    border: 1px solid rgba(100, 255, 218, 0.2);
    border-radius: 6px;
    padding: 0.6rem;
    margin-top: 0.4rem;
}

.displacement-info small {
    font-size: 0.75rem;
    color: #64ffda;
    line-height: 1.4;
}

/* ===== Texture Upload ===== */
.upload-info {
    background: rgba(100, 255, 218, 0.1);
    border: 1px solid rgba(100, 255, 218, 0.3);
    border-radius: 8px;
    padding: 0.8rem;
    margin-bottom: 1rem;
}

.upload-info p {
    font-size: 0.85rem;
    color: #64ffda;
    line-height: 1.5;
}

.material-upload-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.upload-tab {
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #a0a0b0;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #64ffda;
}

.upload-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.upload-panels {
    position: relative;
}

.upload-panel {
    display: none;
}

.upload-panel.active {
    display: block;
}

.upload-panel h3 {
    font-size: 1rem;
    color: #64ffda;
    margin-bottom: 1rem;
}

.texture-upload-group {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.texture-upload-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #a0a0b0;
    margin-bottom: 0.8rem;
}

.upload-item {
    margin-bottom: 0.8rem;
}

.upload-item:last-child {
    margin-bottom: 0;
}

.texture-input {
    width: 100%;
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.texture-input:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #64ffda;
}

.upload-item small {
    display: block;
    font-size: 0.75rem;
    color: #64ffda;
    margin-top: 0.3rem;
    font-weight: 600;
}

/* ===== Expert Evaluation ===== */
.evaluation-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.evaluation-info {
    background: rgba(100, 255, 218, 0.1);
    border: 1px solid rgba(100, 255, 218, 0.3);
    border-radius: 8px;
    padding: 0.8rem;
}

.evaluation-info p {
    font-size: 0.85rem;
    color: #64ffda;
    line-height: 1.5;
    margin: 0;
}

.likert-scale-selector {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.likert-scale-selector label {
    font-size: 0.9rem;
    color: #a0a0b0;
    font-weight: 600;
}

.scale-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.scale-btn {
    padding: 0.7rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.scale-btn:hover {
    background: rgba(100, 255, 218, 0.2);
    border-color: #64ffda;
}

.scale-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.likert-scale-container {
    position: relative;
}

.likert-scale {
    display: none;
    flex-direction: column;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem 1rem;
}

.likert-scale.active {
    display: flex;
}

.likert-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.likert-label-left,
.likert-label-right {
    font-size: 0.85rem;
    font-weight: 600;
}

.likert-label-left {
    color: #4ade80;
}

.likert-label-right {
    color: #f472b6;
}

.likert-points {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.likert-points::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to right, #4ade80 0%, #f472b6 100%);
    transform: translateY(-50%);
    z-index: 0;
}

.likert-point {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    z-index: 1;
}

.likert-point input[type="radio"] {
    display: none;
}

.likert-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: #a0a0b0;
    transition: all 0.3s ease;
}

.likert-point:hover .likert-circle {
    background: rgba(100, 255, 218, 0.2);
    border-color: #64ffda;
    color: #64ffda;
    transform: scale(1.1);
}

.likert-point input[type="radio"]:checked + .likert-circle {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.evaluation-actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.eval-btn {
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.eval-btn:hover {
    background: rgba(100, 255, 218, 0.2);
    border-color: #64ffda;
    transform: translateX(4px);
}

.eval-btn#recordEvaluation {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.eval-btn#recordEvaluation:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.evaluation-summary {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.evaluation-summary h4 {
    font-size: 0.9rem;
    color: #64ffda;
    margin-bottom: 0.8rem;
}

.evaluation-summary::-webkit-scrollbar {
    width: 6px;
}

.evaluation-summary::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.evaluation-summary::-webkit-scrollbar-thumb {
    background: rgba(100, 255, 218, 0.3);
    border-radius: 10px;
}

#evalList {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.eval-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 0.6rem;
    font-size: 0.8rem;
    color: #c0c0d0;
}

.eval-item strong {
    color: #64ffda;
}

/* ===== Research Info ===== */
.research-info {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.research-info p {
    font-size: 0.85rem;
    line-height: 1.6;
    color: #c0c0d0;
    margin-bottom: 0.5rem;
}

.research-info p:last-child {
    margin-bottom: 0;
}

.research-info strong {
    color: #64ffda;
    font-weight: 600;
}

/* ===== Viewport Container ===== */
.viewport-container {
    flex: 1;
    background: rgba(10, 10, 30, 0.5);
    position: relative;
    overflow: hidden;
}

/* ===== Viewport Grid ===== */
.viewport-grid {
    display: none;
    width: 100%;
    height: 100%;
}

.viewport-grid.active {
    display: grid;
}

/* Quad View */
.quad-view {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
}

/* Single View */
.single-view {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

/* Compare View */
.compare-view {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
    gap: 2px;
}

/* ===== Viewport Item ===== */
.viewport-item,
.viewport-item-large {
    position: relative;
    background: rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.viewport-canvas {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

.viewport-canvas canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ===== Viewport Label ===== */
.viewport-label {
    background: rgba(20, 20, 40, 0.95);
    backdrop-filter: blur(10px);
    padding: 0.8rem 1rem;
    border-top: 1px solid rgba(100, 255, 218, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.viewport-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.material-icon {
    font-size: 1.3rem;
}

.material-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e0e0e0;
    flex: 1;
}

.viewport-slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.viewport-slider-container .spectrum-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
}

.viewport-slider-container .style-slider {
    height: 10px;
    margin-bottom: 0;
}

/* ===== Style Indicator ===== */
.style-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.realistic-badge,
.stylized-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.realistic-badge {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.4);
}

.stylized-badge {
    background: rgba(244, 114, 182, 0.2);
    color: #f472b6;
    border: 1px solid rgba(244, 114, 182, 0.4);
}

.blend-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.blend-fill {
    height: 100%;
    background: linear-gradient(to right, #4ade80 0%, #f472b6 100%);
    transition: width 0.3s ease;
}

/* ===== Responsive Design ===== */
@media (max-width: 1200px) {
    .control-sidebar {
        width: 300px;
    }
}

@media (max-width: 968px) {
    .main-container {
        flex-direction: column;
        height: auto;
    }

    .control-sidebar {
        width: 100%;
        max-height: 400px;
    }

    .viewport-container {
        min-height: 600px;
    }

    .quad-view {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
    }

    .compare-view {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .simulator-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .header-content h1 {
        font-size: 1.3rem;
    }

    .header-content .subtitle {
        font-size: 0.8rem;
    }

    .material-upload-tabs {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== Loading Animation ===== */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s ease-in-out infinite;
}
