/* ============================================
   Form Element Styles
   ============================================ */

.form-control, .form-select {
    border-radius: var(--ias-radius);
    border-color: var(--ias-border);
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color var(--ias-transition);
    background-color: var(--ias-bg-surface);
    color: var(--ias-text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--ias-border-focus);
    box-shadow: 0 0 0 3px var(--ias-primary-light);
    background-color: var(--ias-bg-surface);
}

.form-label {
    font-weight: 500;
    color: var(--ias-text-secondary);
    font-size: 0.8125rem;
    margin-bottom: 0.375rem;
}

/* ============================================
   Search Bar
   ============================================ */

.search-bar {
    display: flex;
    align-items: center;
    background: var(--ias-bg-surface);
    border: 2px solid var(--ias-primary);
    border-radius: var(--ias-radius-lg);
    transition: all var(--ias-transition);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    margin-bottom: 1rem;
}

.search-bar:focus-within {
    border-color: var(--ias-primary);
    box-shadow: 0 0 0 3px var(--ias-primary-light), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.search-bar .search-icon,
.search-bar > i {
    color: var(--ias-primary);
    padding: 0.75rem 1rem;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.75rem 0;
    font-size: 0.875rem;
    min-width: 0;
}

.search-bar input:focus {
    box-shadow: none;
    outline: none;
}

.search-bar .clear-btn {
    color: var(--ias-text-muted);
    padding: 0.75rem 1rem;
    transition: color var(--ias-transition-fast);
}

.search-bar .clear-btn:hover {
    color: var(--ias-text-primary);
}

/* ============================================
   Status Filter Dropdown
   ============================================ */

.status-filter-dropdown {
    position: relative;
}

.status-filter-dropdown .form-select {
    cursor: pointer;
    height: auto;
    min-height: calc(1.5em + 0.75rem + 2px);
}

.status-filter-dropdown .dropdown-menu {
    border: 1px solid var(--ias-border);
    border-radius: var(--ias-radius-md, 0.375rem);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    padding: 0.25rem 0;
    z-index: 1050;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 2px;
}

.status-filter-dropdown .dropdown-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.status-filter-dropdown .dropdown-item:hover {
    background-color: var(--ias-primary-light, #f0f4ff);
}

.status-filter-dropdown .dropdown-item.active {
    background-color: var(--ias-primary-light, #e8f0fe);
    font-weight: 500;
}

/* ============================================
   Form Sections
   ============================================ */

.form-section {
    background: var(--ias-bg-surface);
    border-radius: var(--ias-radius-lg);
    border: 1px solid var(--ias-border);
    margin-bottom: 1.5rem;
}

.form-section .section-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--ias-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.form-section .section-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--ias-radius);
    background: var(--ias-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ias-primary);
}

.form-section .section-title {
    font-weight: 600;
    margin: 0;
}

.form-section .section-body {
    padding: 1.25rem;
}

/* ============================================
   Step Editor
   ============================================ */

.step-editor {
    background: var(--ias-bg-muted);
    border-radius: var(--ias-radius-lg);
    padding: 1.5rem;
}

.step-editor .step-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.step-editor .step-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--ias-bg-surface);
    padding: 1rem;
    border-radius: var(--ias-radius);
    border: 1px solid var(--ias-border);
    transition: all 0.15s ease;
}

.step-editor .step-row:hover {
    border-color: var(--ias-primary);
    box-shadow: var(--ias-shadow-sm);
}

.step-editor .step-row.dragging {
    opacity: 0.5;
    border-color: var(--ias-primary);
    border-style: dashed;
}

.step-editor .drag-handle {
    cursor: grab;
    color: var(--ias-text-muted);
    padding: 0.25rem;
}

.step-editor .drag-handle:hover {
    color: var(--ias-text-secondary);
}

.step-editor .step-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ias-primary);
    color: white;
    border-radius: 50%;
    font-weight: 600;
    flex-shrink: 0;
}

.step-editor .step-fields {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.step-editor .step-actions {
    display: flex;
    gap: 0.25rem;
}

.step-editor .add-step-btn {
    width: 100%;
    padding: 0.75rem;
    border: 2px dashed var(--ias-border);
    background: transparent;
    border-radius: var(--ias-radius);
    color: var(--ias-text-secondary);
    font-weight: 500;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.step-editor .add-step-btn:hover {
    border-color: var(--ias-primary);
    color: var(--ias-primary);
    background: var(--ias-primary-light);
}

/* ============================================
   Profile Info
   ============================================ */

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.profile-row {
    display: flex;
    align-items: flex-start;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--ias-border-light);
}

.profile-row:last-child {
    border-bottom: none;
}

.profile-label {
    flex: 0 0 140px;
    font-size: 0.8125rem;
    color: var(--ias-text-muted);
    font-weight: 500;
}

.profile-value {
    flex: 1;
    font-weight: 500;
    color: var(--ias-text-primary);
}

.current-backup-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--ias-info-light);
    border-radius: var(--ias-radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.current-backup-info i {
    color: var(--ias-info);
}

/* ============================================
   Modal Styles
   ============================================ */

.modal-content {
    background-color: var(--ias-bg-surface);
    border: 1px solid var(--ias-border);
    color: var(--ias-text-primary);
}

.modal-header {
    border-bottom-color: var(--ias-border);
}

.modal-footer {
    border-top-color: var(--ias-border);
}

.modal-body {
    color: var(--ias-text-primary);
}

.modal-body strong {
    color: var(--ias-text-primary);
}

.modal-body code {
    background: var(--ias-bg-muted);
    color: var(--ias-primary);
    padding: 0.125rem 0.375rem;
    border-radius: var(--ias-radius-sm);
}

/* Code block for JSON/pre content in modals */
.code-block {
    background: var(--ias-bg-muted);
    color: var(--ias-text-primary);
    border: 1px solid var(--ias-border);
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Fix close button visibility in dark mode */
.modal-header .btn-close {
    filter: var(--ias-btn-close-filter, none);
}

[data-theme="dark"] .modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Also fix for btn-close-white in dark headers */
.btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ============================================
   Form Responsive Styles
   ============================================ */

@media (max-width: 767.98px) {
    .step-editor .step-fields {
        grid-template-columns: 1fr;
    }

    .step-editor .step-row {
        flex-direction: column;
        align-items: stretch;
    }

    .step-editor .step-number {
        align-self: flex-start;
    }

    .form-control,
    .form-select {
        padding: 0.5rem 0.75rem;
    }
}
