/* ═══════════════════════════════════════════════════════
   Builder Layout — Three-Panel Shell
   ═══════════════════════════════════════════════════════ */

.builder-layout {
    display: flex;
    height: calc(100vh - 56px); /* minus top bar */
    overflow: hidden;
    background: #f3f4f6;
}

/* ── Left Sidebar (Palette) ── */
.builder-sidebar-left {
    width: 260px;
    min-width: 260px;
    background: #1a1d23;
    color: #adb5bd;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2a2d35;
    overflow: hidden;
}

/* ── Right Sidebar (Properties) ── */
.builder-sidebar-right {
    width: 300px;
    min-width: 300px;
    background: #ffffff;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* ── Center (Toolbar + Canvas) ── */
.builder-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.builder-page-info {
    padding: 8px 16px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 12px;
}

.builder-title-input {
    font-size: 1.25rem;
    font-weight: 600;
    border: none;
    background: transparent;
    outline: none;
    flex: 1;
    max-width: 400px;
}

.builder-title-input:focus {
    border-bottom: 2px solid #3b82f6;
}

.builder-canvas-wrapper {
    flex: 1;
    overflow: auto;
    padding: 24px;
    background: #e5e7eb;
}

/* ═══════════════════════════════════════════════════════
   Builder Toolbar
   ═══════════════════════════════════════════════════════ */

.builder-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: #e5e7eb;
    margin: 0 6px;
}

.toolbar-status {
    font-size: 0.75rem;
    font-weight: 500;
    margin-right: 8px;
}

/* ═══════════════════════════════════════════════════════
   Builder Canvas
   ═══════════════════════════════════════════════════════ */

.builder-canvas {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-height: 600px;
    padding: 16px;
    transition: all 0.3s ease;
}

.builder-canvas.viewport-tablet {
    max-width: 768px;
    margin: 0 auto;
}

.builder-canvas.viewport-mobile {
    max-width: 375px;
    margin: 0 auto;
}

.builder-canvas.preview-mode {
    box-shadow: none;
    border: 1px solid #e5e7eb;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #9ca3af;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
}

/* ── Builder Nodes ── */
.builder-node {
    position: relative;
    padding: 4px;
    margin: 2px 0;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: all 0.15s ease;
    cursor: pointer;
}

.builder-node:hover {
    border-color: #93c5fd;
    background: rgba(59, 130, 246, 0.03);
}

.builder-node.selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.06);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.builder-node.drop-target {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.06);
}

.builder-node.depth-0 { padding-left: 4px; }
.builder-node.depth-1 { padding-left: 20px; }
.builder-node.depth-2 { padding-left: 40px; }
.builder-node.depth-3 { padding-left: 60px; }
.builder-node.depth-4 { padding-left: 80px; }
.builder-node.depth-5 { padding-left: 100px; }

/* ═══════════════════════════════════════════════════════
   Component Palette
   ═══════════════════════════════════════════════════════ */

.component-palette {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.palette-header {
    padding: 12px;
    border-bottom: 1px solid #2a2d35;
    flex-shrink: 0;
}

.palette-title {
    color: #ffffff;
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.palette-search {
    background: #2a2d35 !important;
    border-color: #3a3d45 !important;
    color: #e5e7eb !important;
}

.palette-search::placeholder {
    color: #6b7280;
}

.palette-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.palette-category {
    margin-bottom: 4px;
}

.palette-category-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 4px;
}

.palette-category-title:hover {
    background: #2a2d35;
    color: #e5e7eb;
}

.palette-category-title .fa-chevron-down {
    transition: transform 0.2s ease;
    font-size: 0.625rem;
}

.palette-category-title .fa-chevron-down.expanded {
    transform: rotate(180deg);
}

.palette-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
}

.palette-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    background: #2a2d35;
    border: 1px solid #3a3d45;
    border-radius: 6px;
    cursor: grab;
    transition: all 0.15s ease;
    text-align: center;
    color: #d1d5db;
    font-size: 0.6875rem;
}

.palette-item:hover {
    background: #3a3d45;
    border-color: #3b82f6;
    color: #ffffff;
}

.palette-item:active {
    cursor: grabbing;
}

.palette-item i {
    font-size: 1rem;
    color: #6b7280;
}

.palette-item:hover i {
    color: #3b82f6;
}

/* ═══════════════════════════════════════════════════════
   Property Panel
   ═══════════════════════════════════════════════════════ */

.property-panel {
    padding: 16px;
    flex: 1;
}

.property-panel.empty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.property-empty {
    text-align: center;
    color: #9ca3af;
}

.property-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.property-title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.property-section {
    margin-bottom: 16px;
}

.property-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin-bottom: 8px;
}

.property-field {
    margin-bottom: 8px;
}

.property-label {
    font-size: 0.8125rem;
    color: #374151;
    margin-bottom: 4px;
    display: block;
}

.property-actions {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

/* ═══════════════════════════════════════════════════════
   Theme Manager
   ═══════════════════════════════════════════════════════ */

.theme-manager {
    padding: 16px;
}

.theme-section {
    max-height: 400px;
    overflow-y: auto;
}

.theme-field {
    margin-bottom: 8px;
}

.theme-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    color: #374151;
    margin-bottom: 2px;
    display: block;
}

.theme-input-group {
    display: flex;
    gap: 8px;
}

.theme-color-picker {
    width: 40px;
    height: 32px;
    padding: 2px;
    cursor: pointer;
}

/* ═══════════════════════════════════════════════════════
   Variable Manager
   ═══════════════════════════════════════════════════════ */

.variable-manager {
    padding: 16px;
}

.variable-list {
    max-height: 400px;
    overflow-y: auto;
}

.variable-item {
    padding: 8px;
    margin-bottom: 6px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.variable-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.variable-name {
    color: #3b82f6;
}

.variable-value {
    margin-bottom: 2px;
}

.variable-source {
    font-size: 0.6875rem;
}

/* ═══════════════════════════════════════════════════════
   Template Grid (Pages Library)
   ═══════════════════════════════════════════════════════ */

.pages-library {
    padding: 16px;
}

.template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
}

.template-card {
    padding: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.template-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.template-icon {
    color: #6b7280;
    margin-bottom: 8px;
}

.template-info strong {
    font-size: 0.8125rem;
}

/* ═══════════════════════════════════════════════════════
   Product Listing / Cart / Checkout
   ═══════════════════════════════════════════════════════ */

.product-listing {
    padding: 16px;
}

.product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
}

.product-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s ease;
}

.product-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.product-image {
    height: 120px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.product-info {
    padding: 8px;
}

.product-name {
    font-size: 0.8125rem;
    margin-bottom: 2px;
}

.product-description {
    font-size: 0.6875rem;
    margin-bottom: 4px;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-price {
    font-weight: 700;
    color: #059669;
    font-size: 0.9375rem;
}

/* ── Cart ── */
.cart-view {
    padding: 16px;
}

.cart-items {
    max-height: 400px;
    overflow-y: auto;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.cart-item-controls {
    display: flex;
    align-items: center;
}

.cart-item-total {
    min-width: 70px;
    text-align: right;
}

.cart-summary {
    font-size: 0.875rem;
}

/* ── Checkout ── */
.checkout-form {
    padding: 16px;
}

/* ═══════════════════════════════════════════════════════
   Code Editor
   ═══════════════════════════════════════════════════════ */

.code-editor {
    padding: 16px;
}

.code-editor-textarea {
    width: 100%;
    font-size: 0.8125rem;
    line-height: 1.5;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #1a1d23;
    color: #e5e7eb;
    resize: vertical;
    tab-size: 2;
}

.code-editor-textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

.code-preview {
    overflow: auto;
}

/* ═══════════════════════════════════════════════════════
   AI Chat Widget
   ═══════════════════════════════════════════════════════ */

.ai-chat-widget {
    padding: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
    margin-bottom: 12px;
}

.chat-message {
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
}

.chat-message.chat-user {
    align-items: flex-end;
}

.chat-message.chat-ai {
    align-items: flex-start;
}

.chat-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.chat-bubble.bg-primary {
    border-bottom-right-radius: 4px;
}

.chat-bubble.bg-light {
    background: #f3f4f6;
    border-bottom-left-radius: 4px;
}

.chat-typing {
    color: #6b7280;
    font-style: italic;
}

.chat-input-group {
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════
   Workflow Designer
   ═══════════════════════════════════════════════════════ */

.workflow-designer {
    padding: 16px;
}

.workflow-list {
    max-height: 400px;
    overflow-y: auto;
}

.workflow-card {
    padding: 12px;
    margin-bottom: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.workflow-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.1);
}

.instance-list {
    max-height: 400px;
    overflow-y: auto;
}

.instance-item {
    padding: 8px;
    margin-bottom: 4px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

/* ═══════════════════════════════════════════════════════
   Translation Manager
   ═══════════════════════════════════════════════════════ */

.translation-manager {
    padding: 16px;
}

.translation-list {
    max-height: 400px;
    overflow-y: auto;
}

.translation-entry {
    padding: 8px;
    margin-bottom: 6px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.translation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.translation-key {
    color: #3b82f6;
    font-size: 0.6875rem;
}

.translation-source-text {
    font-size: 0.75rem;
    margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════
   Policy Mapping
   ═══════════════════════════════════════════════════════ */

.policy-mapping {
    padding: 16px;
}

.policy-role-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

/* ═══════════════════════════════════════════════════════
   Tailwind Manager
   ═══════════════════════════════════════════════════════ */

.tailwind-manager {
    padding: 16px;
}

.tailwind-results {
    max-height: 300px;
    overflow-y: auto;
}

.applied-classes {
    min-height: 32px;
    padding: 4px;
}

.applied-class {
    font-size: 0.75rem;
    font-family: monospace;
}

/* ═══════════════════════════════════════════════════════
   AI Section Generator
   ═══════════════════════════════════════════════════════ */

.ai-section-generator {
    padding: 16px;
}

.ai-result {
    margin-top: 12px;
}

.ai-result-pre {
    background: #1a1d23;
    color: #e5e7eb;
    padding: 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    max-height: 300px;
    overflow: auto;
    white-space: pre-wrap;
}

/* ═══════════════════════════════════════════════════════
   AI Image Studio
   ═══════════════════════════════════════════════════════ */

.ai-image-studio {
    padding: 16px;
}

/* ═══════════════════════════════════════════════════════
   Version History
   ═══════════════════════════════════════════════════════ */

.version-history {
    padding: 16px;
}

.version-list {
    max-height: 400px;
    overflow-y: auto;
}

.version-item {
    padding: 8px;
    margin-bottom: 6px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

/* ═══════════════════════════════════════════════════════
   Publish Dialog
   ═══════════════════════════════════════════════════════ */

.publish-dialog {
    padding: 16px;
}

/* ═══════════════════════════════════════════════════════
   Scrollbar Styling
   ═══════════════════════════════════════════════════════ */

.palette-body::-webkit-scrollbar,
.builder-canvas-wrapper::-webkit-scrollbar,
.property-panel::-webkit-scrollbar,
.variable-list::-webkit-scrollbar,
.template-grid::-webkit-scrollbar,
.product-grid::-webkit-scrollbar,
.cart-items::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.workflow-list::-webkit-scrollbar,
.translation-list::-webkit-scrollbar,
.tailwind-results::-webkit-scrollbar,
.version-list::-webkit-scrollbar {
    width: 6px;
}

.palette-body::-webkit-scrollbar-track,
.builder-canvas-wrapper::-webkit-scrollbar-track,
.property-panel::-webkit-scrollbar-track {
    background: transparent;
}

.palette-body::-webkit-scrollbar-thumb {
    background: #3a3d45;
    border-radius: 3px;
}

.builder-canvas-wrapper::-webkit-scrollbar-thumb,
.property-panel::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}
