:root {
    --bg-color: #1a1a1a;
    --text-color: #e5e5e5;
    --border-color: #404040;
    --primary-color: #4f8bf9;
    --secondary-color: #ff6b6b;
    --light-bg: #2a2a2a;
    --muted-light: #a0a0a0;

    /* 响应式尺寸变量 */
    --gap: clamp(12px, 2vw, 20px);
    --side-width: clamp(280px, 25vw, 400px);
    --font-size: clamp(13px, 2.5vw, 16px);
    --title-size: clamp(20px, 4vw, 28px);
    --padding: clamp(12px, 3vw, 24px);

    /* 固定最小值 */
    --min-gap: 8px;
    --min-font-size: 12px;
}

/* 应用容器 */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 大理石色背景 */
body {
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 25%, #1f1f1f 50%, #252525 75%, #1a1a1a 100%);
    background-size: 400% 400%;
    animation: marble-flow 20s ease-in-out infinite;
    margin: 0;
    color: var(--text-color);
    min-height: 100vh;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* 确保代码/输入/按钮等元素也使用相同的等宽/代码字体堆栈 */
html, body, .app, pre, code, textarea, input, button, .sql-input, .app-editor {
    font-family: 'LXGW WenKai','JetBrains Mono', 'Fira Code', 'Source Code Pro', Consolas, Monaco, 'Courier New', monospace;
}

@keyframes marble-flow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 头部样式 */
.app-header {
    padding: var(--padding);
    border-bottom: 1px solid rgba(64, 64, 64, 0.3);
    background: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(10px);
}

.app-header::before {
    display: none;
}

.app-title {
    margin: 0;
    font-size: var(--title-size);
    font-weight: 600;
    color: var(--text-color);
}

/* 主内容区域 */
.app-main {
    flex: 1;
    padding: var(--padding);
}

.app-layout {
    display: flex;
    gap: var(--gap);
    align-items: flex-start;
}

.app-content {
    flex: 1;
    min-width: 0; /* 防止flex子项溢出 */
    overflow: hidden; /* 防止内容溢出 */
    max-width: 100%; /* 确保不超过父容器 */
    box-sizing: border-box;
}

/* SQL编辑器区域 */
.sql-editor {
    margin-bottom: var(--gap);
    margin-right: 2px;
}

.action-buttons {
    display: flex;
    gap: 8px;
    margin: 16px 0;
    flex-wrap: wrap;
}

/* 参考面板 */
.reference-panel {
    width: 100%;
    min-width: 250px;
    max-width: 100%; /* 确保不超过容器宽度 */
    box-sizing: border-box; /* 包含padding和border */
}

.reference-table {
    max-height: clamp(400px, 60vh, 600px);
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%; /* 确保不超过容器 */
}

/* 函数表格 */
.function-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: var(--font-size);
    table-layout: fixed; /* 固定表格布局 */
}

.function-table th,
.function-table td {
    border: 1px solid var(--border-color);
    padding: clamp(6px, 1.5vw, 12px);
    text-align: left;
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    max-width: none;
}

.function-table th:nth-child(1),
.function-table td:nth-child(1) {
    width: 25%; /* 常用函数列 */
}

.function-table th:nth-child(2),
.function-table td:nth-child(2) {
    width: 25%; /* SQL SERVER列 */
}

.function-table th:nth-child(3),
.function-table td:nth-child(3) {
    width: 25%; /* ORACLE列 */
}

.function-table th:nth-child(4),
.function-table td:nth-child(4) {
    width: 25%; /* MYSQL列 */
}

.function-table th {
    background: #333333;
    font-weight: 600;
    color: #e5e5e5;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 2px solid #555555;
}

.function-table tbody tr:nth-child(even) {
    background: #2a2a2a;
}

.function-table tbody tr:nth-child(odd) {
    background: #1f1f1f;
}

.function-table tbody tr:hover {
    background: #333333;
}

.function-table td {
    color: #e5e5e5;
    border-bottom: 1px solid #404040;
}

.function-table td:first-child {
    font-weight: 500;
    color: #ffffff;
}

.function-name {
    background: var(--light-bg);
    font-weight: 500;
}

/* 天气面板 */
.weather-panel {
    width: var(--side-width);
    min-width: 280px;
}

.weather-widget {
    background: rgba(26, 26, 26, 0.95);
    border: 1px solid rgba(64, 64, 64, 0.3);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    transition: box-shadow 0.2s ease;
    position: relative;
}

.weather-widget:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* 天气滚动箭头按钮 */
.weather-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: rgba(42, 42, 42, 0.9);
    border: 1px solid rgba(64, 64, 64, 0.5);
    border-radius: 50%;
    color: #e5e5e5;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    backdrop-filter: blur(10px);
    opacity: 0.3; /* 初始状态半透明 */
    pointer-events: none; /* 初始状态禁用点击 */
}

.weather-nav-btn:hover {
    background: rgba(64, 64, 64, 0.9);
    border-color: rgba(79, 139, 249, 0.5);
    color: var(--primary-color);
    transform: translateY(-50%) scale(1.1);
}

.weather-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.weather-nav-btn.left {
    left: 8px;
}

.weather-nav-btn.right {
    right: 8px;
}

.weather-header {
    font-weight: 600;
    margin-bottom: 16px;
    font-size: 16px;
    color: #e5e5e5;
    text-align: center;
    position: relative;
}

.weather-header::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 1px;
}

.weather-content {
    font-size: var(--font-size);
    color: #a0a0a0;
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

/* 页脚 */
.app-footer {
    padding: var(--padding);
    border-top: 1px solid rgba(64, 64, 64, 0.3);
    background: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(10px);
    text-align: center;
    font-size: var(--font-size);
    margin-top: auto;
}

.app-footer::before {
    display: none;
}

.app-footer a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

.app-footer a:hover {
    text-decoration: underline;
}

.layout, .app-layout {
    display: flex;
    gap: var(--gap);
    align-items: flex-start;
    padding: var(--gap);
}

.left-column, .app-layout__left {
    flex: 1;
}

.side {
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: var(--gap);
}

.side.right {
    width: 380px
}

.side.left {
    width: auto
}

.csv-panel {
    max-height: 520px;
    overflow: auto;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.csv-panel .csv-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.csv-panel .csv-th,
.csv-panel .csv-td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.csv-panel .csv-th {
    background: #f5f5f5;
    font-weight: bold;
}

.csv-panel .csv-td, .app-csv__panel .app-csv__td {
    font-size: 13px;
    color: #333;
}

.csv-panel .csv-td, .app-csv__panel .app-csv__td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ensure left-side CSV container allows horizontal scrolling when table is wider than container */
.side.left .csv-panel, .app-layout__side.app-layout__side--left .app-csv__panel {
    overflow-x: auto
}

.side.left .csv-panel .csv-table, .app-layout__side.app-layout__side--left .app-csv__panel .app-csv__table {
    width: auto;
    min-width: 100%;
}

.csv-panel .csv-table {
    position: relative
}

/* 固定第一列 */
.csv-panel .csv-th:first-child,
.csv-panel .csv-td:first-child,
.app-csv__panel .app-csv__th:first-child,
.app-csv__panel .app-csv__td:first-child {
    position: sticky;
    left: 0;
    background: #f5f5f5;
    border-right: 2px solid #ccc;
}

/* When JS fallback is active, disable native sticky to avoid double-positioning jitter */
.csv-panel.js-sticky-active .csv-th:first-child,
.csv-panel.js-sticky-active .csv-td:first-child,
.app-csv__panel.js-sticky-active .app-csv__th:first-child,
.app-csv__panel.js-sticky-active .app-csv__td:first-child {
    position: static;
    /* JS will apply transform instead */
}

/* 输入框包装器样式 */
.sql-input-wrapper {
    position: relative;
    border-radius: 8px;
    background: linear-gradient(135deg, #2a2a2a 0%, #333333 100%);
    border: 1px solid #404040;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    overflow: hidden;
}

.sql-input-wrapper:hover {
    border-color: #555555;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.sql-input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(79, 139, 249, 0.3), 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* 输入框样式 */
.sql-input, .app-editor {
    width: 100%;
    height: 400px;
    font-size: var(--font-size);
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-color);
    resize: vertical;
    padding: 16px;
    transition: all 0.2s ease;
    line-height: 1.5;
    outline: none;
}

.sql-input:focus, .app-editor:focus {
    outline: none;
}

.sql-input::placeholder, .app-editor::placeholder {
    color: #9ca3af;
}

.row, .app-row {
    display: flex;
    gap: 10px;
    margin-top: 12px
}

/* 按钮样式 */
.btn {
    padding: 5px 10px;
    border: 1px solid #555555;
    border-radius: 6px;
    background: #333333;
    color: #e5e5e5;
    cursor: pointer;
    font-size: var(--font-size);
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    background: #404040;
    border-color: #777777;
}

.btn:active {
    background: #2a2a2a;
}

.btn.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

.btn.btn-primary:hover {
    background: #3d7bf9;
    border-color: #3d7bf9;
}

.btn.btn-secondary {
    background: var(--secondary-color);
    color: #ffffff;
    border-color: var(--secondary-color);
}

.btn.btn-secondary:hover {
    background: #4b5563;
    border-color: #4b5563;
}

.btn.btn-ghost {
    background: transparent;
    border: 1px solid #555555;
    color: #e5e5e5;
}

.btn.btn-ghost:hover {
    background: #404040;
    border-color: #777777;
}

.meta, .app-meta {
    margin-top: 10px;
    color: var(--muted-light);
    font-size: 13px
}

.footer, .app-footer {
    color: var(--muted-light);
    font-size: 13px;
    display: block;
    clear: both;
    padding-left: 0
}

/* link accent */
a {
    color: var(--primary-color);
    text-decoration: none
}

a:hover {
    text-decoration: underline;
}

/* subtle neon for meta/footer */
.meta, .app-meta {
    color: rgba(180, 220, 255, 0.7)
}

.footer, .app-footer {
    color: rgba(180, 220, 255, 0.55)
}

/* CSV 控件 */
#csvControls {
    display: flex;
    gap: 8px;
    align-items: center
}

.weather-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px 0;
    margin-top: 12px;
    scrollbar-width: none; /* 隐藏Firefox滚动条 */
    -ms-overflow-style: none; /* 隐藏IE滚动条 */
    position: relative;
    z-index: 1;
}

.weather-row::-webkit-scrollbar {
    display: none; /* 隐藏Webkit滚动条 */
}

.weather-day {
    flex: 0 0 auto;
    min-width: 80px;
    text-align: center;
    padding: 12px 8px;
    border: 1px solid #404040;
    border-radius: 8px;
    background: linear-gradient(135deg, #2a2a2a 0%, #333333 100%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.weather-day::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.weather-day:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.weather-day:hover::before {
    opacity: 1;
}

.weather-day .date {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
    font-weight: 500;
}

.weather-day .icon {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.weather-day .temp {
    font-size: 14px;
    color: #e5e5e5;
    font-weight: 600;
}

.weather-day .wind {
    font-size: 11px;
    color: #b0b0b0;
    margin-top: 4px;
    font-weight: 400;
    text-align: center;
}

.weather-day .wind small {
    font-size: 10px;
    color: #888;
    display: block;
    margin-top: 2px;
}

/* ==========================
	 赛博2077 额外细节增强
	 - 背景网格、标题霓虹文字
	 - 自定义滚动条、输入焦点发光
	 - 按钮/表头细微动画与高光
	 ========================== */

/* 选择/高亮颜色 */
::selection {
    background: var(--primary-color);
    color: #ffffff;
}

/* 移除表头的装饰线 */

/* 首列样式 */
.csv-panel .csv-td.csv-first,
.csv-panel .csv-th.csv-first,
.app-csv__panel .app-csv__td.app-csv__cell--first,
.app-csv__panel .app-csv__th.app-csv__cell--first {
    background: var(--light-bg);
}

/* 自定义滚动条 */
.csv-panel .csv-table::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.csv-panel .csv-table::-webkit-scrollbar-thumb,
.app-csv__panel .app-csv__table::-webkit-scrollbar-thumb {
    background: #666666;
    border-radius: 4px;
}

.weather-row::-webkit-scrollbar {
    height: 8px
}

/* 输入焦点：发光边框（便于键盘导航） */
.sql-input:focus, .app-editor:focus {
    outline: none;
    box-shadow: 0 0 30px var(--btn-after-cyan), inset 0 1px 0 var(--inset-weak);
    border-color: var(--first-column-border)
}

.sql-input::placeholder, .app-editor::placeholder {
    color: var(--placeholder-muted)
}

/* 天气标题轻微跳动（非侵入） */
.weather-header {
    transition: transform .28s ease, color .18s ease
}

.weather-header:hover {
    transform: translateY(-2px);
    color: var(--secondary-color);
}

/* 响应式设计 */

/* 平板和桌面端 */
@media (max-width: 1024px) {
    :root {
        --side-width: clamp(250px, 30vw, 350px);
    }
}

/* 小屏幕设备 */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
        gap: var(--min-gap);
    }

    .reference-panel,
    .weather-panel {
        width: 100%;
        order: 1; /* 让侧边栏在移动端排在后面 */
    }

    .app-content {
        order: -1; /* 主要内容优先显示 */
    }

    .action-buttons {
        flex-direction: column;
        gap: var(--min-gap);
    }

    .action-buttons .btn {
        width: 100%;
        padding: 12px;
    }

    .reference-table {
        max-height: 300px;
    }
}

/* 手机端 */
@media (max-width: 480px) {
    :root {
        --padding: 12px;
        --gap: 12px;
    }

    .app-header,
    .app-main,
    .app-footer {
        padding: var(--padding);
    }

    .app-title {
        font-size: 20px;
        text-align: center;
    }

    .sql-input {
        font-size: var(--min-font-size);
        min-height: 200px;
        padding: 12px;
    }

    .function-table th,
    .function-table td {
        padding: 6px 4px;
        font-size: var(--min-font-size);
    }
}


