* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90e2;
    --secondary-color: #50c878;
    --danger-color: #e74c3c;
    --bg-dark: #0a0e27;
    --bg-panel: #1a1f3a;
    --bg-hover: #252b4a;
    --text-light: #e0e0e0;
    --text-muted: #8892b0;
    --border-color: #2d3454;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1f3a 100%);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== HEADER ==================== */
.header {
    background: linear-gradient(90deg, #1a1f3a 0%, #252b4a 100%);
    padding: 1rem 2rem;
    text-align: center;
    border-bottom: 2px solid var(--primary-color);
    box-shadow: var(--shadow);
}

.header h1 {
    font-size: 1.5rem;
    margin-bottom: 0;
    background: linear-gradient(90deg, #4a90e2, #50c878);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 1rem;
    padding: 1rem;
    flex: 1;
    height: calc(100vh - 100px);
    overflow: hidden;
}

/* ==================== SIDEBARS ==================== */
.sidebar {
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 1.5rem;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.panel {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.panel h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.panel h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--secondary-color);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.panel-header h2 {
    margin-bottom: 0;
}

/* ==================== FORM ELEMENTS ==================== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-light);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-group input[type="text"]:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-group input[type="color"] {
    width: 100%;
    height: 45px;
    padding: 0.25rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #357abd);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(74, 144, 226, 0.4);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-light);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #c0392b);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(231, 76, 60, 0.4);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-preset {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
    margin-bottom: 0.5rem;
    text-align: left;
}

.btn-preset:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 8px rgba(155, 89, 182, 0.4);
}

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 1.5rem 0;
}

/* ==================== CONTROL HINTS ==================== */
.control-hints {
    margin-top: 0;
}

.control-hints h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--secondary-color);
}

.hint-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.hint-item kbd {
    display: inline-block;
    min-width: 35px;
    padding: 0.25rem 0.5rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--primary-color);
    text-align: center;
    font-weight: 600;
}

.hint-item span {
    flex: 1;
}

/* ==================== VIEWER CONTAINER ==================== */
.viewer-container {
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    position: relative;
}

#canvas-container {
    flex: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #00001a;
    position: relative;
}

.viewer-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.viewer-controls .btn {
    width: auto;
    padding: 0.6rem 1.2rem;
}

.stats-panel {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(26, 31, 58, 0.9);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    min-width: 180px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.stat-value {
    color: var(--secondary-color);
    font-weight: 600;
    font-size: 0.9rem;
}

/* ==================== MODULES LIST ==================== */
.modules-list {
    flex: 1;
    overflow-y: auto;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 1rem;
    font-style: italic;
}

.module-item {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.module-item:hover {
    border-color: var(--primary-color);
    transform: translateX(-5px);
}

.module-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
}

.module-color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    margin-right: 0.75rem;
    border: 2px solid var(--border-color);
}

.module-title {
    flex: 1;
    font-weight: 600;
    font-size: 1rem;
}

.module-type-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.module-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.module-actions {
    display: flex;
    gap: 0.5rem;
}

.module-actions .btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* ==================== MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-panel);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    color: var(--primary-color);
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.modal-footer .btn {
    flex: 1;
}

/* ==================== TABS ==================== */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--text-light);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ==================== POSITION CONTROLS ==================== */
.position-control {
    margin-bottom: 1.5rem;
}

.position-control label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.slider-btn {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    width: 35px;
    height: 35px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.slider-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    background: var(--bg-dark);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.slider-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 8px var(--primary-color);
}

.value-display {
    min-width: 50px;
    text-align: center;
    color: var(--secondary-color);
    font-weight: 600;
}

/* ==================== DIMENSION CONTROLS ==================== */
#dimensionControls .form-group {
    margin-bottom: 1.5rem;
}

#dimensionControls input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--bg-dark);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    margin-top: 0.5rem;
}

#dimensionControls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--secondary-color);
    border-radius: 50%;
    cursor: pointer;
}

.dimension-value {
    display: inline-block;
    margin-left: 0.5rem;
    color: var(--secondary-color);
    font-weight: 600;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 280px 1fr 320px;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: auto;
    }
    
    .sidebar {
        max-height: 400px;
    }
    
    .viewer-container {
        min-height: 500px;
    }
}

/* ==================== SELECTED MODULE INFO ==================== */
.selected-module-info {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 31, 58, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 1.5rem;
    min-width: 350px;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 900;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.info-header strong {
    font-size: 1.1rem;
    color: var(--text-light);
}

.info-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.info-content {
    color: var(--text-light);
    font-size: 0.9rem;
}

.info-content p {
    margin-bottom: 0.75rem;
}

.info-content ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.info-content li {
    padding: 0.35rem 0;
    color: var(--text-muted);
}

.info-content kbd {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--primary-color);
    margin-right: 0.5rem;
}
