/**
 * DBForge Studio - SQL Editor & Bottom Panel Styles
 * VS Code style bottom dock, tabs, live SQL viewer, and linter issues.
 */

#bottom-panel-container {
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  height: 240px;
  min-height: 38px;
  max-height: 450px;
  z-index: 25;
  transition: height 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#bottom-panel.collapsed {
  height: 38px !important;
}

.bottom-panel-header {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--border-color);
  user-select: none;
}

.bottom-tabs-group {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.bottom-tabs-group::-webkit-scrollbar {
  display: none;
}

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

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

.bottom-tab-btn.active {
  color: var(--text-primary);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.badge-count {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 700;
}

.badge-count.clean {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-count.warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-count.danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.bottom-controls-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bottom-ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Tab Panes */
.bottom-panel-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.bottom-tab-pane {
  display: none;
  width: 100%;
  height: 100%;
  overflow: auto;
}

.bottom-tab-pane.active {
  display: flex;
  flex-direction: column;
}

/* Live SQL Tab */
.sql-tab-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sql-toolbar {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-muted);
}

.sql-toolbar-left, .sql-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sql-tool-btn {
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.sql-tool-btn:hover {
  background: var(--bg-surface-hover);
}

.sql-editor-container {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

#monaco-editor-container {
  width: 100%;
  height: 100%;
  display: none;
}

#sql-fallback-textarea {
  width: 100%;
  height: 100%;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  border: none;
  outline: none;
  background: var(--bg-surface);
  color: var(--text-primary);
  resize: none;
  white-space: pre;
}

/* Linter Problems Tab */
#bottom-problems-list {
  padding: 8px 12px;
  overflow-y: auto;
}

.problem-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 4px;
  background: var(--bg-surface-secondary);
  border-left: 3px solid transparent;
}

.problem-item.problem-warning {
  border-left-color: var(--color-warning);
}

.problem-item.problem-error {
  border-left-color: var(--color-danger);
}

.problem-message {
  flex: 1;
}

.btn-problem-goto {
  padding: 2px 8px;
  font-size: 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  cursor: pointer;
}

.btn-problem-goto:hover {
  background: var(--accent-subtle);
}

.panel-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  font-size: 12px;
  color: var(--color-success);
  font-weight: 500;
}

/* Console Logs Tab */
#bottom-console-logs {
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-y: auto;
}

.console-row {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid var(--bg-surface-secondary);
}

.log-time { color: var(--text-tertiary); }
.console-info .log-type { color: var(--accent-primary); }
.console-success .log-type { color: var(--color-success); }
.console-warning .log-type { color: var(--color-warning); }
.console-error .log-type { color: var(--color-danger); }
.log-msg { color: var(--text-primary); flex: 1; }

/* History Tab */
#bottom-history-list {
  padding: 8px 12px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  background: var(--bg-surface-secondary);
}

.history-item.current {
  border-left: 3px solid var(--accent-primary);
  background: var(--accent-subtle);
}

.history-idx {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-secondary);
}

.history-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--accent-primary);
  color: #fff;
}

/* ========================================================== */
/* EDITOR & BOTTOM PANEL MOBILE RESPONSIVE                    */
/* ========================================================== */
@media (max-width: 600px) {
  /* Bottom Panel Tabs */
  .bottom-tab-btn {
    height: 34px;
    padding: 0 8px;
    font-size: 11px;
    gap: 4px;
  }

  .bottom-tab-btn svg {
    width: 11px;
    height: 11px;
  }

  /* SQL Toolbar - Stack on mobile */
  .sql-toolbar {
    height: auto;
    flex-direction: column;
    padding: 6px 10px;
    gap: 6px;
    align-items: stretch;
  }

  .sql-toolbar-left,
  .sql-toolbar-right {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 4px;
  }

  .sql-tool-btn {
    height: 28px;
    font-size: 10px;
    padding: 0 6px;
    white-space: nowrap;
  }

  .sql-tool-btn svg {
    width: 10px;
    height: 10px;
  }

  /* Fallback textarea */
  #sql-fallback-textarea {
    font-size: 13px;
    padding: 8px 10px;
    line-height: 1.5;
  }

  /* Problem Items */
  .problem-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 10px;
  }

  .btn-problem-goto {
    align-self: flex-end;
    height: 28px;
    padding: 0 10px;
    font-size: 11px;
  }

  /* History Items */
  .history-item {
    padding: 8px 10px;
    font-size: 11px;
    gap: 6px;
  }

  /* Console */
  .console-row {
    font-size: 10px;
    flex-wrap: wrap;
  }
}

