/**
 * Form Builder Styles
 * Modern drag-and-drop interface inspired by ElevenLabs
 */

/* ===== MODAL OVERLAY & CONTAINER ===== */
.form-builder-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.form-builder-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.form-builder-container {
    position: relative;
    background: #ffffff;
    border-radius: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    animation: slideUp 0.3s ease;
}

/* ===== HEADER ===== */
.form-builder-header {
    padding: 20px 30px;
    border-bottom: 2px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #000000;
    border-radius: 0;
}

.form-builder-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-builder-header h2 i {
    font-size: 1.3rem;
}

.form-builder-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #ffffff;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.form-builder-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* ===== MAIN CONTENT ===== */
.form-builder-content {
    flex: 1;
    display: grid;
    grid-template-columns: 250px 1fr 300px;
    gap: 0;
    overflow: hidden;
}

/* ===== LEFT SIDEBAR - FIELD PALETTE ===== */
.form-builder-sidebar {
    background: #f8f9fa;
    border-right: 2px solid #e8e8e8;
    padding: 20px;
    overflow-y: auto;
}

.form-builder-sidebar h3 {
    margin: 0 0 16px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-palette {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-palette-item {
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: grab;
    transition: all 0.2s ease;
    user-select: none;
}

.field-palette-item:hover {
    border-color: #000000;
    background: #f5f5f5;
    transform: translateX(4px);
}

.field-palette-item:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.field-palette-item i {
    font-size: 1.2rem;
    color: #000000;
    width: 24px;
    text-align: center;
}

.field-palette-item span {
    font-size: 0.9rem;
    font-weight: 500;
    color: #2c3e50;
}

/* ===== CENTER - CANVAS ===== */
.form-builder-canvas {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
}

.canvas-header {
    padding: 20px;
    border-bottom: 2px solid #e8e8e8;
    background: #fafbfc;
}

.form-title-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.3rem;
    font-weight: 600;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.form-title-input:focus {
    outline: none;
    border-color: #000000;
}

.form-description-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    min-height: 60px;
    resize: vertical;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.form-description-input:focus {
    outline: none;
    border-color: #000000;
}

.canvas-drop-zone {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    min-height: 300px;
}

.canvas-drop-zone.drag-over {
    background: #f5f5f5;
    outline: 3px dashed #000000;
    outline-offset: -10px;
}

.canvas-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: #95a5a6;
}

.canvas-empty-state i {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.canvas-empty-state p {
    font-size: 1.1rem;
    margin: 0;
}

/* ===== CANVAS FIELD ITEMS ===== */
.canvas-field-item {
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* ===== SECTION CONTAINERS ===== */
.canvas-section-container {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.canvas-section-container.selected {
    border-color: #000000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.section-header {
    background: linear-gradient(90deg, #000000 0%, #333333 100%);
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.section-header:hover {
    background: linear-gradient(90deg, #1a1a1a 0%, #4a4a4a 100%);
}

.section-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.section-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.2rem;
}

.section-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-info strong {
    font-size: 1.1rem;
    color: #ffffff;
    font-weight: 600;
}

.section-info span {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.section-actions {
    display: flex;
    gap: 8px;
}

/* ===== SECTION FIELDS ZONE ===== */
.section-fields-zone {
    padding: 16px;
    min-height: 100px;
    background: #ffffff;
    transition: all 0.2s ease;
}

.section-fields-zone.drag-over-section {
    background: #f0f4ff;
    outline: 3px dashed #000000;
    outline-offset: -10px;
}

.section-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #bdc3c7;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
}

.section-empty-state i {
    font-size: 2.5rem;
    margin-bottom: 8px;
    opacity: 0.4;
}

.section-empty-state p {
    font-size: 0.95rem;
    margin: 0;
}

/* Update canvas field items for nested structure */
.section-fields-zone .canvas-field-item {
    margin-bottom: 12px;
}

.section-fields-zone .canvas-field-item:last-child {
    margin-bottom: 0;
}

.canvas-field-item:hover {
    border-color: #000000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.canvas-field-item.selected {
    border-color: #000000;
    background: #f5f5f5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.field-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.field-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.field-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-item-info strong {
    font-size: 1rem;
    color: #2c3e50;
}

.field-item-info span {
    font-size: 0.85rem;
    color: #7f8c8d;
    text-transform: capitalize;
}

.field-item-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #7f8c8d;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: #000000;
    border-color: #000000;
    color: #ffffff;
    transform: translateY(-2px);
}

.btn-icon.btn-danger:hover {
    background: #e74c3c;
    border-color: #e74c3c;
}

/* ===== PROPERTY INFO ===== */
.property-info {
    padding: 12px;
    background: #f0f4ff;
    border-left: 3px solid #000000;
    border-radius: 6px;
    margin-top: 8px;
}

.property-info p {
    margin: 0;
    font-size: 0.85rem;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.property-info i {
    color: #000000;
}

/* ===== RIGHT SIDEBAR - PROPERTIES ===== */
.form-builder-properties {
    background: #f8f9fa;
    border-left: 2px solid #e8e8e8;
    padding: 20px;
    overflow-y: auto;
}

.form-builder-properties h3 {
    margin: 0 0 16px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-properties-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.properties-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #95a5a6;
    text-align: center;
}

.properties-empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.3;
}

.properties-empty-state p {
    font-size: 0.95rem;
    margin: 0;
}

.property-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.property-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #2c3e50;
}

.property-group input[type="text"],
.property-group input[type="number"],
.property-group textarea {
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.property-group input:focus,
.property-group textarea:focus {
    outline: none;
    border-color: #000000;
}

.property-group textarea {
    min-height: 80px;
    resize: vertical;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.checkbox-label:hover {
    background-color: #e8e8e8;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #000000;
}

.checkbox-label span {
    font-size: 0.9rem;
    color: #2c3e50;
}

/* ===== FOOTER ===== */
.form-builder-footer {
    padding: 20px 30px;
    border-top: 2px solid #e8e8e8;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: #fafbfc;
    border-radius: 0 0 16px 16px;
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.btn-secondary {
    background: #ffffff;
    color: #7f8c8d;
    border: 2px solid #e0e0e0;
}

.btn-secondary:hover {
    background: #f8f9fa;
    border-color: #000000;
    color: #000000;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
    .form-builder-content {
        grid-template-columns: 220px 1fr 280px;
    }
}

@media (max-width: 1024px) {
    .form-builder-container {
        width: 98vw;
        height: 95vh;
    }

    .form-builder-content {
        grid-template-columns: 200px 1fr 260px;
    }

    .form-builder-sidebar,
    .form-builder-properties {
        padding: 16px;
    }
}

@media (max-width: 768px) {
    .form-builder-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .form-builder-sidebar {
        border-right: none;
        border-bottom: 2px solid #e8e8e8;
        max-height: 200px;
    }

    .form-builder-properties {
        border-left: none;
        border-top: 2px solid #e8e8e8;
        max-height: 250px;
    }

    .field-palette {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .field-palette-item {
        flex: 0 0 calc(50% - 4px);
    }
}

/* ===== SCROLLBAR STYLING ===== */
.form-builder-sidebar::-webkit-scrollbar,
.form-builder-properties::-webkit-scrollbar,
.canvas-drop-zone::-webkit-scrollbar {
    width: 8px;
}

.form-builder-sidebar::-webkit-scrollbar-track,
.form-builder-properties::-webkit-scrollbar-track,
.canvas-drop-zone::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.form-builder-sidebar::-webkit-scrollbar-thumb,
.form-builder-properties::-webkit-scrollbar-thumb,
.canvas-drop-zone::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.form-builder-sidebar::-webkit-scrollbar-thumb:hover,
.form-builder-properties::-webkit-scrollbar-thumb:hover,
.canvas-drop-zone::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .form-builder-container {
        background: #2d2d2d;
    }

    .form-builder-sidebar,
    .form-builder-properties {
        background: #1a1a1a;
        border-color: #444444;
    }

    .canvas-header,
    .form-builder-footer {
        background: #1a1a1a;
        border-color: #444444;
    }

    .form-builder-canvas {
        background: #2d2d2d;
    }

    .form-title-input,
    .form-description-input,
    .property-group input,
    .property-group textarea {
        background: #1a1a1a;
        border-color: #444444;
        color: #ffffff;
    }

    .field-palette-item,
    .canvas-field-item {
        background: #3a3a3a;
        border-color: #555555;
    }

    .canvas-empty-state,
    .properties-empty-state {
        color: #888888;
    }

    .field-item-info strong,
    .property-group label,
    .checkbox-label span,
    .form-builder-sidebar h3,
    .form-builder-properties h3 {
        color: #e0e0e0;
    }

    .field-item-info span {
        color: #999999;
    }

    .btn-secondary {
        background: #3a3a3a;
        border-color: #555555;
        color: #e0e0e0;
    }

    .btn-icon {
        background: #3a3a3a;
        border-color: #555555;
        color: #999999;
    }
}

/* ===== ACCESSIBILITY ===== */
.form-builder-close:focus,
.field-palette-item:focus,
.canvas-field-item:focus,
.btn-primary:focus,
.btn-secondary:focus {
    outline: 2px solid #000000;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .form-builder-modal,
    .form-builder-container,
    .field-palette-item,
    .canvas-field-item,
    .btn-icon,
    .btn-primary,
    .btn-secondary {
        animation: none;
        transition: none;
    }
}
