/* JSON Array Builder Component Styles */

.json-array-builder {
    width: 100%;
}

/* Main container with editor and controls side by side */
.json-array-main {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

/* Mode toggle controls - positioned on the right */
.json-array-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background-color: var(--adf-tertiary-bg, #f8f9fa);
    border: 1px solid var(--adf-border-light, #dee2e6);
    border-radius: 6px;
    padding: 4px;
    flex-shrink: 0;
}

.json-array-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    background-color: transparent;
    border: none;
    border-radius: 4px;
    color: var(--adf-text-secondary, #6c757d);
    cursor: pointer;
    transition: all 0.15s ease;
}

.json-array-mode-toggle:hover:not(:disabled) {
    background-color: var(--adf-secondary-bg, #ffffff);
    color: var(--adf-text-primary, #212529);
}

.json-array-mode-toggle.active {
    background-color: var(--adf-primary-color, #0d6efd);
    color: white;
}

.json-array-mode-toggle:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.json-array-mode-toggle i {
    font-size: 13px;
}

/* Horizontal wrapper for cards */
.json-array-items-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
    flex: 1;
}

/* Individual item cards with inline editing */
.json-array-card {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--adf-secondary-bg, #ffffff);
    border: 1px solid var(--adf-border-light, #dee2e6);
    border-radius: 6px;
    padding: 6px 8px;
    transition: all 0.2s ease;
}

.json-array-card:hover {
    border-color: var(--adf-border-medium, #adb5bd);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Card inputs container */
.json-array-card-inputs {
    display: flex;
    gap: 6px;
}

/* Inline inputs */
.json-array-input {
    border: 1px solid var(--adf-border-light, #dee2e6);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    background-color: var(--adf-primary-bg, #ffffff);
    color: var(--adf-text-primary, #212529);
    transition: border-color 0.15s ease;
}

.json-array-input:focus {
    outline: none;
    border-color: var(--adf-primary-color, #0d6efd);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.1);
}

.json-array-input:disabled {
    background-color: var(--adf-tertiary-bg, #e9ecef);
    cursor: not-allowed;
    opacity: 0.6;
}

.json-array-input-key {
    width: 100px;
    font-weight: 500;
}

.json-array-input-value {
    width: 120px;
}

.json-array-input::placeholder {
    color: var(--adf-text-muted, #adb5bd);
    font-size: 12px;
}

/* Remove button inside card */
.json-array-remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: transparent;
    border: none;
    border-radius: 4px;
    color: var(--adf-text-secondary, #6c757d);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    flex-shrink: 0;
}

.json-array-remove-btn:hover:not(:disabled) {
    background-color: var(--adf-danger-bg-subtle, #f8d7da);
    color: var(--adf-danger-color, #dc3545);
}

.json-array-remove-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.json-array-remove-btn i {
    font-size: 12px;
}

/* Add button */
.json-array-add-card {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 36px;
    background-color: transparent;
    border: 1px dashed var(--adf-border-medium, #adb5bd);
    border-radius: 6px;
    color: var(--adf-text-secondary, #6c757d);
    cursor: pointer;
    transition: all 0.2s ease;
}

.json-array-add-card:hover:not(:disabled) {
    border-color: var(--adf-primary-color, #0d6efd);
    border-style: solid;
    color: var(--adf-primary-color, #0d6efd);
    background-color: var(--adf-primary-bg-subtle, #cfe2ff);
}

.json-array-add-card:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.json-array-add-card i {
    font-size: 14px;
}

/* Preview button (icon only) */
.json-array-preview-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 36px;
    background-color: var(--adf-tertiary-bg, #f8f9fa);
    border: 1px solid var(--adf-border-light, #dee2e6);
    border-radius: 6px;
    color: var(--adf-text-primary, #212529);
    cursor: pointer;
    transition: all 0.2s ease;
}

.json-array-preview-btn:hover:not(:disabled) {
    border-color: var(--adf-info-color, #0dcaf0);
    color: var(--adf-info-color, #0dcaf0);
    background-color: var(--adf-info-bg-subtle, #cff4fc);
}

.json-array-preview-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.json-array-preview-btn i {
    font-size: 14px;
}

/* Text editor mode */
.json-array-text-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.json-array-textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px 12px;
    border: 1px solid var(--adf-border-light, #dee2e6);
    border-radius: 6px;
    background-color: var(--adf-primary-bg, #ffffff);
    color: var(--adf-text-primary, #212529);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.15s ease;
}

.json-array-textarea:focus {
    outline: none;
    border-color: var(--adf-primary-color, #0d6efd);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.json-array-textarea:disabled {
    background-color: var(--adf-tertiary-bg, #e9ecef);
    cursor: not-allowed;
    opacity: 0.6;
}

.json-array-textarea::placeholder {
    color: var(--adf-text-muted, #adb5bd);
}

.json-array-text-error {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background-color: var(--adf-danger-bg-subtle, #f8d7da);
    border: 1px solid var(--adf-danger-border, #f5c2c7);
    border-radius: 4px;
    color: var(--adf-danger-color, #842029);
    font-size: 13px;
}

.json-array-text-error i {
    flex-shrink: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .json-array-main {
        flex-direction: column-reverse;
    }

    .json-array-input-key {
        width: 80px;
    }

    .json-array-input-value {
        width: 100px;
    }
}

/* Empty state */
.json-array-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: var(--adf-text-muted, #6c757d);
    background-color: var(--adf-tertiary-bg, #f8f9fa);
    border: 1px solid var(--adf-border-light, #dee2e6);
    border-radius: 6px;
    width: 100%;
}

.json-array-empty i {
    color: var(--adf-text-muted, #adb5bd);
}

/* Preview panel */
.json-array-preview {
    background-color: var(--adf-secondary-bg, #ffffff);
    border: 1px solid var(--adf-border-light, #dee2e6);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 12px;
}

.json-array-preview-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background-color: var(--adf-tertiary-bg, #f8f9fa);
    border-bottom: 1px solid var(--adf-border-light, #dee2e6);
    font-size: 13px;
}

.json-array-preview-content {
    margin: 0;
    padding: 12px;
    background-color: var(--adf-code-bg, #f8f9fa);
    border: none;
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    max-height: 200px;
    overflow: auto;
    color: var(--adf-text-primary, #212529);
}

.json-array-preview-content code {
    color: inherit;
    background: none;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .json-array-controls {
        background-color: var(--adf-tertiary-bg, #2d2d2d);
        border-color: var(--adf-border-light, #404040);
    }

    .json-array-mode-toggle:hover:not(:disabled) {
        background-color: var(--adf-secondary-bg, #1e1e1e);
    }

    .json-array-card {
        background-color: var(--adf-secondary-bg, #1e1e1e);
        border-color: var(--adf-border-light, #404040);
    }

    .json-array-input {
        background-color: var(--adf-primary-bg, #2d2d2d);
        border-color: var(--adf-border-light, #404040);
        color: var(--adf-text-primary, #e0e0e0);
    }

    .json-array-input:focus {
        border-color: var(--adf-primary-color, #0d6efd);
    }

    .json-array-textarea {
        background-color: var(--adf-primary-bg, #2d2d2d);
        border-color: var(--adf-border-light, #404040);
        color: var(--adf-text-primary, #e0e0e0);
    }

    .json-array-textarea:focus {
        border-color: var(--adf-primary-color, #0d6efd);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .json-array-main {
        flex-direction: column-reverse;
    }

    .json-array-controls {
        flex-direction: row;
        width: fit-content;
    }

    .json-array-input-key {
        width: 80px;
    }

    .json-array-input-value {
        width: 100px;
    }
}
