/**
 * DBForge Studio - Components & Modals Styles
 * Modals, Table Editor, AI chat & diffs, Command Palette, and Toasts.
 */

/* --- Modals Base --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 20, 25, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  width: 90%;
  max-width: 680px;
  max-height: 88vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(10px);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-card.wide {
  max-width: 880px;
}

.modal-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-secondary);
}

.modal-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface-secondary);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* --- Modal Tabs Header --- */
.modal-tabs-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 16px;
  background: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.modal-tab-btn {
  height: 36px;
  padding: 0 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

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

.modal-tab-btn.active {
  color: var(--accent-primary);
  background: var(--bg-surface);
  border-bottom-color: var(--accent-primary);
}

/* Quick Snippets Bar */
.quick-snippets-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-surface-secondary);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}

.snippets-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.btn-snippet {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-snippet:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-subtle);
}

/* Reorder and Mini Buttons */
.col-reorder-btns {
  display: flex;
  gap: 2px;
  align-items: center;
}

.btn-mini {
  width: 20px;
  height: 20px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn-mini:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--bg-surface-hover);
}

/* Card rows for Indexes & Foreign Keys */
.item-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 12px;
}

.item-card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-card-title {
  font-weight: 700;
  color: var(--text-primary);
}

.item-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

/* --- Table Editor Modal --- */
.editor-form-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group-row {
  display: flex;
  gap: 12px;
}

.form-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-text, .form-field input[type="text"], .form-field select {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  transition: all 0.12s ease;
}

.input-text:focus, .form-field input[type="text"]:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

.color-palette-swatches {
  display: flex;
  gap: 6px;
  align-items: center;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s ease;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.selected {
  border-color: var(--text-primary);
  transform: scale(1.2);
}

/* Column Rows Builder */
.editor-columns-container {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.editor-columns-header {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.editor-column-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-muted);
}

.editor-column-row:last-child {
  border-bottom: none;
}

.col-drag-handle {
  color: var(--text-tertiary);
  cursor: grab;
  padding: 0 4px;
}

.col-name-field { flex: 2; }
.col-type-field { flex: 1.5; }
.col-len-field { width: 65px; }
.col-default-field { flex: 1.5; }
.col-actions-field { width: 28px; }

.col-input-group input, .col-input-group select {
  width: 100%;
  height: 26px;
  padding: 0 6px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
}

.mobile-col-badge-label {
  display: none;
}

.col-checkbox-group label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: 0 4px;
}

.btn-col-delete {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.btn-col-delete:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

.validation-banner {
  padding: 8px 12px;
  background: var(--color-warning-bg);
  border: 1px solid #d4a72c;
  border-radius: var(--radius-md);
  color: var(--color-warning);
  font-size: 12px;
  display: none;
}

.error-badge {
  margin-bottom: 2px;
}

.sql-preview-box {
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  max-height: 110px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* --- AI Panel --- */
#ai-assistant-panel {
  display: none;
  flex-direction: column;
  height: 100%;
}

.ai-panel-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  gap: 8px;
}

.ai-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
  color: #8250df;
  white-space: nowrap;
}

.ai-status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #57606a;
  display: inline-block;
  transition: all 0.2s ease;
}

.ai-status-indicator.online {
  background: #2da44e;
  box-shadow: 0 0 6px rgba(45, 164, 78, 0.6);
}

.ai-status-indicator.offline {
  background: #cf222e;
}

.ai-header-center {
  flex: 1;
  min-width: 0;
}

.ai-model-select {
  width: 100%;
  height: 24px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.ai-model-select:focus {
  border-color: #8250df;
}

.ai-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-message {
  display: flex;
  gap: 10px;
  font-size: 12px;
  line-height: 1.5;
}

.message-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-color);
}

.message-user .message-avatar {
  background: var(--accent-subtle);
  color: var(--accent-primary);
}

.message-ai .message-avatar {
  background: rgba(130, 80, 223, 0.12);
  color: #8250df;
}

.message-content {
  flex: 1;
  min-width: 0;
  background: var(--bg-surface-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-muted);
  overflow-wrap: break-word;
}

.message-user .message-content {
  background: var(--accent-subtle);
  border-color: rgba(9, 105, 218, 0.2);
  color: var(--text-primary);
}

.message-content code {
  font-family: var(--font-mono);
  background: var(--border-muted);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}

.message-content ul {
  padding-left: 18px;
  margin: 4px 0;
}

.message-content .md-h4 {
  font-weight: 700;
  margin: 6px 0 2px 0;
}

.message-content .md-h3 {
  font-weight: 700;
  font-size: 13px;
  margin: 8px 0 3px 0;
}

.message-content .md-h2 {
  font-weight: 800;
  font-size: 14px;
  margin: 10px 0 4px 0;
}

.message-content pre {
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-x: auto;
  position: relative;
  line-height: 1.4;
}

.message-content pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: var(--text-primary);
  font-size: 11px;
  white-space: pre;
}

.btn-copy-code {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0.8;
  transition: all 0.15s ease;
}

.btn-copy-code:hover {
  opacity: 1;
  background: var(--bg-surface);
  color: #8250df;
  border-color: #8250df;
}

.ai-stream-cursor {
  display: inline-block;
  color: #8250df;
  font-weight: bold;
  animation: cursorBlink 0.7s infinite;
  margin-left: 2px;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Typing animation */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8250df;
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

/* AI Proposed Changes Card */
.ai-proposal-card {
  margin-top: 8px;
  background: var(--bg-surface);
  border: 1px solid #8250df;
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: var(--shadow-sm);
}

.proposal-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.proposal-tag {
  font-size: 9px;
  font-weight: 800;
  color: #8250df;
  letter-spacing: 0.5px;
}

.proposal-title {
  font-weight: 700;
  font-size: 12px;
}

.proposal-diff-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.diff-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  padding: 4px 6px;
  background: var(--bg-surface-secondary);
  border-radius: var(--radius-sm);
}

.diff-badge {
  font-weight: 800;
  font-family: var(--font-mono);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

.badge-add { background: var(--color-success-bg); color: var(--color-success); }
.badge-mod { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-del { background: var(--color-danger-bg); color: var(--color-danger); }

.diff-title { font-weight: 600; }
.diff-detail { color: var(--text-secondary); font-size: 10px; }

.proposal-actions {
  display: flex;
  gap: 6px;
}

.btn-proposal-apply {
  flex: 1;
  height: 28px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  background: var(--color-success);
  color: #fff;
  cursor: pointer;
}

.btn-proposal-reject {
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
}

.ai-proposal-card.applied {
  border-color: var(--color-success);
  opacity: 0.85;
}

/* Prompt Chips */
.ai-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-surface-secondary);
  border-top: 1px solid var(--border-color);
}

.prompt-chip {
  padding: 3px 8px;
  font-size: 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
}

.prompt-chip:hover {
  border-color: #8250df;
  color: #8250df;
  background: rgba(130, 80, 223, 0.06);
}

/* AI Input Bar */
.ai-input-wrapper {
  padding: 10px 14px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
  display: flex;
  gap: 6px;
}

.ai-input-wrapper textarea {
  flex: 1;
  height: 34px;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
  outline: none;
  resize: none;
}

.ai-input-wrapper textarea:focus {
  border-color: #8250df;
  background: var(--bg-surface);
}

.btn-ai-send {
  height: 34px;
  width: 34px;
  border-radius: var(--radius-md);
  border: none;
  background: #8250df;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-ai-send:hover {
  background: #6e3fc9;
}

.btn-ai-stop {
  height: 34px;
  width: 34px;
  border-radius: var(--radius-md);
  border: none;
  background: #cf222e;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-ai-stop:hover {
  background: #a40e26;
}

/* --- Schema Inspector Content --- */
#schema-inspector-panel {
  padding: 16px;
}

.inspector-header {
  margin-bottom: 16px;
}

.inspector-type-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.inspector-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

.inspector-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.inspector-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inspector-color-pill {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.inspector-section {
  margin-bottom: 16px;
}

.inspector-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.inspector-cols-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.inspector-col-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-secondary);
  font-size: 12px;
}

.inspector-col-main {
  display: flex;
  align-items: center;
  gap: 6px;
}

.col-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.tag-toggle-btn {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.1s ease;
}

.tag-toggle-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.tag-toggle-btn.active.pk {
  background: #fff8c5;
  color: #9a6700;
  border-color: #d4a72c;
}

.tag-toggle-btn.active.nn {
  background: var(--border-muted);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.tag-toggle-btn.active.uq {
  background: #fbefff;
  color: #8250df;
  border-color: #8250df;
}

.tag-toggle-btn.active.ai {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: var(--color-success);
}

.badge-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 3px;
  margin-left: 2px;
}

.badge-tag.pk { background: #fff8c5; color: #9a6700; }
.badge-tag.nn { background: var(--border-muted); color: var(--text-secondary); }
.badge-tag.uq { background: #fbefff; color: #8250df; }

.inspector-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.metric-card {
  padding: 10px;
  background: var(--bg-surface-secondary);
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--border-muted);
}

.metric-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

.metric-lbl {
  font-size: 11px;
  color: var(--text-secondary);
}

.inspector-actions, .quick-actions-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-inspector {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-color);
  transition: all 0.12s ease;
}

.btn-inspector.primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.btn-inspector.secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-inspector.danger {
  background: var(--bg-surface);
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.btn-inspector.danger:hover {
  background: var(--color-danger-bg);
}

.inspector-mapping-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: var(--bg-surface-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 12px;
}

.mapping-arrow {
  color: var(--accent-primary);
  font-weight: 700;
  font-size: 14px;
}

.mapping-side {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mapping-label {
  font-size: 10px;
  color: var(--text-secondary);
}

.inspector-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.inspector-form-row label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.inspector-select {
  height: 28px;
  padding: 0 6px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* --- Command Palette (Ctrl+K) --- */
#modal-command-palette .modal-card {
  max-width: 580px;
}

.palette-input-wrap {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
}

.palette-search-icon {
  color: #8250df;
  font-size: 16px;
}

.palette-input {
  flex: 1;
  height: 32px;
  font-size: 14px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  outline: none;
}

.palette-results-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}

.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.1s ease;
}

.palette-item.active {
  background: var(--accent-subtle);
  color: var(--accent-primary);
}

.palette-item-main {
  display: flex;
  flex-direction: column;
}

.palette-item-title { font-weight: 600; }
.palette-item-desc { font-size: 11px; color: var(--text-secondary); }

.palette-item-cat {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--border-muted);
  color: var(--text-secondary);
}

/* --- Project Cards in Modal --- */
.projects-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  transition: all 0.15s ease;
}

.project-card.current {
  border-color: var(--accent-primary);
  background: rgba(9, 105, 218, 0.04);
}

.project-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-title { font-weight: 700; font-size: 13px; }
.project-engine-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--border-muted);
}

.project-active-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--color-success-bg);
  color: var(--color-success);
}

.project-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.project-card-actions {
  display: flex;
  gap: 6px;
}

.project-card-actions button {
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.project-card-actions button.danger:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* --- Toast Notifications --- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast-item {
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  transform: translateY(20px);
  opacity: 0;
  animation: toastSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-item.fade-out {
  animation: toastFadeOut 0.2s ease forwards;
}

@keyframes toastSlideIn {
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toastFadeOut {
  to { transform: translateY(10px); opacity: 0; }
}

.toast-success { border-left: 4px solid var(--color-success); }
.toast-success .toast-icon { color: var(--color-success); }
.toast-warning { border-left: 4px solid var(--color-warning); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-error { border-left: 4px solid var(--color-danger); }
.toast-error .toast-icon { color: var(--color-danger); }
.toast-info { border-left: 4px solid var(--accent-primary); }
.toast-info .toast-icon { color: var(--accent-primary); }

.toast-close {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-tertiary);
  cursor: pointer;
  margin-left: 6px;
}

/* Documentation Modal Tables */
.docs-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 12px;
}

.docs-table th, .docs-table td {
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  text-align: left;
}

.docs-table th {
  background: var(--bg-surface-secondary);
}

/* ==========================================================================
   Android & Mobile Optimizations (Oppo Reno 14F, ~360px - 600px screens)
   ========================================================================== */
@media (max-width: 600px) {
  /* Modals as native Android bottom-sheets */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card,
  .modal-card.wide {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh !important;
    height: 92dvh;
    border-radius: 20px 20px 0 0 !important;
    border-bottom: none !important;
    margin: 0 !important;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.2, 0, 0, 1);
  }

  .modal-overlay.active .modal-card {
    transform: translateY(0);
  }

  .modal-header {
    padding: 10px 14px;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
  }

  .modal-tabs-header {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding: 0 10px;
    flex-shrink: 0;
  }

  .modal-tabs-header::-webkit-scrollbar {
    display: none;
  }

  .modal-tab-btn {
    height: 38px;
    padding: 0 10px;
    font-size: 11px;
    white-space: nowrap;
  }

  .modal-body {
    padding: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
  }

  .modal-footer {
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--bg-surface-secondary);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
  }

  .modal-footer button {
    flex: 1;
    height: 38px;
    font-size: 13px;
    font-weight: 600;
  }

  /* Quick Column Snippet Chips */
  .quick-snippets-bar {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding: 6px 8px;
    gap: 6px;
  }

  .quick-snippets-bar::-webkit-scrollbar {
    display: none;
  }

  .snippets-label {
    white-space: nowrap;
    font-size: 10px;
  }

  .btn-snippet {
    white-space: nowrap;
    height: 38px;
    padding: 0 12px;
    font-size: 12px;
    flex-shrink: 0;
  }

  /* Prevent iOS Zoom on Inputs */
  .input-text, .form-field input[type="text"], .form-field select, input, select, textarea {
    font-size: 16px !important;
  }

  /* Hide Desktop Table Header in Mobile Column Builder */
  .editor-columns-header {
    display: none !important;
  }

  /* Transform Column Rows into Stacked Touch Cards */
  .editor-columns-container {
    border: none;
    background: transparent;
    gap: 10px;
    display: flex;
    flex-direction: column;
  }

  .editor-column-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-surface-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }

  .editor-column-row:hover {
    border-color: var(--accent-primary);
  }

  /* Row 1: Reorder buttons, Column Name, and Actions */
  .col-reorder-btns {
    width: auto !important;
    display: flex;
    gap: 2px;
  }

  .col-reorder-btns .btn-mini {
    width: 26px;
    height: 26px;
    font-size: 11px;
  }

  .col-name-field {
    flex: 1 1 140px !important;
  }

  .col-name-field input {
    height: 32px;
    font-size: 13px;
    font-weight: 600;
  }

  .col-actions-field {
    width: auto !important;
    display: flex;
    gap: 4px;
    margin-left: auto;
  }

  .col-actions-field .btn-mini {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  /* Row 2: Type Dropdown & Length */
  .col-type-field {
    flex: 2 1 140px !important;
  }

  .col-type-field select {
    height: 30px;
    font-size: 12px;
    background: var(--bg-surface);
  }

  .col-len-field {
    flex: 1 1 70px !important;
    width: auto !important;
  }

  .col-len-field input {
    height: 30px;
    font-size: 12px;
  }

  /* Row 3: Flags (PK, NN, UQ, AI) styled as touch-friendly badge pills */
  .mobile-col-badge-label {
    display: inline-block !important;
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
  }

  .col-checkbox-group {
    width: auto !important;
    flex: 1 1 calc(25% - 6px);
    min-width: 58px;
    text-align: left !important;
  }

  .col-checkbox-group label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.12s ease;
    min-height: 30px;
    touch-action: manipulation;
  }

  .col-checkbox-group label:has(input:checked) {
    background: var(--accent-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary);
  }

  /* Row 4: Default Value Field */
  .col-default-field {
    flex: 1 1 100% !important;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .col-default-field::before {
    content: 'Default:';
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
  }

  .col-default-field input {
    height: 28px;
    font-size: 12px;
    flex: 1;
  }

  /* Color swatch palette on mobile */
  .color-palette-swatches {
    gap: 8px;
    flex-wrap: wrap;
  }

  .color-swatch {
    width: 24px;
    height: 24px;
  }

  /* AI Assistant Panel on Mobile */
  .ai-chips-container {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding: 4px 0;
  }

  .ai-chips-container::-webkit-scrollbar {
    display: none;
  }

  .prompt-chip {
    white-space: nowrap;
    flex-shrink: 0;
    height: 28px;
    padding: 0 10px;
    font-size: 11px;
  }

  .ai-message {
    max-width: 90%;
  }

  .ai-input-wrapper {
    padding: 8px 10px;
    margin-bottom: max(4px, env(safe-area-inset-bottom, 0px));
  }

  .btn-ai-send {
    width: 32px;
    height: 32px;
  }

  /* Schema Inspector on Mobile */
  .inspector-card {
    padding: 10px 12px;
  }

  .inspector-col-item {
    padding: 8px 10px;
  }

  /* Command Bar (Ctrl+K) on Mobile */
  .command-bar-card {
    width: 96% !important;
    max-height: 80dvh !important;
    top: 10% !important;
  }

  /* Toast Notifications above Mobile Bottom Nav */
  #toast-container {
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    left: 12px;
    align-items: stretch;
  }

  .toast-item {
    font-size: 13px;
    padding: 10px 14px;
  }

  /* Export Modal Grid -> Stack */
  #modal-export .modal-body div[style*="grid-template-columns"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  #modal-export .btn-inspector.secondary {
    height: 44px;
    font-size: 13px;
  }

  /* Import Modal */
  #import-text-input {
    height: 140px !important;
    font-size: 13px !important;
  }

  /* Project Cards */
  .project-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
  }

  .project-card-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .project-card-actions button {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
  }

  /* Form Group Rows -> Stack Vertical */
  .form-group-row {
    flex-direction: column;
    gap: 10px;
  }

  /* Schema Inspector Mobile Refinements */
  .inspector-metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .metric-card {
    padding: 8px;
  }

  .metric-val {
    font-size: 16px;
  }

  .metric-lbl {
    font-size: 10px;
  }

  .inspector-cols-list {
    max-height: 200px;
  }

  .inspector-col-row {
    padding: 6px 8px;
    font-size: 11px;
  }

  .inspector-mapping-box {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    padding: 10px 12px;
  }

  .mapping-arrow {
    transform: rotate(90deg);
    align-self: center;
  }

  /* Item Card Rows (Indexes & FK) */
  .item-card-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
  }

  .item-card-row .project-card-actions,
  .item-card-row > div:last-child {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }

  /* Proposal Cards */
  .ai-proposal-card {
    padding: 10px;
  }

  .proposal-diff-list {
    max-height: 150px;
  }

  .proposal-actions {
    flex-direction: column;
    gap: 6px;
  }

  .btn-proposal-apply,
  .btn-proposal-reject {
    height: 36px;
    font-size: 12px;
  }

  /* Settings Modal */
  #modal-settings .modal-body div[style*="gap: 20px"] {
    flex-direction: column !important;
    gap: 12px !important;
  }

  #modal-settings select,
  #modal-settings input[type="checkbox"] {
    min-height: 36px;
    font-size: 13px;
  }

  /* Docs Modal */
  .docs-table {
    font-size: 11px;
    display: block;
    overflow-x: auto;
  }

  .docs-table th,
  .docs-table td {
    padding: 4px 6px;
    white-space: nowrap;
  }
}

/* ========================================================== */
/* ULTRA-SMALL SCREENS (≤360px, e.g. Galaxy S, older phones)  */
/* ========================================================== */
@media (max-width: 360px) {
  .modal-body {
    padding: 10px;
  }

  .modal-tab-btn {
    font-size: 10px;
    padding: 0 8px;
  }

  .ai-panel-header {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
  }

  .ai-header-left {
    font-size: 12px;
  }

  .ai-model-select {
    font-size: 10px;
  }

  .prompt-chip {
    font-size: 10px;
    padding: 0 8px;
    height: 26px;
  }

  .ai-input-wrapper textarea {
    font-size: 13px;
    padding: 8px;
  }

  .btn-ai-send,
  .btn-ai-stop {
    width: 36px;
    height: 36px;
  }

  .inspector-title {
    font-size: 14px;
  }

  .palette-input {
    font-size: 13px;
  }
}

/* ========================================================== */
/* LANDSCAPE + MOBILE (short height screens)                  */
/* ========================================================== */
@media (max-width: 768px) and (max-height: 500px) {
  .modal-card,
  .modal-card.wide {
    max-height: 96dvh !important;
    height: 96dvh;
    border-radius: 12px 12px 0 0 !important;
  }

  .ai-chips-container {
    padding: 4px 8px;
  }

  .prompt-chip {
    height: 24px;
    font-size: 10px;
  }

  #toast-container {
    bottom: calc(50px + env(safe-area-inset-bottom, 0px));
  }
}


