/* builder.css - Custom Layout Builder UI */

.builder-container {
    display: flex;
    height: 100vh;
    background: #f1f5f9;
    font-family: 'Inter', sans-serif;
}

/* Sidebar Styling */
.builder-sidebar {
    width: 320px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

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

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.component-library {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.library-section {
    margin-bottom: 2rem;
}

.library-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.comp-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.comp-item:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.comp-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #64748b;
    transition: color 0.2s;
}

.comp-item:hover .comp-icon {
    color: #3b82f6;
}

/* Canvas Styling */
.builder-canvas-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-frame {
    width: 100%;
    max-width: 1100px;
    background: #ffffff;
    min-height: 800px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    position: relative;
    padding-bottom: 100px;
}

/* Section Controls (Overlay) */
.section-wrapper {
    position: relative;
    border: 2px solid transparent;
    transition: border-color 0.2s;
    min-height: 40px;
    z-index: 1;
    /* Low z-index to stay below navbar dropdown (2000) while maintaining stacking context */
}

.section-wrapper:hover {
    border: 2px dashed #3b82f6;
    background: rgba(59, 130, 246, 0.02);
    /* No z-index to avoid creating stacking context over main navbar */
}

.section-controls {
    position: absolute;
    right: 8px;
    top: 8px;
    display: none;
    gap: 6px;
    background: rgba(255, 255, 255, 0.98);
    padding: 6px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 9999;
    /* Very high z-index to ensure visibility */
    backdrop-filter: blur(8px);
}

.section-wrapper:hover .section-controls {
    display: flex;
}

.control-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #475569;
    transition: all 0.2s;
}

.control-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
    transform: scale(1.05);
}

.control-btn.delete:hover {
    background: #fee2e2;
    color: #ef4444;
    border-color: #fca5a5;
}

.control-btn.duplicate:hover {
    background: #dbeafe;
    color: #2563eb;
    border-color: #93c5fd;
}

/* Empty State */
.empty-canvas-msg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #94a3b8;
}

/* Top Bar Removed - Functionality moved to Sidebar Footer */

/* ---------------------------------------------------------
   BUILDER UI RESPONSIVENESS
   --------------------------------------------------------- */

@media (max-width: 992px) {
    .builder-sidebar {
        width: 260px;
    }
}

@media (max-width: 768px) {
    .builder-container {
        flex-direction: column;
        overflow: visible;
        height: auto;
    }

    .builder-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        position: sticky;
        top: 0;
        max-height: 400px;
    }

    .builder-canvas-area {
        padding: 1rem;
    }

    .canvas-frame {
        padding-bottom: 50px;
    }
}

@media (max-width: 480px) {
    .sidebar-header {
        padding: 1rem;
    }

    .component-library {
        padding: 1rem;
    }

    .comp-item {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    .sidebar-footer {
        padding: 1rem;
    }

    .canvas-frame {
        min-height: 500px;
    }
}

/* ========== CUSTOMIZATION PANEL ========== */
.customization-panel {
    position: fixed;
    top: 1rem;
    right: -420px;
    width: 400px;
    height: calc(100vh - 2rem);
    background: #ffffff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08), -1px 0 4px rgba(0, 0, 0, 0.04);
    z-index: 10000;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-radius: 16px 0 0 16px;
    border: 1px solid #e2e8f0;
    border-right: none;
}

.customization-panel.active {
    right: 0;
}

.panel-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafbfc;
    border-radius: 16px 0 0 0;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #0f172a;
}

.panel-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.panel-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* Form Controls */
.form-group {
    margin-bottom: 2rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #edf2f7;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: all 0.2s;
    font-family: inherit;
    box-sizing: border-box;
    background: #f8fafc;
    color: #0f172a;
}

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

/* List Editor */
.list-editor {
    margin-bottom: 0.75rem;
}

.list-item {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    align-items: center;
    background: #ffffff;
    padding: 0.5rem;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    transition: all 0.2s;
}

.list-item:hover {
    border-color: #e2e8f0;
}

.list-item .form-control {
    flex: 1;
    border-color: transparent;
    padding: 0.5rem 0.75rem;
}

.list-item .form-control:focus {
    background: #f8fafc;
}

.btn-remove {
    width: 36px;
    height: 36px;
    background: #fff1f2;
    border: none;
    color: #e11d48;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-remove:hover {
    background: #ffe4e6;
    color: #be123c;
    transform: scale(1.05);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}



.panel-section-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1.5rem 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.panel-section-title i {
    color: #3b82f6;
    font-size: 0.9rem;
}

.panel-footer {
    padding: 1.5rem;
    border-top: 1px solid #f1f5f9;
    background: #fff;
}

.btn-done {
    width: 100%;
    padding: 0.875rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.btn-done:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
}

.btn-done:active {
    transform: translateY(0);
}