/* ============================================================
   SQL优化助手 - sql_optimizer.css
   布局风格参考 svg_editor，配色以深蓝/靛蓝为主题色
   ============================================================ */

/* ---- 容器布局 ---- */
.sqlo-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    min-height: 580px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s;
}

.sqlo-container:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* ---- 全屏模式 ---- */
.sqlo-container.fullscreen {
    position: fixed;
    inset: 0;
    z-index: 999;
    height: 100vh;
    border-radius: 0;
    border: none;
}

body.dark-mode .sqlo-container {
    background: #1e2535;
    border-color: #2d3748;
}

/* ---- 工具栏 ---- */
.sqlo-toolbar {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    border-bottom: 1px solid #1a3050;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 4px;
}

body.dark-mode .sqlo-toolbar {
    background: linear-gradient(135deg, #0f1f3d 0%, #1d4ed8 100%);
    border-bottom-color: #1e3a5f;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-right: 10px;
    margin-right: 6px;
    border-right: 1px solid rgba(255,255,255,0.22);
}

.toolbar-group:last-child {
    border-right: none;
    padding-right: 0;
    margin-right: 0;
    margin-left: auto;
}

.toolbar-btn {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 12px;
    padding: 5px 11px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.18s;
    white-space: nowrap;
    font-family: inherit;
    letter-spacing: 0.02em;
}

.toolbar-btn:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

.toolbar-btn:active {
    transform: translateY(0);
    background: rgba(255,255,255,0.18);
}

.toolbar-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
    animation: btnShimmer 1.2s infinite;
}

/* 主操作按钮突出样式 */
.toolbar-btn-primary {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    border-color: #b45309 !important;
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(245,158,11,0.35);
    letter-spacing: 0.03em;
}

.toolbar-btn-primary:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
    border-color: #d97706 !important;
    box-shadow: 0 4px 14px rgba(245,158,11,0.5);
    transform: translateY(-2px);
}

.toolbar-btn-primary.loading {
    animation: btnShimmerGold 1.2s infinite;
}

@keyframes btnShimmerGold {
    0%   { background: linear-gradient(135deg, rgba(245,158,11,0.6) 0%, rgba(217,119,6,0.6) 100%); }
    50%  { background: linear-gradient(135deg, rgba(251,191,36,0.9) 0%, rgba(245,158,11,0.9) 100%); }
    100% { background: linear-gradient(135deg, rgba(245,158,11,0.6) 0%, rgba(217,119,6,0.6) 100%); }
}

@keyframes btnShimmer {
    0%   { background: rgba(255,255,255,0.12); }
    50%  { background: rgba(255,255,255,0.28); }
    100% { background: rgba(255,255,255,0.12); }
}

.toolbar-label {
    color: rgba(255,255,255,0.8);
    font-size: 12px;
    white-space: nowrap;
    padding: 2px 0 2px;
}

.toolbar-select {
    background: rgba(255,255,255,0.13);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    font-size: 12px;
    padding: 5px 8px;
    border-radius: 5px;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    min-width: 110px;
}

.toolbar-select option {
    background: #1e3a5f;
    color: #fff;
}

/* ---- 主内容区 ---- */
.sqlo-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

/* ---- 通用面板头部 ---- */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 8px 14px;
    background: linear-gradient(to bottom, #f0f4ff 0%, #e8f0fe 100%);
    border-bottom: 1px solid #c7d7f5;
    flex-shrink: 0;
}

body.dark-mode .panel-header {
    background: linear-gradient(to bottom, #1a2540 0%, #1e2d4a 100%);
    border-bottom-color: #2d3d5c;
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e40af;
    letter-spacing: 0.03em;
}

body.dark-mode .panel-title {
    color: #93c5fd;
}

.panel-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.char-counter, .line-counter {
    font-size: 11px;
    color: #64748b;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 3px;
    padding: 1px 6px;
    font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
}

body.dark-mode .char-counter,
body.dark-mode .line-counter {
    background: #1a2535;
    border-color: #2d3748;
    color: #94a3b8;
}

/* ---- 输入面板 ---- */
.sqlo-input-panel {
    display: flex;
    flex-direction: column;
    width: 45%;
    min-width: 320px;
    border-right: 2px solid #dbeafe;
    background: #fff;
    flex-shrink: 0;
}

body.dark-mode .sqlo-input-panel {
    background: #1a2535;
    border-right-color: #2d3d5c;
}

.sql-editor-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.line-numbers {
    width: 38px;
    min-width: 38px;
    background: #f0f4ff;
    color: #94a3b8;
    font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    padding: 12px 4px 12px 0;
    text-align: right;
    border-right: 1px solid #dbeafe;
    overflow: hidden;
    user-select: none;
    white-space: pre;
    flex-shrink: 0;
}

body.dark-mode .line-numbers {
    background: #131c2e;
    border-right-color: #2d3d5c;
    color: #4a5568;
}

.sql-editor {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #1e293b;
    background: #fff;
    padding: 12px 14px;
    tab-size: 4;
    overflow-y: auto;
    overflow-x: auto;
    white-space: pre;
    transition: box-shadow 0.18s, border-left 0.18s;
    border-left: 3px solid transparent;
}

.sql-editor:focus {
    border-left: 3px solid #2563eb;
    box-shadow: inset 3px 0 12px rgba(37,99,235,0.06);
    outline: none;
}

body.dark-mode .sql-editor {
    background: #1a2535;
    color: #e2e8f0;
}

body.dark-mode .sql-editor:focus {
    border-left: 3px solid #3b82f6;
    box-shadow: inset 3px 0 12px rgba(59,130,246,0.1);
}

.sql-editor::placeholder {
    color: #94a3b8;
    font-style: italic;
}

/* 输入底栏 */
.input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 4px;
}

body.dark-mode .input-footer {
    background: #131c2e;
    border-top-color: #2d3748;
}

.quick-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.quick-label {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
}

.quick-btn {
    font-size: 11px;
    padding: 3px 8px;
    border: 1px solid #c7d7f5;
    background: #eff6ff;
    color: #2563eb;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.quick-btn:hover {
    background: #dbeafe;
    border-color: #3b82f6;
}

body.dark-mode .quick-btn {
    background: #1e3a5f;
    border-color: #2d3d5c;
    color: #93c5fd;
}

body.dark-mode .quick-btn:hover {
    background: #1d4ed8;
}

.shortcut-hint {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
}

/* ---- 结果面板 ---- */
.sqlo-result-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    background: #fff;
    overflow: hidden;
}

body.dark-mode .sqlo-result-panel {
    background: #1e2535;
}

.result-action-btn {
    font-size: 11px;
    padding: 3px 9px;
    border: 1px solid #c7d7f5;
    background: #eff6ff;
    color: #2563eb;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.result-action-btn:hover {
    background: #dbeafe;
}

body.dark-mode .result-action-btn {
    background: #1e3a5f;
    border-color: #2d3d5c;
    color: #93c5fd;
}

body.dark-mode .result-action-btn:hover {
    background: #1d4ed8;
    border-color: #3b82f6;
}

/* 空状态 */
.result-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.empty-icon {
    font-size: 52px;
    margin-bottom: 14px;
    opacity: 0.6;
    animation: emptyFloat 3s ease-in-out infinite;
}

@keyframes emptyFloat {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-8px); }
}

.empty-title {
    font-size: 17px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}

body.dark-mode .empty-title {
    color: #94a3b8;
}

.empty-desc {
    font-size: 13px;
    color: #64748b;
    max-width: 320px;
    line-height: 1.6;
    margin-bottom: 28px;
}

body.dark-mode .empty-desc {
    color: #475569;
}

.empty-features {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #64748b;
    padding: 10px 16px;
    background: #f0f4ff;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    min-width: 72px;
    transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
    cursor: default;
}

.feature-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 14px rgba(37,99,235,0.14);
    background: #e0e7ff;
    border-color: #6366f1;
    color: #3730a3;
}

body.dark-mode .feature-item {
    background: #1a2540;
    border-color: #2d3d5c;
    color: #64748b;
}

body.dark-mode .feature-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 14px rgba(59,130,246,0.2);
    background: #1e3a5f;
    border-color: #3b82f6;
    color: #93c5fd;
}

.feature-icon {
    font-size: 22px;
}

/* 加载状态 */
.result-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
}

.loading-animation {
    display: flex;
    gap: 8px;
}

.loading-dot {
    width: 10px;
    height: 10px;
    background: #2563eb;
    border-radius: 50%;
    animation: dotBounce 1.2s infinite ease-in-out;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%            { transform: scale(1.2); opacity: 1; }
}

.loading-text {
    font-size: 14px;
    color: #334155;
    font-weight: 500;
}

body.dark-mode .loading-text {
    color: #94a3b8;
}

.loading-progress {
    width: 200px;
    height: 3px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #6366f1);
    border-radius: 2px;
    animation: progressAnim 2.5s infinite ease-in-out;
}

@keyframes progressAnim {
    0%   { width: 0%; margin-left: 0%; }
    50%  { width: 60%; margin-left: 20%; }
    100% { width: 0%; margin-left: 100%; }
}

/* 结果内容 */
.result-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    scrollbar-width: thin;
    scrollbar-color: #c7d7f5 transparent;
}

.result-content::-webkit-scrollbar {
    width: 6px;
}

.result-content::-webkit-scrollbar-track {
    background: transparent;
}

.result-content::-webkit-scrollbar-thumb {
    background: #c7d7f5;
    border-radius: 3px;
}

.result-content::-webkit-scrollbar-thumb:hover {
    background: #93c5fd;
}

body.dark-mode .result-content {
    scrollbar-color: #2d3d5c transparent;
}

body.dark-mode .result-content::-webkit-scrollbar-thumb {
    background: #2d3d5c;
}

body.dark-mode .result-content::-webkit-scrollbar-thumb:hover {
    background: #3b4f7c;
}

.result-markdown {
    font-size: 13.5px;
    line-height: 1.75;
    color: #1e293b;
}

@keyframes sqloSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

body.dark-mode .result-markdown {
    color: #cbd5e1;
}

.result-markdown h2 {
    font-size: 15px;
    font-weight: 700;
    color: #1d4ed8;
    margin: 16px 0 10px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
    border-left: 4px solid #2563eb;
    border-radius: 0 6px 6px 0;
}

.result-markdown h2:first-child {
    margin-top: 2px;
}

body.dark-mode .result-markdown h2 {
    color: #93c5fd;
    background: linear-gradient(135deg, #1a2540 0%, #1e2d50 100%);
    border-left-color: #3b82f6;
}

.result-markdown h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2563eb;
    margin: 16px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px dashed #bfdbfe;
}

body.dark-mode .result-markdown h3 {
    color: #60a5fa;
    border-bottom-color: #1e3a5f;
}

.result-markdown p {
    margin: 6px 0 10px;
    color: #374151;
}

body.dark-mode .result-markdown p {
    color: #9ca3af;
}

.result-markdown ul {
    margin: 6px 0 12px 20px;
    padding: 0;
    list-style: disc;
}

.result-markdown ol {
    margin: 6px 0 12px 20px;
    padding: 0;
    list-style: decimal;
}

.result-markdown li {
    margin: 4px 0;
    color: #374151;
}

body.dark-mode .result-markdown li {
    color: #9ca3af;
}

.result-markdown pre {
    background: #0f172a;
    border: 1px solid #1e3a5f;
    border-radius: 8px;
    padding: 14px 16px;
    margin: 10px 0;
    overflow-x: auto;
    position: relative;
}

.result-markdown pre .code-lang-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #1e3a5f;
}

.result-markdown pre .code-lang-dot {
    width: 8px;
    height: 8px;
    background: #7c3aed;
    border-radius: 50%;
    display: inline-block;
}

.result-markdown code {
    font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 12.5px;
    color: #e2e8f0;
    line-height: 1.65;
}

.result-markdown :not(pre) > code {
    background: #1e3a5f;
    color: #93c5fd;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

.result-markdown strong {
    color: #1d4ed8;
    font-weight: 600;
}

body.dark-mode .result-markdown strong {
    color: #60a5fa;
}

.result-markdown hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 16px 0;
}

body.dark-mode .result-markdown hr {
    border-top-color: #2d3748;
}

.result-markdown blockquote {
    border-left: 4px solid #3b82f6;
    margin: 10px 0;
    padding: 8px 14px;
    background: #eff6ff;
    color: #374151;
    border-radius: 0 6px 6px 0;
}

body.dark-mode .result-markdown blockquote {
    background: #1a2540;
    color: #94a3b8;
}

/* SQL代码块复制按钮 */
.code-block-wrapper {
    position: relative;
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: #94a3b8;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    z-index: 2;
    font-family: inherit;
}

.code-copy-btn:hover {
    background: rgba(255,255,255,0.22);
    color: #e2e8f0;
}

.code-copy-btn.copied {
    background: rgba(34,197,94,0.25);
    border-color: rgba(34,197,94,0.5);
    color: #86efac;
}

/* 错误状态 */
.result-error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    text-align: center;
}

.error-icon {
    font-size: 40px;
}

.error-msg {
    font-size: 14px;
    color: #ef4444;
    max-width: 280px;
}

.retry-btn {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #2563eb;
    font-size: 13px;
    padding: 7px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.retry-btn:hover {
    background: #dbeafe;
    border-color: #3b82f6;
}

/* ---- 底部状态栏 ---- */
.sqlo-statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 14px;
    background: #1e3a5f;
    border-top: 1px solid #1a3050;
    font-size: 11px;
    color: rgba(255,255,255,0.65);
    flex-shrink: 0;
}

body.dark-mode .sqlo-statusbar {
    background: #0f1f3d;
    border-top-color: #1a2d4a;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-sep {
    color: rgba(255,255,255,0.3);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-green { background: #22c55e; }
.status-yellow { background: #eab308; }
.status-blue { background: #3b82f6; }

/* ---- 历史记录侧边栏 ---- */
.sqlo-history-sidebar {
    position: fixed;
    right: -360px;
    top: 0;
    width: 340px;
    height: 100vh;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sqlo-history-sidebar.open {
    right: 0;
}

body.dark-mode .sqlo-history-sidebar {
    background: #1a2535;
    border-left-color: #2d3748;
}

.history-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: #fff;
    flex-shrink: 0;
}

.history-sidebar-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 7px;
}

/* 历史数量徽章 */
.history-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    background: #22c55e;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    padding: 0 5px;
    line-height: 1;
}

.history-close-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    font-family: inherit;
}

.history-close-btn:hover {
    background: rgba(255,255,255,0.28);
}

.history-sidebar-toolbar {
    padding: 8px 14px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

body.dark-mode .history-sidebar-toolbar {
    border-bottom-color: #2d3748;
}

.history-clear-btn {
    background: #fff0f0;
    border: 1px solid #fecaca;
    color: #ef4444;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.history-clear-btn:hover {
    background: #fde8e8;
}

body.dark-mode .history-clear-btn {
    background: #2d1a1a;
    border-color: #7f1d1d;
    color: #fca5a5;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.history-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    border-left: 3px solid transparent;  /* 预留active边框位置，避免布局抖动 */
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.history-item-main {
    flex: 1;
    min-width: 0;
}

/* 单条删除按钮（hover时显示） */
.history-item-del {
    display: none;
    flex-shrink: 0;
    background: none;
    border: 1px solid #fca5a5;
    color: #ef4444;
    font-size: 13px;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    font-family: inherit;
    transition: all 0.15s;
}

.history-item:hover .history-item-del {
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-item-del:hover {
    background: #fde8e8;
    border-color: #ef4444;
}

body.dark-mode .history-item-del {
    border-color: #7f1d1d;
    color: #fca5a5;
}

body.dark-mode .history-item-del:hover {
    background: #2d1a1a;
}

.history-item:hover {
    background: #f0f4ff;
}

body.dark-mode .history-item {
    border-bottom-color: #1e2d4a;
}

body.dark-mode .history-item:hover {
    background: #1a2540;
}

/* active 高亮（最新生成条目）- 置于:hover之后确保优先级更高 */
.history-item.active {
    background: #eff6ff;
    border-left-color: #2563eb;
}

body.dark-mode .history-item.active {
    background: #1a2d4a;
    border-left-color: #3b82f6;
}

.history-item.active:hover {
    background: #dbeafe;
}

body.dark-mode .history-item.active:hover {
    background: #1e3a5f;
}

.history-item-sql {
    font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
    font-size: 11px;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

body.dark-mode .history-item-sql {
    color: #94a3b8;
}

.history-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: #94a3b8;
}

.history-item-db {
    background: #eff6ff;
    color: #2563eb;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 10px;
}

body.dark-mode .history-item-db {
    background: #1e3a5f;
    color: #93c5fd;
}

.history-item-action {
    background: #f0fdf4;
    color: #16a34a;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 10px;
}

body.dark-mode .history-item-action {
    background: #052e16;
    color: #4ade80;
}

.history-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    padding: 40px 20px;
}

/* ---- 遮罩层 ---- */
.sqlo-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.sqlo-overlay.active {
    display: block;
}

/* ---- Toast通知 ---- */
.sqlo-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: #1e3a5f;
    color: #fff;
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 2000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1), opacity 0.28s;
    opacity: 0;
    white-space: nowrap;
}

.sqlo-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.sqlo-toast.success { background: #166534; }
.sqlo-toast.error   { background: #991b1b; }
.sqlo-toast.warning { background: #92400e; }

/* ---- 响应式 ---- */
@media (max-width: 900px) {
    .sqlo-main {
        flex-direction: column;
    }

    .sqlo-input-panel {
        width: 100%;
        min-width: unset;
        border-right: none;
        border-bottom: 2px solid #dbeafe;
        height: 45%;
        min-height: 220px;
    }

    .sqlo-result-panel {
        height: 55%;
    }

    .sqlo-history-sidebar {
        width: 300px;
    }
}

@media (max-width: 600px) {
    .sqlo-toolbar {
        padding: 6px 8px;
    }

    .toolbar-btn {
        padding: 4px 7px;
        font-size: 11px;
    }

    .toolbar-group {
        padding-right: 6px;
        margin-right: 4px;
    }
}
