/* ============================================================
   ADMIN PANEL
   ============================================================ */

/* ── Tabs ───────────────────────────────────────────── */

.admin-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px;
    margin-bottom: 24px;
    width: fit-content;
    box-shadow: var(--shadow-xs);
}

.admin-tab {
    padding: 10px 18px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.admin-tab:hover { background: var(--bg-hover); color: var(--text-primary); }

.admin-tab.active {
    background: var(--bg-white);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; }

/* ── Cards ──────────────────────────────────────────── */

.admin-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
}

.admin-card h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}

.admin-card h3 span {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 8px;
    letter-spacing: 0;
}

/* ── List items ─────────────────────────────────────── */

.admin-list { display: flex; flex-direction: column; gap: 10px; }

.admin-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    gap: 16px;
    box-shadow: var(--shadow-xs);
    flex-wrap: wrap;
}

.admin-list-item-info { flex: 1; min-width: 0; }

.admin-list-item-info h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.admin-list-item-info p {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-list-item-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Buttons (admin-specific sizes) ─────────────────── */

.btn-sm {
    padding: 7px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn-primary.btn-sm {
    padding: 10px 18px;
    font-size: 14px;
    width: auto;
}

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.btn-danger:hover { background: #dc2626; color: white; border-color: #dc2626; }

.btn-warning {
    background: #fef3c7;
    color: #d97706;
    border: 1px solid #fde68a;
}

.btn-warning:hover { background: #d97706; color: white; border-color: #d97706; }

/* ── Forms ──────────────────────────────────────────── */

.admin-form { display: flex; flex-direction: column; gap: 16px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.form-hint code { font-family: inherit; font-size: inherit; background: none; }
.form-hint-inline { font-size: 11px; color: var(--text-muted); font-weight: normal; margin-left: 4px; }

.form-actions { display: flex; gap: 12px; margin-top: 8px; }

/* ── Toolbar ────────────────────────────────────────── */

.admin-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
    gap: 10px;
}

/* ── Tags / badges ──────────────────────────────────── */

.status-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.status-tag.ready   { background: #dcfce7; color: #16a34a; }
.status-tag.error   { background: #fee2e2; color: #dc2626; }
.status-tag.pending { background: #fef9c3; color: #ca8a04; }

.indexing-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: #eff6ff;
    color: #2563eb;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
}

/* ── Wizard ─────────────────────────────────────────── */

.wizard-steps {
    display: flex;
    align-items: center;
    margin-bottom: 32px;
    gap: 0;
    overflow-x: auto;
    padding-bottom: 4px;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.wizard-step-circle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 2px solid var(--border);
    transition: all var(--transition-normal);
}

.wizard-step.active .wizard-step-circle {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.wizard-step.completed .wizard-step-circle {
    background: #16a34a;
    color: #fff;
    border-color: #16a34a;
}

.wizard-step-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    max-width: 80px;
    white-space: nowrap;
}

.wizard-step.active .wizard-step-label { color: var(--accent-primary); font-weight: 600; }
.wizard-step.completed .wizard-step-label { color: #16a34a; }

.wizard-connector {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 4px;
    margin-bottom: 24px;
    min-width: 20px;
    transition: background var(--transition-normal);
}

.wizard-connector.completed { background: #16a34a; }

.wizard-panel { display: none; }
.wizard-panel.active { display: block; }

/* ── Table selector (wizard) ────────────────────────── */

.table-selector-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    gap: 10px;
    cursor: default;
    transition: all var(--transition-fast);
    user-select: none;
}

.table-selector-row .btn-secondary {
    white-space: nowrap;
}

.table-selector-row select {
    flex: 1;
    min-width: 0;
    padding: 10px 36px 10px 14px;
    background: var(--bg-white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
}

.table-selector-row select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.table-selector-row select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background-color: var(--bg-tertiary);
}

.selected-tables-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.selected-table-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--accent-light);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: var(--radius-full);
    font-size: 13px;
    color: var(--accent-primary);
    font-weight: 500;
}

.selected-table-tag button {
    background: none;
    border: none;
    color: var(--accent-primary);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 0 0 2px;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.selected-table-tag button:hover { opacity: 1; }

/* ── Dictionary / file upload ───────────────────────── */

.dict-upload-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 8px;
}

.custom-file-input {
    flex: 1;
    min-width: 0;
    min-height: 42px;
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-white);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.custom-file-input:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.file-pick-btn {
    padding: 0 14px;
    background: var(--bg-secondary);
    border: none;
    border-right: 1.5px solid var(--border);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--text-secondary);
    font-family: inherit;
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.file-pick-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.file-name-label {
    flex: 1;
    padding: 0 12px;
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.label-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.label-action-row label { margin-bottom: 0; }

/* ── AI Action Buttons ──────────────────────────────── */

.btn-ai {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
    color: #7c3aed;
    border: 1px solid #c4b5fd;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.btn-ai:hover {
    background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 100%);
    border-color: #7c3aed;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.18);
    transform: translateY(-1px);
}

.btn-ai:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.dict-preview {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    max-height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Review section ─────────────────────────────────── */

.review-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-bottom: 16px;
}

.review-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.review-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.review-row:last-child { border-bottom: none; padding-bottom: 0; }

.review-row .label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 120px;
}

.review-row .value {
    font-size: 13px;
    color: var(--text-primary);
    text-align: right;
    word-break: break-word;
}

/* ── Context access chips (user form) ───────────────── */

.ctx-access-group { display: flex; flex-wrap: wrap; gap: 8px; }

.ctx-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    user-select: none;
}

.ctx-chip.selected {
    border-color: var(--accent-primary);
    background: var(--accent-light);
    color: var(--accent-primary);
    font-weight: 600;
}

.ctx-chip:hover { border-color: rgba(37, 99, 235, 0.3); background: var(--accent-light); }

/* ── Connection Cards ───────────────────────────────── */

.conn-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.conn-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: rgba(15, 23, 42, 0.10);
}

.conn-card-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    color: #fff;
    text-transform: uppercase;
}

.conn-icon-pg      { background: #2563eb; }
.conn-icon-mysql   { background: #e07b2a; }
.conn-icon-mssql   { background: #2d6a9f; }
.conn-icon-oracle  { background: #ef4444; }
.conn-icon-mongo   { background: #00a651; }
.conn-icon-default { background: #64748b; }

.conn-card-body { flex: 1; min-width: 0; }

.conn-card-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 7px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conn-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.conn-db-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    background: var(--accent-light);
    color: var(--accent-primary);
    flex-shrink: 0;
}

.conn-meta-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.5;
}

.conn-card-host {
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 2px 9px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.conn-card-user {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.conn-card-user strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.conn-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* ── Context List Cards ─────────────────────────────── */

.ctx-list-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.ctx-list-card:hover {
    box-shadow: var(--shadow-sm);
}

.ctx-list-card.ctx-status-ready    { border-left-color: #16a34a; }
.ctx-list-card.ctx-status-error    { border-left-color: var(--error); }
.ctx-list-card.ctx-status-indexing { border-left-color: var(--warning); }
.ctx-list-card.ctx-status-pending  { border-left-color: var(--text-muted); }

.ctx-list-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    flex-shrink: 0;
}

.ctx-icon-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
}
.ctx-icon-sql  { background: var(--accent-primary); color: #fff; }
.ctx-icon-file { background: #0891b2; color: #fff; }
.ctx-icon-mix  { background: linear-gradient(135deg, var(--accent-primary) 50%, #0891b2 50%); color: #fff; }
.ctx-icon-builtin { background: #475569; color: #fff; }

.ctx-list-body { flex: 1; min-width: 0; }

.ctx-list-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 7px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ctx-list-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ctx-tables-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.ctx-list-date {
    font-size: 12px;
    color: var(--text-muted);
}

.ctx-list-error {
    margin-top: 6px;
    font-size: 12px;
    color: var(--error);
    font-weight: 500;
}

.ctx-list-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.ctx-list-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.examples-modal-textarea {
    min-height: 220px;
    resize: vertical;
    line-height: 1.5;
    padding-top: 12px;
}

/* ── MongoDB / connection form extras ──────────────────── */

.form-hint-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 13px;
    color: #1e40af;
    line-height: 1.5;
    margin-bottom: 4px;
}

.form-hint-box code {
    background: #dbeafe;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 12px;
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

.label-hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

.mongo-badge {
    display: inline-block;
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Source-type toggle (Connection vs File) ────────── */

.source-type-toggle {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.source-type-btn {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
    text-align: center;
}

.source-type-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.source-type-btn.active {
    border-color: var(--accent-primary);
    background: #eff6ff;
    color: var(--accent-primary);
    font-weight: 600;
}

/* ── Data file upload zone ──────────────────────────── */

.file-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    background: var(--bg-secondary);
}

.file-upload-zone.file-upload-zone-inline {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    text-align: left;
    font-size: 13px;
    color: var(--text-secondary);
}

.file-upload-zone.file-upload-zone-inline .file-upload-types {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
    white-space: nowrap;
}

.file-upload-zone:hover,
.file-upload-zone.drag-over {
    border-color: var(--accent-primary);
    background: #eff6ff;
}

.file-upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.file-upload-hint {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.file-upload-types {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.file-selected-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1.5px solid #86efac;
    border-radius: var(--radius-sm);
    background: #f0fdf4;
    margin-top: 8px;
}

.file-info-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.file-info-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: #15803d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-info-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    padding: 2px 4px;
    border-radius: 4px;
    flex-shrink: 0;
    font-family: inherit;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.file-info-remove:hover {
    color: var(--error);
    background: #fee2e2;
}

/* ── Toggle Switch ──────────────────────────────────── */

.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 22px;
    transition: background var(--transition-normal);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition-normal);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary, #6366f1);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}
