/* Builder Mode Styles */
.builder-container {
    display: flex;
    height: calc(100vh - 80px);
    /* Adjust based on header height */
    overflow: hidden;
    background-color: #f5f5f5;
}

.builder-sidebar {
    width: 220px;
    /* Reduced from 300px */
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

.builder-sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.builder-sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.builder-sections-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.draggable-section {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.75rem;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.draggable-section:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.draggable-section:active {
    cursor: grabbing;
}

.section-icon {
    font-size: 1.25rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 4px;
}

.section-info {
    flex: 1;
}

.section-name {
    font-weight: 500;
    font-size: 0.9rem;
    display: block;
}

.section-desc {
    font-size: 0.75rem;
    color: #666;
}

.builder-canvas-container {
    width: 320px;
    /* Fixed width */
    flex: none;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    justify-content: center;
    background-image: radial-gradient(#ddd 1px, transparent 1px);
    background-size: 20px 20px;
    border-right: 1px solid #e0e0e0;
}

.builder-canvas {
    width: 100%;
    min-height: 100%;
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    position: relative;
    padding-bottom: 4rem;
}

.builder-canvas.empty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-msg {
    text-align: center;
    color: #999;
    padding: 2rem;
    border: 2px dashed #ddd;
    border-radius: 8px;
}

/* Drop Zones */
.drop-zone {
    height: 10px;
    transition: height 0.2s ease;
    position: relative;
}

.drop-zone.active {
    height: 40px;
    background: rgba(59, 130, 246, 0.1);
    border: 2px dashed #3b82f6;
    margin: 0.5rem 0;
    border-radius: 4px;
}

.drop-zone.active::after {
    content: 'Drop Here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #3b82f6;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Builder Item Controls */
.builder-item {
    position: relative;
}

.builder-item-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 100;
    background: white;
    padding: 0.25rem;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.builder-item:hover .builder-item-controls {
    opacity: 1;
}

.control-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    transition: all 0.1s;
}

.control-btn:hover {
    background: #f0f0f0;
    color: #000;
}

.control-btn.delete {
    color: #ef4444;
    border-color: #fecaca;
    color: #ef4444;
}

.control-btn.delete:hover {
    background: #fef2f2;
}

/* Toggle Switch */
.mode-toggle {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    margin-right: 1rem;
}

.mode-btn {
    padding: 6px 16px;
    border-radius: 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s ease;
}

.mode-btn.active {
    background: white;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.hidden {
    display: none !important;
}

/* Custom Section Preview Styles */
.custom-section-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

.custom-section-wrapper img {
    max-width: 100% !important;
    height: auto !important;
}

/* Preview Pane Styles */
.builder-preview {
    flex: 1;
    /* Take remaining space */
    background: white;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.05);
    min-width: 0;
    /* Prevent flex overflow */
}

/* Preview Toolbar */
.preview-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    justify-content: center;
}

.preview-toggle {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.preview-toggle:hover {
    background: #f0f0f0;
}

.preview-toggle.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* Preview Container & Views */
.preview-container {
    flex: 1;
    overflow-y: auto;
    background: #f0f2f5;
    /* Distinct background for canvas area */
    padding: 2rem;
    display: flex;
    justify-content: center;
    /* Center the content */
}

.preview-content {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: width 0.3s ease, border-radius 0.3s ease;
    min-height: 100%;
}

/* Desktop View (Default) */
.preview-content {
    width: 100%;
    max-width: 100%;
}

/* Mobile View */
.preview-content.preview-mobile {
    width: 375px !important;
    min-width: 375px;
    max-width: 375px;
    border-radius: 20px;
    border: 8px solid #333;
    overflow: hidden;
    min-height: 667px;
    height: max-content;
}

/* Editable Content */
[contenteditable="true"] {
    outline: 2px dashed transparent;
    transition: outline-color 0.2s;
    cursor: text;
}

[contenteditable="true"]:hover {
    outline-color: rgba(0, 123, 255, 0.5);
}

[contenteditable="true"]:focus {
    outline: 2px solid #007bff;
    background: rgba(0, 123, 255, 0.05);
    border-radius: 2px;
}

/* AI Assistant Modal Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

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

.file-upload-wrapper {
    border: 2px dashed #ddd;
    padding: 1rem;
    text-align: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9fa;
}

.file-upload-wrapper:hover {
    border-color: #3b82f6;
    background: #f0f9ff;
}

.btn-loader {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}