/* ============================================
   DC THEME BUILDER — UI Styles
   (Independent of the theme being edited)
   ============================================ */

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    color: #1f2937;
    background: #0f172a;
}

/* ============================================
   LAYOUT SHELL
   ============================================ */

.theme-builder {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   HEADER
   ============================================ */

.builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.builder-header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.02em;
}

.header-subtitle {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 400;
}

.header-controls {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.toggle-label {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.5rem;
}

/* Mode toggle buttons */
.mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.mode-btn {
    padding: 0.4rem 0.85rem;
    border: 1px solid #475569;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8rem;
    transition: all 0.15s;
}

.mode-btn:first-of-type { border-radius: 6px 0 0 6px; }
.mode-btn:last-of-type  { border-radius: 0 6px 6px 0; }

.mode-btn:hover {
    background: #334155;
    color: #e2e8f0;
}

.mode-btn.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

/* Preview toggle switch */
.preview-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#previewModeLabel {
    font-size: 0.8rem;
    color: #cbd5e1;
    font-weight: 500;
    min-width: 32px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #475569;
    transition: 0.2s;
    border-radius: 22px;
}

.slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: 0.2s;
    border-radius: 50%;
}

input:checked + .slider { background-color: #6366f1; }
input:checked + .slider::before { transform: translateX(18px); }

/* ============================================
   MAIN CONTENT
   ============================================ */

.builder-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ============================================
   SIDEBAR (Editor Panel)
   ============================================ */

.builder-sidebar {
    width: 520px;
    min-width: 320px;
    background: #1e293b;
    border-right: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Resize handle */
.resize-handle {
    width: 5px;
    cursor: col-resize;
    background: #334155;
    flex-shrink: 0;
    transition: background 0.15s;
    position: relative;
}

.resize-handle::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -3px;
    right: -3px;
}

.resize-handle:hover,
.resize-handle.dragging {
    background: #3b82f6;
}

/* Preset selector */
.preset-selector {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #334155;
}

.preset-selector label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: #94a3b8;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.preset-selector select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #475569;
    border-radius: 6px;
    font-size: 13px;
    background: #0f172a;
    color: #e2e8f0;
    cursor: pointer;
}

.preset-selector select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.preset-selector select optgroup {
    color: #94a3b8;
    font-weight: 600;
    font-style: normal;
}

.preset-selector select option {
    color: #e2e8f0;
    font-weight: 400;
}

/* Category tabs */
.category-tabs {
    display: flex;
    border-bottom: 1px solid #334155;
    overflow-x: auto;
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 0.6rem 0.5rem;
    border: none;
    background: transparent;
    color: #64748b;
    text-align: center;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: all 0.15s;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.tab-btn:hover {
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

/* Variable editors container */
.variable-editors {
    flex: 1;
    padding: 1rem 1.25rem;
    overflow-y: auto;
}

.variable-editors::-webkit-scrollbar { width: 6px; }
.variable-editors::-webkit-scrollbar-track { background: transparent; }
.variable-editors::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.variable-editors::-webkit-scrollbar-thumb:hover { background: #475569; }

.loading-msg {
    color: #64748b;
    text-align: center;
    padding: 2rem;
}

.editor-section-title {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    font-weight: 700;
    color: #f1f5f9;
}

.editor-section-subtitle {
    font-size: 0.75rem;
    color: #64748b;
    margin: 0 0 1rem 0;
}

.mode-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mode-badge.light {
    background: #fef3c7;
    color: #92400e;
}

.mode-badge.dark {
    background: #312e81;
    color: #c7d2fe;
}

/* Variable list */
.variable-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.variable-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.1s;
}

.variable-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.variable-item label {
    flex: 1;
    font-weight: 500;
    color: #cbd5e1;
    font-size: 0.82rem;
    cursor: default;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.color-input-group {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-shrink: 0;
}

.color-picker {
    width: 36px;
    height: 30px;
    border: 1px solid #475569;
    border-radius: 4px;
    cursor: pointer;
    padding: 1px;
    background: #0f172a;
}

.color-picker::-webkit-color-swatch-wrapper { padding: 1px; }
.color-picker::-webkit-color-swatch { border: none; border-radius: 2px; }

.color-text {
    width: 90px;
    padding: 0.35rem 0.5rem;
    border: 1px solid #475569;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.78rem;
    background: #0f172a;
    color: #e2e8f0;
    text-align: center;
}

.color-text:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* Typography editor */
.typography-editor {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

.font-selector-group label {
    font-weight: 600;
    color: #94a3b8;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.font-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #475569;
    border-radius: 6px;
    font-size: 13px;
    background: #0f172a;
    color: #e2e8f0;
    cursor: pointer;
}

.font-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.font-preview-box {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 1.25rem;
}

.font-preview-heading {
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #f1f5f9;
    line-height: 1.4;
}

.font-preview-body {
    margin: 0 0 1rem 0;
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.6;
    word-break: break-all;
}

.font-weight-samples {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.font-weight-samples span {
    font-size: 0.8rem;
    color: #cbd5e1;
    padding: 0.3rem 0.6rem;
    background: #1e293b;
    border-radius: 4px;
}

/* Action buttons */
.action-buttons {
    padding: 1rem 1.25rem;
    border-top: 1px solid #334155;
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.btn {
    flex: 1;
    padding: 0.65rem 1rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: #3b82f6;
    color: #ffffff;
}

.btn-primary:hover { background: #2563eb; }

.btn-secondary {
    background: #334155;
    color: #cbd5e1;
}

.btn-secondary:hover { background: #475569; }

/* ============================================
   PREVIEW PANEL
   ============================================ */

.builder-preview {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    transition: background-color 0.3s, color 0.3s;
}

.builder-preview::-webkit-scrollbar { width: 8px; }
.builder-preview::-webkit-scrollbar-track { background: transparent; }
.builder-preview::-webkit-scrollbar-thumb { background: rgba(128, 128, 128, 0.3); border-radius: 4px; }

.preview-content {
    max-width: 960px;
    margin: 0 auto;
}

/* Preview header */
.preview-title {
    margin: 0 0 0.25rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--kt-headings-color, #181C32);
}

.preview-subtitle {
    margin: 0 0 2rem 0;
    font-size: 0.9rem;
    color: var(--kt-text-muted, #A1A5B7);
}

/* Sample card */
.sample-card {
    background: var(--kt-card-bg, #ffffff);
    border: 1px solid var(--kt-card-border-color, var(--kt-border-color, #eff2f5));
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.sample-card .card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--kt-border-color, #eff2f5);
}

.sample-card .card-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--kt-headings-color, #181C32);
}

.sample-card .card-body {
    padding: 1.5rem;
    color: var(--kt-body-color, #181C32);
}

.sample-card .card-body p {
    margin: 0 0 1rem 0;
    line-height: 1.6;
    color: var(--kt-text-muted, #A1A5B7);
}

/* Preview buttons */
.button-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.preview-btn {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 0.4rem;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: default;
    color: #ffffff;
}

.preview-btn.primary   { background: var(--kt-primary, #009ef7); }
.preview-btn.success   { background: var(--kt-success, #50cd89); }
.preview-btn.info      { background: var(--kt-info, #7239ea); }
.preview-btn.warning   { background: var(--kt-warning, #ffc700); color: #000; }
.preview-btn.danger    { background: var(--kt-danger, #f1416c); }
.preview-btn.secondary {
    background: var(--kt-secondary, #E4E6EF);
    color: var(--kt-body-color, #181C32);
}

/* Preview form */
.preview-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--kt-headings-color, #181C32);
}

.preview-input {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--kt-input-border-color, #E4E6EF);
    border-radius: 0.4rem;
    background: var(--kt-input-bg, #ffffff);
    color: var(--kt-input-color, #5E6278);
    font-size: 0.9rem;
    font-family: inherit;
}

.preview-input::placeholder {
    color: var(--kt-input-placeholder-color, #A1A5B7);
}

.preview-select {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--kt-input-border-color, #E4E6EF);
    border-radius: 0.4rem;
    background: var(--kt-input-bg, #ffffff);
    color: var(--kt-input-color, #5E6278);
    font-size: 0.9rem;
    font-family: inherit;
}

/* Preview table */
.preview-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--kt-table-color, var(--kt-body-color, #181C32));
}

.preview-table th,
.preview-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--kt-table-border-color, var(--kt-border-color, #eff2f5));
}

.preview-table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--kt-text-muted, #A1A5B7);
}

.preview-table tbody tr:hover {
    background: var(--kt-table-hover-bg, var(--kt-gray-100, #f5f8fa));
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #ffffff;
}

.badge.success { background: var(--kt-success, #50cd89); }
.badge.warning { background: var(--kt-warning, #ffc700); color: #000; }
.badge.danger  { background: var(--kt-danger, #f1416c); }
.badge.info    { background: var(--kt-info, #7239ea); }

/* Color swatches */
.swatch-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.swatch {
    flex: 1;
    padding: 1.25rem 0.5rem;
    text-align: center;
    border-radius: 0.4rem;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #ffffff;
}

.swatch.primary   { background: var(--kt-primary, #009ef7); }
.swatch.success   { background: var(--kt-success, #50cd89); }
.swatch.info      { background: var(--kt-info, #7239ea); }
.swatch.warning   { background: var(--kt-warning, #ffc700); color: #000; }
.swatch.danger    { background: var(--kt-danger, #f1416c); }

.swatch.gray {
    color: var(--kt-body-color, #181C32);
    font-size: 0.65rem;
}

.swatch.gray.dark-text { color: #ffffff; }

/* Preview layout mockup */
.layout-mockup {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--kt-border-color, #eff2f5);
    border-radius: 0.5rem;
    overflow: hidden;
    font-size: 0.8rem;
}

.mockup-header {
    padding: 0.75rem 1rem;
    background: var(--kt-app-header-base-bg-color, #ffffff);
    color: var(--kt-headings-color, #181C32);
    font-weight: 600;
    border-bottom: 1px solid var(--kt-border-color, #eff2f5);
}

.mockup-body {
    display: flex;
    min-height: 120px;
}

.mockup-sidebar {
    width: 80px;
    background: var(--kt-app-sidebar-light-bg-color, var(--kt-card-bg, #ffffff));
    border-right: 1px solid var(--kt-border-color, #eff2f5);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.mockup-sidebar-item {
    height: 8px;
    border-radius: 4px;
    background: var(--kt-gray-200, #eff2f5);
}

.mockup-sidebar-item.active {
    background: var(--kt-primary, #009ef7);
}

.mockup-main {
    flex: 1;
    background: var(--kt-app-bg-color, #f5f8fa);
    padding: 0.75rem;
}

.mockup-toolbar {
    padding: 0.5rem 0.75rem;
    background: var(--kt-app-toolbar-base-bg-color, #ffffff);
    border-radius: 0.3rem;
    margin-bottom: 0.5rem;
    height: 20px;
}

.mockup-card {
    background: var(--kt-card-bg, #ffffff);
    border-radius: 0.3rem;
    padding: 0.75rem;
    height: 60px;
}

.mockup-footer {
    padding: 0.5rem 1rem;
    background: var(--kt-app-footer-bg-color, #f5f8fa);
    color: var(--kt-text-muted, #A1A5B7);
    font-size: 0.7rem;
    border-top: 1px solid var(--kt-border-color, #eff2f5);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .builder-sidebar { width: 380px; }
}

@media (max-width: 768px) {
    .builder-header {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
    }
    .header-controls {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    .builder-content { flex-direction: column; }
    .builder-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 50vh;
    }
}
