/**
 * Form Builder Admin Styles
 *
 * @package ComplySpec_Accessible
 * @since 1.5.0
 */

/* ========================================
   FORM BUILDER INTERFACE
   ======================================== */

.cs-form-builder-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.cs-form-builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #e9ecef;
}

.cs-form-builder-title {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.cs-form-builder-actions {
    display: flex;
    gap: 1rem;
}

.cs-form-builder-btn {
    padding: 0.75rem 1.5rem;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cs-form-builder-btn:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.cs-form-builder-btn i {
    font-size: 1rem;
}

/* ========================================
   FORM BUILDER LAYOUT
   ======================================== */

.cs-form-builder-layout {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 2rem;
    min-height: 600px;
}

/* Field Palette */
.cs-field-palette {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.cs-palette-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #333;
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cs-field-type-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cs-field-type-item {
    padding: 0.875rem 1rem;
    background: #f8f9fa;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cs-field-type-item:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateX(4px);
}

.cs-field-type-item:active {
    cursor: grabbing;
}

.cs-field-type-icon {
    font-size: 1.25rem;
    color: #667eea;
}

.cs-field-type-name {
    font-weight: 600;
    color: #333;
    font-size: 0.875rem;
}

/* Form Canvas */
.cs-form-canvas {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 2rem;
    min-height: 600px;
}

.cs-form-canvas-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    border: 3px dashed #cbd5e1;
    border-radius: 12px;
    color: #6c757d;
    text-align: center;
}

.cs-form-canvas-empty i {
    font-size: 4rem;
    color: #cbd5e1;
    margin-bottom: 1rem;
}

.cs-form-canvas-empty p {
    font-size: 1.125rem;
    margin: 0;
}

.cs-form-fields-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cs-form-field-item {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    position: relative;
    transition: all 0.3s ease;
}

.cs-form-field-item:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.cs-form-field-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.cs-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.cs-field-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cs-field-drag-handle {
    cursor: grab;
    color: #6c757d;
    font-size: 1.25rem;
}

.cs-field-drag-handle:active {
    cursor: grabbing;
}

.cs-field-label {
    font-weight: 700;
    color: #333;
    font-size: 1rem;
}

.cs-field-required {
    color: #dc3545;
    font-weight: 700;
}

.cs-field-actions {
    display: flex;
    gap: 0.5rem;
}

.cs-field-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: #fff;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cs-field-action-btn:hover {
    background: #667eea;
    color: #fff;
}

.cs-field-action-btn.delete:hover {
    background: #dc3545;
}

.cs-field-preview {
    margin-top: 1rem;
}

.cs-field-preview input,
.cs-field-preview textarea,
.cs-field-preview select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.cs-field-preview input:focus,
.cs-field-preview textarea:focus,
.cs-field-preview select:focus {
    outline: none;
    border-color: #667eea;
}

/* Settings Panel */
.cs-settings-panel {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.cs-settings-panel-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #333;
    margin: 0 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cs-settings-group {
    margin-bottom: 1.5rem;
}

.cs-settings-group:last-child {
    margin-bottom: 0;
}

.cs-settings-label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.cs-settings-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.3s ease;
}

.cs-settings-input:focus {
    outline: none;
    border-color: #667eea;
}

.cs-settings-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cs-settings-checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.cs-settings-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.875rem;
    background: #fff;
    cursor: pointer;
}

.cs-settings-help {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* ========================================
   FORM SUBMISSIONS TABLE
   ======================================== */

.cs-submissions-wrapper {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
}

.cs-submissions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.cs-submissions-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.cs-submissions-stats {
    display: flex;
    gap: 2rem;
}

.cs-stat-item {
    text-align: center;
}

.cs-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    display: block;
}

.cs-stat-label {
    font-size: 0.875rem;
    color: #6c757d;
}

.cs-submissions-table {
    width: 100%;
    border-collapse: collapse;
}

.cs-submissions-table thead {
    background: #f8f9fa;
}

.cs-submissions-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 700;
    color: #333;
    border-bottom: 2px solid #e9ecef;
}

.cs-submissions-table td {
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.cs-submissions-table tr:hover {
    background: #f8f9fa;
}

.cs-submission-actions {
    display: flex;
    gap: 0.5rem;
}

.cs-submission-view-btn,
.cs-submission-delete-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.cs-submission-view-btn {
    background: #667eea;
    color: #fff;
}

.cs-submission-view-btn:hover {
    background: #5568d3;
}

.cs-submission-delete-btn {
    background: #dc3545;
    color: #fff;
}

.cs-submission-delete-btn:hover {
    background: #c82333;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1200px) {
    .cs-form-builder-layout {
        grid-template-columns: 1fr;
    }

    .cs-field-palette,
    .cs-settings-panel {
        position: static;
    }
}

@media (max-width: 768px) {
    .cs-form-builder-wrapper {
        padding: 1rem;
    }

    .cs-form-builder-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .cs-form-builder-actions {
        width: 100%;
        flex-direction: column;
    }

    .cs-form-builder-btn {
        width: 100%;
        justify-content: center;
    }

    .cs-submissions-stats {
        width: 100%;
        flex-direction: column;
        gap: 1rem;
    }

    .cs-submissions-table {
        display: block;
        overflow-x: auto;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cs-form-field-item {
    animation: slideIn 0.3s ease-out;
}

/* ========================================
   DRAG AND DROP STATES
   ======================================== */

.cs-form-canvas.drag-over {
    background: #f0f4ff;
    border-color: #667eea;
}

.cs-field-drop-zone {
    height: 4px;
    background: #667eea;
    border-radius: 2px;
    margin: 0.5rem 0;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cs-field-drop-zone.active {
    opacity: 1;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.cs-field-type-item:focus-visible,
.cs-field-action-btn:focus-visible,
.cs-form-builder-btn:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
