/* Prusawire Configurator Styles */

:root {
    /* Backgrounds - from dwtas.net */
    --bg-primary: #0a0c10;
    --bg-secondary: #0f1318;
    --bg-panel: #1c2128;
    --bg-tertiary: #161b22;
    
    /* Accent colors - Positron orange */
    --accent: #DE9400;
    --accent-hover: #F5A623;
    --accent-light: #FFC15E;
    
    /* Text */
    --text-primary: #f0f3f6;
    --text-secondary: #9aa5b1;
    --text-muted: #6b7785;
    
    /* Borders */
    --border-color: #2d333b;
    --border-light: #444c56;
    
    /* Status colors */
    --success: #3fb950;
    --warning: #d29922;
    --error: #ef4444;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #3d5a80 0%, #4a6fa5 50%, #6989b9 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
}

.logo .subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.header-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-links .cadscope-link {
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
}

.header-links .cadscope-link:hover {
    border-color: var(--accent-hover);
    color: var(--text-primary);
}

.header-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.header-links a:hover {
    color: var(--accent);
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Config Panel */
.config-panel {
    width: 640px;
    min-width: 280px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.config-panel-content {
    flex: 1;
    overflow-y: scroll;
    padding: 1rem;
    /* Force scrollbar visibility on mobile */
    -webkit-overflow-scrolling: touch;
}

/* Option widgets flow in two columns inside the wider panel, divided by
   a thin rule down the middle of the gap. */
#option-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.25rem;
    align-items: start;
    position: relative;
}

#option-sections::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: var(--border-color);
}

/* Custom scrollbar for webkit browsers (Chrome, Safari, Edge) */
.config-panel-content::-webkit-scrollbar {
    width: 8px;
}

.config-panel-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.config-panel-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.config-panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.scroll-indicator {
    display: none;
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    z-index: 1;
    padding: 8px 16px;
    animation: bounce 1.5s ease-in-out infinite;
    transition: color 0.2s;
}

.scroll-indicator:hover {
    color: var(--accent);
}

.scroll-indicator:active {
    animation: none;
    transform: translateX(-50%) scale(0.95);
}

.scroll-indicator svg {
    display: block;
    margin: 0 auto 2px;
}

@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(3px); }
}

.config-panel h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.config-section {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
    margin-bottom: 1.25rem;
}

.config-section h3 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Color Picker Section */
.color-section {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.color-pickers {
    display: flex;
    gap: 1rem;
}

.color-picker-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.color-picker-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.color-picker-group input[type="color"] {
    width: 100%;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-secondary);
    cursor: pointer;
    padding: 2px;
}

.color-picker-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker-group input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.section-note {
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    margin: 0 0 0.75rem 0;
    line-height: 1.4;
    font-style: italic;
}

.section-note a {
    color: var(--accent-color, #4a9eff);
    text-decoration: none;
}

.section-note a:hover {
    text-decoration: underline;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Dropdown selects for configuration options */
.config-section select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    appearance: auto;
}

.config-section select:focus {
    outline: none;
    border-color: var(--accent);
}

.config-section select option:disabled {
    color: var(--text-muted);
}

/* Nested sub-options (e.g., WW-BMG sensor options) */
.sub-options {
    margin-left: 1.5rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--border-color);
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

.sub-options select {
    margin-top: 0.25rem;
}

.sub-options-label {
    display: block;
    font-size: 0.8em;
    color: var(--accent);
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sub-options-label:first-child {
    margin-top: 0;
}

.option {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.option input[type="radio"],
.option input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    margin-right: 0.75rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.option input[type="checkbox"] {
    border-radius: 4px;
}

.option input[type="radio"]:checked,
.option input[type="checkbox"]:checked {
    border-color: var(--accent);
    background: var(--accent);
}

.option input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.option input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 10px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.option-label {
    font-size: 0.875rem;
}

.option.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Warnings */
.warnings {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid var(--warning);
    border-radius: 6px;
    padding: 0.75rem;
    display: none;
}

.warnings.visible {
    display: block;
}

.warnings h3 {
    color: var(--warning);
}

.warning-item {
    font-size: 0.8rem;
    color: var(--warning);
    margin-top: 0.5rem;
}



/* Download Button */
.download-section {
    margin: 0 0.5rem 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.download-section button {
    flex: 1 1 30%;
    min-width: 150px;
}

.btn-download {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-download:hover {
    background: var(--accent-hover);
}

.btn-copy-url {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn-copy-url:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.btn-reset {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn-reset:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

/* 3D Viewer */
.viewer-container {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
}

#viewer-3d {
    width: 100%;
    height: 100%;
}

#viewer-3d canvas {
    display: block;
}

/* Viewer Controls */
.viewer-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(3, 60px);
    gap: 5px;
    background: var(--bg-panel);
    padding: 0.25rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.viewer-btn {
    height: 45px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s;
}

.viewer-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.viewer-btn:active,
.viewer-btn.active {
    background: var(--accent);
    color: white;
}

.viewer-btn-blank {
    visibility: hidden;
    pointer-events: none;
}

.viewer-btn-separator {
    width: 100%;
    height: 1px;
    background: var(--border-color);
    margin: 2px 0;
    grid-column: span 3;
}

.slider-label {
    grid-column: span 3;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: center;
    margin-top: 2px;
}

.viewer-controls input[type="range"] {
    width: 100%;
    height: 6px;
    appearance: none;
    -webkit-appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    grid-column: span 3;
    margin-bottom: 4px;
}

.viewer-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.viewer-controls input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
}

.viewer-controls input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

/* Loading Indicator (centered version) */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(26, 26, 46, 0.9);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    z-index: 100;
    transition: opacity 0.3s;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.loading-indicator.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner-small {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Dev Panel */
.dev-panel {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    font-size: 0.75rem;
    max-width: 300px;
}

.dev-panel h4 {
    margin-bottom: 0.75rem;
    color: var(--accent);
}

.dev-controls label {
    display: block;
    margin-bottom: 0.5rem;
}

.dev-controls select {
    width: 100%;
    padding: 0.4rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    margin-top: 0.25rem;
}

.transform-inputs {
    margin-top: 0.75rem;
}

.transform-inputs > div {
    margin-bottom: 0.5rem;
}

.transform-inputs label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.transform-inputs input {
    width: 60px;
    padding: 0.3rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    margin-right: 0.25rem;
}

#dev-copy-transform {
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

/* Attribution */
.attribution {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(10, 12, 16, 0.8);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.attribution a {
    color: var(--accent);
    text-decoration: none;
}

.attribution a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .config-panel {
        width: 100%;
        max-height: 45vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    #option-sections {
        grid-template-columns: 1fr;
    }

    #option-sections::before {
        display: none;
    }
    
    .scroll-indicator {
        display: block;
    }
    
    .config-panel:not(.has-more-content) .scroll-indicator {
        display: none;
    }
    
    .viewer-container {
        min-height: 55vh;
    }
}

.loading-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.loading-line.hidden {
    display: none;
}

.loading-progress {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.15s ease-out;
}

.viewer-notice {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 30;
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    max-width: 320px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.viewer-notice.hidden {
    display: none;
}

.preview-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.preview-toggle input {
    accent-color: var(--accent);
}
