/* Page Builder V2 Styles */

.page-builder-v2 {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f5f5f5;
}

/* Loading State */
.builder-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

/* Toolbar */
.builder-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #1a202c;
    border-bottom: 1px solid #4a5568;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.page-info {
    display: flex;
    gap: 8px;
}

.page-title-input {
    min-width: 200px;
    font-weight: 600;
}

.page-slug-input {
    min-width: 150px;
    color: #666;
}

.section-info-display {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 14px;
}

.builder-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Viewport Controls */
.viewport-controls {
    display: flex;
    gap: 4px;
    background: #f8f9fa;
    padding: 4px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.viewport-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.2s;
}

.viewport-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.viewport-btn.active {
    background: #667eea;
    color: white;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.viewport-btn i {
    font-size: 16px;
}

.viewport-label {
    font-size: 12px;
    font-weight: 500;
}

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

/* Sidebar */
.builder-sidebar {
    width: 260px;
    background: #1a202c;
    border-right: 1px solid #4a5568;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.builder-sidebar-settings {
    width: 300px;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #4a5568;
    display: flex;
    align-items: center;
    background: #2d3748;
}

.sidebar-header h6 {
    margin: 0;
    font-weight: 600;
    color: #e2e8f0;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #1a202c;
    color: #FFF;
}

.sidebar-content .text-muted {
    color: rgba(255, 255, 255, 0.3) !important;
}

.sidebar-content .border {
    border-color: #333438 !important;
}

.component-group {
    margin-bottom: 20px;
}

.group-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #a0aec0;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.component-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.component-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 8px;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 6px;
    cursor: grab;
    transition: all 0.2s;
    width: 100%;
    text-align: center;
}

.component-item:hover {
    background: #4a5568;
    border-color: #667eea;
    transform: translateY(-2px);
}

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

.component-item:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.component-item i {
    font-size: 24px;
    color: #667eea;
}

.component-item span {
    font-size: 12px;
    font-weight: 500;
    color: #e2e8f0;
}

/* Main Viewport */
.builder-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
}

.builder-viewport {
    flex: 1;
    padding: 0;
    overflow: auto;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
}

.viewport-wrapper {
    width: 100%;
    max-width: 100%;
    margin: 0;
    background: #fff;
    min-height: 100%;
    flex: 1;
    position: relative;
}

.viewport-responsive {
    border-radius: 12px;
    max-width: none;
    padding: 0;
}

.viewport-wrapper.viewport-responsive {
    margin: 20px auto;
}

.viewport-label {
    text-align: center;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    background: #2d3748;
    border-bottom: 1px solid #4a5568;
}

.empty-canvas {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #999;
    text-align: center;
}

.empty-canvas i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-canvas p {
    margin: 0;
    font-size: 14px;
}

/* Layers Panel (Floating & Draggable) */
.builder-layers-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 280px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
}

.builder-layers-panel .panel-header {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    cursor: move;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.builder-layers-panel .panel-header h6 {
    margin: 0;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.builder-layers-panel .panel-header i {
    color: #667eea;
}

.panel-header-drag-icon {
    color: #999;
    font-size: 12px;
    cursor: move;
}

.builder-layers-panel .panel-header:active {
    cursor: grabbing;
}

/* Layers content area */
.builder-layers-panel .layers-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Prevent text selection while dragging */
.builder-layers-panel.dragging,
.builder-layers-panel.dragging * {
    user-select: none;
    cursor: grabbing !important;
}

/* Settings Panel (Legacy - now in sidebar) */
.builder-settings-panel {
    width: 300px;
    background: #fff;
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Panel Tabs */
.panel-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    background: #f8f9fa;
}

.panel-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.2s;
}

.panel-tab:hover {
    background: #e9ecef;
    color: #495057;
}

.panel-tab.active {
    background: #fff;
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.panel-tab i {
    font-size: 14px;
}

.panel-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.panel-header h6 {
    margin: 0;
    font-weight: 600;
    color: #333;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Layers Panel */
.layers-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.layers-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.layers-content {
    flex: 1;
    overflow-y: auto;
}

.layer-node {
    user-select: none;
}

.layer-item {
    position: relative;
}

.layer-item[draggable="true"]:active {
    cursor: grabbing !important;
}

.layer-item:hover .layer-drag-handle {
    opacity: 1 !important;
}

.layer-drag-over {
    background-color: #e3f2fd !important;
    border: 2px dashed #667eea !important;
}

.layer-root {
    font-weight: 600;
}

.no-selection,
.no-settings {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #999;
    text-align: center;
}

.no-selection i,
.no-settings i {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.no-selection p,
.no-settings p {
    margin: 0;
    font-size: 13px;
}

/* Component Settings */
.component-settings {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-label {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0;
}

.panel-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* Craft.js specific styles */
[data-cy="frame"] {
    width: 100%;
    height: 100%;
}

.component-selected {
    outline: 2px solid #667eea !important;
    outline-offset: 0px;
    position: relative;
}

.component-hover {
    outline: 1px dashed #667eea !important;
    outline-offset: 0px;
}

.component-indicator {
    pointer-events: none;
}

.component-toolbar {
    user-select: none;
}

.component-toolbar .toolbar-btn {
    transition: all 0.2s;
}

.component-toolbar .toolbar-btn:hover {
    background: rgba(255,255,255,0.3) !important;
    transform: scale(1.05);
}

/* Drag and drop indicators */
[data-indicator] {
    position: absolute;
    background-color: #667eea;
    height: 2px;
    z-index: 999;
}

/* Make draggable items have grab cursor */
[draggable="true"] {
    cursor: grab !important;
}

[draggable="true"]:active {
    cursor: grabbing !important;
}

/* Canvas drop zone styling */
.empty-canvas {
    transition: all 0.2s ease;
}

/* Highlight containers when hovering during drag */
[data-canvas]:hover {
    background-color: rgba(102, 126, 234, 0.02);
}

/* Selected component styling */
div[class*="craft"] > div:hover {
    outline: 1px dashed #667eea;
    outline-offset: 2px;
}

/* Quill WYSIWYG Editor Styles */
.component-settings .quill {
    background: white;
    border-radius: 4px;
}

.component-settings .ql-toolbar {
    border: 1px solid #ced4da;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    background: #f8f9fa;
}

.component-settings .ql-container {
    border: 1px solid #ced4da;
    border-radius: 0 0 4px 4px;
    font-size: 14px;
    min-height: 150px;
    background: white;
}

.component-settings .ql-editor {
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
    color: #212529 !important;
    background: white;
}

.component-settings .ql-editor * {
    color: inherit;
}

.component-settings .ql-editor p,
.component-settings .ql-editor h1,
.component-settings .ql-editor h2,
.component-settings .ql-editor h3,
.component-settings .ql-editor h4,
.component-settings .ql-editor h5,
.component-settings .ql-editor h6,
.component-settings .ql-editor span,
.component-settings .ql-editor div {
    color: #212529 !important;
}

.component-settings .ql-editor.ql-blank::before {
    color: #6c757d !important;
    font-style: normal;
}

/* Quill toolbar buttons */
.component-settings .ql-toolbar button {
    width: 28px;
    height: 28px;
}

.component-settings .ql-toolbar button:hover,
.component-settings .ql-toolbar button.ql-active {
    color: #667eea;
}

.component-settings .ql-toolbar .ql-stroke {
    stroke: #495057;
}

.component-settings .ql-toolbar button:hover .ql-stroke,
.component-settings .ql-toolbar button.ql-active .ql-stroke {
    stroke: #667eea;
}

.component-settings .ql-toolbar .ql-fill {
    fill: #495057;
}

.component-settings .ql-toolbar button:hover .ql-fill,
.component-settings .ql-toolbar button.ql-active .ql-fill {
    fill: #667eea;
}
