/* 导入字体 - 必须放在最前面 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

@tailwind base;
@tailwind components;
@tailwind utilities;

/* ============================================
   EasySQL - 简约浅色科技主题
   Clean Light Theme
   ============================================ */

/* ============================================
   基础重置
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ============================================
   CSS 变量
   ============================================ */
:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

/* ============================================
   Body 基础样式
   ============================================ */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #ffffff;
  color: #0f172a;
  overflow: hidden;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* ============================================
   文字选中样式
   ============================================ */
::selection {
  background: rgba(59, 130, 246, 0.2);
  color: #0f172a;
}

/* ============================================
   滚动条 - 极简风格
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* 更细的滚动条 */
.scrollbar-thin::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

/* ============================================
   拖拽区域
   ============================================ */
.drag { -webkit-app-region: drag; }
.no-drag { -webkit-app-region: no-drag; }

/* ============================================
   输入框基础样式
   ============================================ */
input, textarea, select {
  font-family: 'Inter', -apple-system, sans-serif;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  color: #0f172a;
  transition: all 0.15s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input::placeholder, textarea::placeholder {
  color: #64748b;
}

/* ============================================
   按钮样式
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 2px rgba(59, 130, 246, 0.1);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

/* ============================================
   卡片样式
   ============================================ */
.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* ============================================
   数据库磁贴
   ============================================ */
.db-tile {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
}

.db-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.db-tile:active {
  transform: scale(0.98);
}

/* ============================================
   菜单动画
   ============================================ */
.menu {
  animation: menuIn 0.15s ease-out;
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   标签页指示器
   ============================================ */
.tab-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

/* ============================================
   加载动画
   ============================================ */
.loader {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   状态点
   ============================================ */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.status-dot.connected {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.status-dot.disconnected {
  background: #cbd5e1;
}

/* ============================================
   工具提示
   ============================================ */
.tooltip {
  position: relative;
}

.tooltip::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: #1e293b;
  color: white;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s ease;
  z-index: 1000;
}

.tooltip:hover::before {
  opacity: 1;
  visibility: visible;
}

/* ============================================
   焦点样式
   ============================================ */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================
   禁用状态
   ============================================ */
.disabled,
[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================
   Navicat 风格数据表格 - 浅色版
   ============================================ */
.navi-table-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #ffffff;
  outline: none;
  user-select: none;
}

.navi-scroll-container {
  flex: 1;
  overflow: auto;
  position: relative;
}

/* 表头样式 */
.navi-header {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.navi-row-number-header {
  position: sticky;
  left: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.navi-row-number-header:hover {
  background: #f1f5f9;
}

.navi-header-cell {
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-right: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  transition: background 0.1s;
  flex-shrink: 0;
  position: relative;
}

.navi-header-cell:hover {
  background: #f1f5f9;
}

.navi-header-cell.resizing {
  background: #dbeafe;
}

/* 列宽拖动手柄 */
.navi-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
  transition: background 0.15s;
}

.navi-resize-handle:hover,
.navi-header-cell.resizing .navi-resize-handle {
  background: #3b82f6;
}

.navi-resize-handle::after {
  content: '';
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  background: #cbd5e1;
  border-radius: 1px;
  opacity: 0;
  transition: opacity 0.15s;
}

.navi-header-cell:hover .navi-resize-handle::after {
  opacity: 1;
}

.navi-header-cell.resizing .navi-resize-handle::after {
  opacity: 1;
  background: white;
}

.navi-col-name {
  color: #0f172a;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.navi-col-type {
  color: #64748b;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.navi-col-comment {
  color: #22c55e;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 数据体 */
.navi-body {
  position: relative;
  cursor: default;
}

.navi-row {
  display: flex;
  border-bottom: 1px solid #f1f5f9;
}

.navi-row.selected {
  background: rgba(59, 130, 246, 0.08);
}

/* 空白填充行 */
.navi-row.empty-row {
  background: #fcfcfd;
}

.navi-row-number.empty {
  background: #fafafa;
  border-right: 1px solid #e2e8f0;
}

.navi-cell.empty {
  background: transparent;
  border-right: 1px solid #f1f5f9;
}

/* 行号 */
.navi-row-number {
  position: sticky;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  border-right: 1px solid #e2e8f0;
  color: #94a3b8;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  flex-shrink: 0;
}

.navi-row-number:hover {
  background: #f1f5f9;
  color: #64748b;
}

.navi-row-number.selected {
  background: #3b82f6;
  color: #fff;
}

/* 单元格样式 */
.navi-cell {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-right: 1px solid #f1f5f9;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  overflow: hidden;
  flex-shrink: 0;
  cursor: default;
}

.navi-cell:hover {
  background: #f8fafc;
}

/* 单元格值 */
.navi-value {
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.navi-null {
  color: #94a3b8;
  font-style: italic;
  font-size: 11px;
}

.navi-json {
  color: #f59e0b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 单元格编辑输入框 */
.navi-cell-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0 10px;
  margin: 0;
  background: #fff;
  color: #0f172a;
  border: 2px solid #3b82f6;
  outline: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* 日期单元格通用样式 */
.navi-date-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 100%;
}

.navi-date-icon {
  flex-shrink: 0;
  color: #60a5fa;
}

.navi-date-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1e293b;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* 日期编辑状态 - 与未编辑状态保持一致 */
.navi-date-cell-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  position: absolute;
  inset: 0;
  padding: 0 10px;
  background: transparent;
}

.navi-date-input-field {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #1e293b;
  color: #1e293b;
}

.navi-date-input-field::placeholder {
  color: #94a3b8;
  font-size: 11px;
}


/* 日期时间选择器动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 右键菜单 */
.navi-context-menu {
  position: fixed;
  z-index: 50;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 6px 0;
  min-width: 200px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  animation: menuIn 0.15s ease-out;
}

.navi-context-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: #475569;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}

.navi-context-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.navi-context-item.danger {
  color: #ef4444;
}

.navi-context-item.danger:hover {
  background: #fef2f2;
}

.navi-context-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 4px 0;
}

.navi-shortcut {
  margin-left: auto;
  font-size: 11px;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
}

/* ============================================
   加载遮罩
   ============================================ */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

/* ============================================
   空状态
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  text-align: center;
  color: #94a3b8;
}

/* ============================================
   GPU 加速
   ============================================ */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* ============================================
   搜索框样式
   ============================================ */
.navi-search-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.navi-search-input {
  flex: 1;
  height: 32px;
  padding: 0 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s;
}

.navi-search-input:focus {
  border-color: #3b82f6;
}

.navi-search-input::placeholder {
  color: #94a3b8;
}

.navi-search-btn {
  padding: 4px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}

.navi-search-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.navi-search-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================
   表头内容样式
   ============================================ */
.navi-header-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.navi-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.navi-pin-icon {
  opacity: 0;
  color: #94a3b8;
  transition: opacity 0.15s;
}

.navi-header-cell:hover .navi-pin-icon {
  opacity: 1;
}

.navi-pin-icon.active {
  opacity: 1;
  color: #3b82f6;
}

/* ============================================
   右键菜单信息
   ============================================ */
.navi-context-info {
  padding: 6px 14px;
  font-size: 11px;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 4px;
}

/* 右键菜单项状态 */
.navi-context-item.warning {
  color: #d97706;
}

.navi-context-item.warning:hover {
  background: #fffbeb;
}

.navi-context-item.success {
  color: #059669;
}

.navi-context-item.success:hover {
  background: #f0fdf4;
}

/* ============================================
   固定列样式
   ============================================ */
.navi-header-cell.pinned {
  background: #f1f5f9;
}

/* ============================================
   空状态
   ============================================ */
.navi-empty {
  padding: 40px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
}

/* ============================================
   虚拟行容器
   ============================================ */
.navi-rows-container {
  position: relative;
}
