/**
 * Form Designer - Visual Form Builder CSS
 */

/* Modal Principal */
.fd-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.fd-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.fd-modal-content {
    background: #1a1d24;
    border-radius: 12px;
    width: 95%;
    max-width: 1600px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Header */
.fd-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px 12px 0 0;
}

.fd-header h2 {
    margin: 0;
    color: #fff;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.fd-header h2 i {
    color: #8b5cf6;
}

.fd-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #999;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.fd-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Body - Layout de 3 colunas */
.fd-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar - Campos disponíveis */
.fd-sidebar {
    width: 280px;
    background: rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    flex-shrink: 0;
}

.fd-sidebar-section {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.fd-sidebar-section h3 {
    color: #8b5cf6;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
}

/* Configuração do Formulário */
.fd-form-config {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fd-config-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fd-config-group label {
    color: #888;
    font-size: 0.8em;
}

.fd-config-group input,
.fd-config-group textarea,
.fd-config-group select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 10px;
    color: #fff;
    font-size: 0.9em;
}

.fd-config-group input:focus,
.fd-config-group textarea:focus,
.fd-config-group select:focus {
    border-color: #8b5cf6;
}

.fd-config-group input:focus-visible,
.fd-config-group textarea:focus-visible,
.fd-config-group select:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Categorias de Campos */
.fd-field-categories {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fd-category {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    overflow: hidden;
}

.fd-category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    color: #bbb;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
}

.fd-category-header:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.fd-category-header i {
    width: 18px;
    text-align: center;
    color: #8b5cf6;
}

.fd-category.collapsed .fd-category-fields {
    display: none;
}

.fd-category-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 8px;
    padding-top: 0;
}

/* Tipos de Campo Arrastáveis */
.fd-field-type {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: grab;
    transition: all 0.2s;
    font-size: 0.75em;
    color: #bbb;
}

.fd-field-type:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    color: #fff;
    transform: translateY(-2px);
}

.fd-field-type.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.fd-field-type i {
    font-size: 1.2em;
    color: #8b5cf6;
}

/* Canvas - Área de Design */
.fd-canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.fd-canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.fd-canvas-header h3 {
    margin: 0;
    color: #fff;
    font-size: 0.95em;
}

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

.fd-canvas {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.03) 0%, rgba(59, 130, 246, 0.03) 100%);
}

.fd-canvas.drag-over {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%);
}

.fd-canvas-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    gap: 16px;
}

.fd-canvas-empty i {
    font-size: 3em;
    color: #8b5cf6;
    opacity: 0.5;
    animation: bounce-left 1.5s infinite;
}

@keyframes bounce-left {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-10px); }
}

.fd-canvas-empty p {
    font-size: 1.1em;
    margin: 0;
}

/* Form Preview */
.fd-form-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-content: flex-start;
}

/* Canvas Field - Campo no Canvas */
.fd-canvas-field {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 16px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.fd-canvas-field:hover {
    border-color: rgba(139, 92, 246, 0.3);
}

.fd-canvas-field.selected {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

/* Larguras */
.fd-width-full {
    width: 100%;
}

.fd-width-half {
    width: calc(50% - 8px);
}

.fd-width-third {
    width: calc(33.333% - 10.667px);
}

/* Ações do Campo */
.fd-field-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.fd-canvas-field:hover .fd-field-actions,
.fd-canvas-field.selected .fd-field-actions {
    opacity: 1;
}

.fd-field-actions button {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75em;
    transition: all 0.2s;
}

.fd-field-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.fd-field-actions button.fd-btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.fd-field-actions button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Conteúdo do Campo */
.fd-field-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fd-field-content.layout-field {
    min-height: auto;
}

.fd-field-label {
    color: #bbb;
    font-size: 0.9em;
    font-weight: 500;
}

.fd-required {
    color: #ef4444;
    margin-left: 2px;
}

.fd-field-content input,
.fd-field-content textarea,
.fd-field-content select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px 12px;
    color: #888;
    font-size: 0.9em;
}

.fd-help-text {
    color: #666;
    font-size: 0.8em;
}

.fd-field-type-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.7em;
}

/* Preview específicos por tipo */
.fd-checkbox-group,
.fd-radio-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fd-checkbox-group label,
.fd-radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #888;
    font-size: 0.85em;
    cursor: default;
}

.fd-file-preview {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    color: #666;
}

.fd-file-preview i {
    font-size: 2em;
    margin-bottom: 8px;
    color: #8b5cf6;
    opacity: 0.5;
}

.fd-range-preview {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fd-range-preview input {
    flex: 1;
}

.fd-range-value {
    color: #8b5cf6;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.fd-rating-preview {
    display: flex;
    gap: 4px;
}

.fd-rating-preview i {
    font-size: 1.3em;
    color: rgba(255, 255, 255, 0.2);
}

.fd-rating-preview i.active {
    color: #fbbf24;
}

.fd-hidden-preview {
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 6px;
    color: #666;
    font-size: 0.85em;
    text-align: center;
}

.fd-divider-preview {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

.fd-heading-preview {
    color: #fff;
    font-size: 1.2em;
    margin: 0;
    padding: 8px 0;
}

.fd-paragraph-preview {
    color: #888;
    font-size: 0.9em;
    margin: 0;
    line-height: 1.5;
}

/* Painel de Propriedades */
.fd-properties {
    width: 300px;
    background: rgba(0, 0, 0, 0.3);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.fd-properties-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.fd-properties-header h3 {
    margin: 0;
    color: #fff;
    font-size: 0.95em;
}

.fd-properties-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.fd-no-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #666;
    text-align: center;
    gap: 12px;
}

.fd-no-selection i {
    font-size: 2.5em;
    opacity: 0.5;
}

/* Grupos de Propriedades */
.fd-prop-group {
    margin-bottom: 16px;
}

.fd-prop-group label {
    display: block;
    color: #888;
    font-size: 0.8em;
    margin-bottom: 6px;
}

.fd-prop-group input,
.fd-prop-group textarea,
.fd-prop-group select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 10px;
    color: #fff;
    font-size: 0.9em;
}

.fd-prop-group input:focus,
.fd-prop-group textarea:focus,
.fd-prop-group select:focus {
    border-color: #8b5cf6;
}

.fd-prop-group input:focus-visible,
.fd-prop-group textarea:focus-visible,
.fd-prop-group select:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.fd-prop-checkbox {
    display: flex;
    align-items: center;
}

.fd-prop-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #bbb;
    cursor: pointer;
    margin: 0;
}

.fd-prop-checkbox input {
    width: auto;
}

.fd-hint {
    display: block;
    color: #666;
    font-size: 0.75em;
    margin-top: 4px;
}

.fd-prop-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.fd-prop-section h4 {
    color: #8b5cf6;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
}

/* Lista de Opções */
.fd-options-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.fd-option-item {
    display: flex;
    gap: 6px;
}

.fd-option-item input {
    flex: 1;
}

.fd-option-item button {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.fd-option-item button:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Footer */
.fd-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 12px 12px;
}

/* Botões */
.fd-btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.fd-btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: #fff;
}

.fd-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.fd-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #bbb;
}

.fd-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.fd-btn-small {
    padding: 6px 12px;
    font-size: 0.8em;
}

/* Modal de Preview */
.fd-preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10001;
}

.fd-preview-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.fd-preview-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.fd-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.fd-preview-header h3 {
    margin: 0;
    color: #333;
}

.fd-preview-header .fd-close-btn {
    background: transparent;
    color: #666;
}

.fd-preview-header .fd-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

.fd-preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Preview Form Styles */
.fd-preview-form {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.fd-preview-form.dark-theme {
    background: #1a1d24;
    color: #fff;
    padding: 24px;
    border-radius: 8px;
}

.fd-preview-form-header {
    margin-bottom: 24px;
}

.fd-preview-form-header h2 {
    margin: 0 0 8px 0;
    color: inherit;
}

.fd-preview-form-header p {
    margin: 0;
    color: #666;
}

.fd-preview-form.dark-theme .fd-preview-form-header p {
    color: #888;
}

.fd-preview-form-body {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.fd-preview-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fd-preview-field label {
    font-weight: 500;
    color: #333;
}

.fd-preview-form.dark-theme .fd-preview-field label {
    color: #bbb;
}

.fd-preview-field .required {
    color: #ef4444;
}

.fd-preview-field input,
.fd-preview-field textarea,
.fd-preview-field select {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.fd-preview-form.dark-theme .fd-preview-field input,
.fd-preview-form.dark-theme .fd-preview-field textarea,
.fd-preview-form.dark-theme .fd-preview-field select {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.fd-preview-field .help-text {
    font-size: 12px;
    color: #888;
}

.fd-preview-field .checkbox-group,
.fd-preview-field .radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fd-preview-field .checkbox-label,
.fd-preview-field .radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

.fd-preview-field .range-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fd-preview-field .range-container input {
    flex: 1;
}

.fd-preview-field .range-value {
    font-weight: bold;
    color: #8b5cf6;
    min-width: 40px;
    text-align: center;
}

.fd-preview-field .rating-container {
    display: flex;
    gap: 4px;
}

.fd-preview-field .rating-star {
    font-size: 1.5em;
    color: #ddd;
    cursor: pointer;
    transition: color 0.2s;
}

.fd-preview-field .rating-star.active,
.fd-preview-field .rating-star:hover {
    color: #fbbf24;
}

.fd-preview-divider {
    width: 100%;
    border: none;
    border-top: 1px solid #eee;
    margin: 8px 0;
}

.fd-preview-form.dark-theme .fd-preview-divider {
    border-color: rgba(255, 255, 255, 0.1);
}

.fd-preview-heading {
    width: 100%;
    margin: 8px 0;
    color: #333;
}

.fd-preview-form.dark-theme .fd-preview-heading {
    color: #fff;
}

.fd-preview-paragraph {
    width: 100%;
    margin: 8px 0;
    color: #666;
    line-height: 1.5;
}

.fd-preview-form.dark-theme .fd-preview-paragraph {
    color: #888;
}

.fd-preview-submit {
    width: 100%;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.fd-preview-form.dark-theme .fd-preview-submit {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Node visual no editor */
.node-form-designer-info {
    padding: 8px;
    text-align: center;
}

.node-form-designer-title {
    font-weight: bold;
    color: #8b5cf6;
    margin-bottom: 4px;
}

.node-form-designer-stats {
    font-size: 0.8em;
    color: #888;
}

.node-form-designer-stats i {
    margin-right: 4px;
}

/* Responsividade */
@media (max-width: 1200px) {
    .fd-sidebar {
        width: 240px;
    }

    .fd-properties {
        width: 260px;
    }
}

@media (max-width: 992px) {
    .fd-body {
        flex-direction: column;
    }

    .fd-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .fd-properties {
        width: 100%;
        max-height: 250px;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .fd-field-categories {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .fd-category {
        flex: 1;
        min-width: 150px;
    }
}

/* Scrollbar customizada */
.fd-sidebar::-webkit-scrollbar,
.fd-canvas::-webkit-scrollbar,
.fd-properties-content::-webkit-scrollbar,
.fd-preview-body::-webkit-scrollbar {
    width: 8px;
}

.fd-sidebar::-webkit-scrollbar-track,
.fd-canvas::-webkit-scrollbar-track,
.fd-properties-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.fd-sidebar::-webkit-scrollbar-thumb,
.fd-canvas::-webkit-scrollbar-thumb,
.fd-properties-content::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 4px;
}

.fd-sidebar::-webkit-scrollbar-thumb:hover,
.fd-canvas::-webkit-scrollbar-thumb:hover,
.fd-properties-content::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}
