/* Builder Page Styles */

.builder-main {
    padding: var(--space-xl) 0;
    min-height: calc(100vh - 160px);
}

.builder-layout {
    display: grid;
    gap: var(--space-xl);
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* Preview Panel */
.preview-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.preview-container {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    aspect-ratio: 16 / 10;
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    transition: background 0.3s ease;
}

.preview-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 30% 40%, rgba(255,255,255,0.03) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(255,255,255,0.02) 0%, transparent 40%);
    pointer-events: none;
}

/* Background Variants */
.preview-container.bg-default {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.preview-container.bg-headshot {
    background: url('../images/backgrounds/headshot.png');
    background-size: cover;
    background-position: center;
}

.preview-container.bg-ace {
    background: url('../images/backgrounds/ace.png');
    background-size: cover;
    background-position: center;
}

.preview-container.bg-clutch {
    background: url('../images/backgrounds/clutch.png');
    background-size: cover;
    background-position: center;
}

.preview-container.bg-buyphase {
    background: url('../images/backgrounds/buyphase.png');
    background-size: cover;
    background-position: center;
}

#builder-preview {
    max-width: 100%;
    height: auto;
    position: relative;
    z-index: 1;
}

.preview-resize {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
}

.resize-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
    transition: all var(--transition-fast);
}

.resize-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.resize-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Background Selector */
.background-selector {
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--border-color);
}

.background-selector .control-label {
    text-align: center;
    margin-bottom: var(--space-md);
    display: block;
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.bg-options {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.bg-btn {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    padding: 3px;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
}

.bg-btn:hover {
    border-color: var(--border-light);
    transform: scale(1.05);
}

.bg-btn.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(255, 70, 85, 0.3);
}

/* Custom Color Button */
.bg-color-btn {
    position: relative;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
    padding: 0;
}

.bg-color-btn input[type="color"] {
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    cursor: pointer;
    opacity: 0;
    position: absolute;
    inset: 0;
}

.bg-color-btn::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: var(--radius-sm);
    background: inherit;
    pointer-events: none;
}

.preview-container.bg-custom {
    background: var(--custom-bg-color, #1a1a2e);
}

.bg-preview {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-sm);
    background-size: cover;
    background-position: center;
}

.bg-preview.bg-default {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.bg-preview.bg-headshot {
    background: url('../images/backgrounds/headshot.png');
    background-size: cover;
    background-position: center;
}

.bg-preview.bg-ace {
    background: url('../images/backgrounds/ace.png');
    background-size: cover;
    background-position: center;
}

.bg-preview.bg-clutch {
    background: url('../images/backgrounds/clutch.png');
    background-size: cover;
    background-position: center;
}

.bg-preview.bg-buyphase {
    background: url('../images/backgrounds/buyphase.png');
    background-size: cover;
    background-position: center;
}

.preview-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.preview-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.preview-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.preview-btn svg {
    width: 16px;
    height: 16px;
}

/* Controls Panel */
.controls-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

/* Code Output */
.code-output {
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--border-color);
}

.code-box {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.code-box code {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--accent-secondary);
    word-break: break-all;
    overflow: hidden;
    line-height: 1.6;
}

/* Code Actions (Share & Download) */
.code-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.code-actions .action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.code-actions .action-btn svg {
    width: 16px;
    height: 16px;
}

.share-btn {
    background: var(--accent-tertiary);
    border: 1px solid var(--accent-tertiary);
    color: white;
}

.share-btn:hover {
    background: #4752c4;
    border-color: #4752c4;
}

.download-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.download-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

/* Import Section */
.import-section {
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--border-color);
}

.import-box {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.import-box input {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

.import-box input::placeholder {
    color: var(--text-muted);
}

.import-box input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.import-btn {
    padding: var(--space-md) var(--space-xl);
    background: var(--accent-tertiary);
    color: white;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    transition: background var(--transition-fast);
}

.import-btn:hover {
    background: #4752c4;
}

/* Settings Tabs */
.settings-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
    background: var(--bg-primary);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
}

.settings-tab {
    padding: var(--space-md);
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-align: center;
}

.settings-tab:hover {
    color: var(--text-primary);
}

.settings-tab.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Settings Content */
.settings-content {
    display: none;
}

.settings-content.active {
    display: block;
}

/* Settings Chapter */
.settings-chapter {
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--border-color);
}

.settings-chapter:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.chapter-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

/* Control Groups */
.control-group {
    margin-bottom: var(--space-lg);
}

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

.control-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

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

.control-row .control-label {
    margin-bottom: 0;
}

.control-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* Color Picker */
.color-picker {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.color-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    transition: all var(--transition-fast);
    position: relative;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-secondary);
}

.color-btn.custom-color {
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red) !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-btn.custom-color span {
    color: white;
    font-weight: bold;
    text-shadow: 0 0 2px black;
}

/* Custom Color Input */
.color-input-row {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.color-input-row input[type="color"] {
    width: 48px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
}

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

.color-input-row input[type="color"]::-webkit-color-swatch {
    border-radius: var(--radius-sm);
    border: none;
}

.color-input-row input[type="text"] {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    text-transform: uppercase;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border-radius: 24px;
    transition: var(--transition-fast);
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition-fast);
}

.toggle input:checked + .toggle-slider {
    background: var(--accent-primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: white;
}

/* Sliders */
.slider-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.slider-row:last-child {
    margin-bottom: 0;
}

.slider-row input[type="range"] {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.slider-row input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

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

.slider-value {
    min-width: 52px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* Scrollbar Styling */
.controls-panel::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 3px;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.controls-panel::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Responsive */
@media (min-width: 1024px) {
    .builder-layout {
        grid-template-columns: 1fr 440px;
        padding: 0 var(--space-xl);
        align-items: start;
    }

    .preview-panel {
        position: sticky;
        top: 100px;
        height: fit-content;
    }

    .preview-container {
        min-height: 360px;
    }

    .controls-panel {
        max-height: calc(100vh - 140px);
    }
}

@media (min-width: 1280px) {
    .builder-layout {
        grid-template-columns: 1fr 500px;
        gap: 48px;
    }

    .preview-container {
        min-height: 400px;
    }
}

@media (min-width: 1440px) {
    .builder-layout {
        grid-template-columns: 1fr 540px;
    }
}

/* CS2 Builder Specific Styles */
.style-selector {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.style-btn {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

.style-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.style-btn.active {
    background: var(--accent-tertiary);
    border-color: var(--accent-tertiary);
    color: white;
}

.rgb-inputs {
    display: flex;
    gap: var(--space-md);
}

.rgb-input {
    flex: 1;
}

.rgb-input label {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.rgb-input input {
    width: 100%;
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-sm);
    text-align: center;
}

.rgb-input input:focus {
    outline: none;
    border-color: var(--accent-primary);
}
