/* ========== Whitey 主题风格 ========== */
/* 基于 Typora Whitey 主题的配色与字体风格 */
/* 适用于智能电子价签蓝牙控制中心 */

:root {
    --bg-color: #f3f2ee;
    --text-color: #1f0909;
    --text-secondary: #656565;
    --card-bg: #ffffff;
    --border-color: #c5c5c5;
    --border-light: #e0ddd4;
    --link-color: #065588;
    --accent-color: #065588;
    --accent-hover: #054470;
    --btn-success: #3a7d5a;
    --btn-success-hover: #2d6246;
    --btn-warning: #b0723a;
    --btn-warning-hover: #8f5c2f;
    --btn-info: #4a6d8c;
    --btn-info-hover: #3a5a73;
    --header-bg: #e8e5d9;
    --header-text: #1f0909;
    --tab-bg: #e8e5d9;
    --tab-active-bg: #f3f2ee;
    --code-bg: #dadada;
    --table-header-bg: #dadada;
    --table-stripe: #e8e7e7;
    --hover-bg: rgba(0, 0, 0, 0.03);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --font-serif: 'PT Serif', 'Times New Roman', Times, serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono: 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* ========== 基础重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-serif);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    padding: 24px;
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

/* ========== 容器 ========== */
.container {
    max-width: 820px;
    margin: 0 auto;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    border: none;
}

/* ========== 头部 ========== */
.header {
    background: transparent;
    color: var(--text-color);
    padding: 36px 0 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.header h1 {
    font-size: 1.875em;
    margin-bottom: 6px;
    font-weight: bold;
    letter-spacing: 0;
    line-height: 1.3;
    border-bottom: none;
    padding-bottom: 0;
}

.header p {
    font-size: 0.95em;
    color: var(--text-secondary);
    font-style: italic;
}

/* ========== 连接面板 ========== */
.connection-panel {
    background: transparent;
    padding: 16px 0;
    margin: 0 0 20px;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border-light);
}

.connection-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

/* ========== 按钮 ========== */
.btn {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 8px 18px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    transition: background-color 0.2s ease;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-serif);
    margin: 10px 0 0 0;
}

.btn:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: #aaa;
}

.btn:active {
    background: rgba(0, 0, 0, 0.08);
}

.btn-success {
    background: var(--btn-success);
    color: #fff;
    border-color: var(--btn-success);
}

.btn-success:hover {
    background: var(--btn-success-hover);
    border-color: var(--btn-success-hover);
}

.btn-warning {
    background: var(--btn-warning);
    color: #fff;
    border-color: var(--btn-warning);
}

.btn-warning:hover {
    background: var(--btn-warning-hover);
    border-color: var(--btn-warning-hover);
}

.btn-info {
    background: var(--btn-info);
    color: #fff;
    border-color: var(--btn-info);
}

.btn-info:hover {
    background: var(--btn-info-hover);
    border-color: var(--btn-info-hover);
}

/* ========== 标签页 ========== */
.tabs {
    display: flex;
    background: transparent;
    margin: 0 0 16px;
    border-radius: 0;
    overflow: visible;
    border: none;
    border-bottom: 1px solid var(--border-color);
}

.tab {
    flex: 0 1 auto;
    padding: 10px 24px;
    text-align: center;
    cursor: pointer;
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    position: relative;
    min-height: 40px;
    border-right: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-family: var(--font-serif);
}

.tab.active {
    background: transparent;
    color: var(--text-color);
    font-weight: 700;
    border-bottom: 2px solid var(--text-color);
}

.tab:hover:not(.active) {
    background: transparent;
    color: var(--text-color);
}

/* ========== 内容区 ========== */
.content {
    display: none;
    padding: 0;
    animation: fadeIn 0.2s ease-in-out;
}

.content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ========== 卡片 ========== */
.card {
    background: transparent;
    border-radius: 0;
    padding: 16px 0;
    margin-bottom: 16px;
    border: none;
    border-bottom: 1px solid var(--border-light);
    transition: none;
}

.card:hover {
    box-shadow: none;
}

.card-title {
    font-size: 1.125em;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-color);
    border-bottom: none;
    padding-bottom: 0;
}

/* ========== 表单 ========== */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    margin-bottom: 4px;
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.875em;
    font-style: italic;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    background: var(--card-bg);
    color: var(--text-color);
    font-family: var(--font-serif);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(6, 85, 136, 0.1);
}

.form-control-inline {
    display: inline-block;
    width: auto;
    margin-right: 10px;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

/* ========== Canvas ========== */
.canvas-container {
    position: relative;
    display: inline-block;
    border-radius: 0;
    overflow: visible;
    border: 1px solid var(--border-color);
    background: #fff;
}

#canvas {
    border: none;
    border-radius: 0;
    background: #ffffff;
}

/* ========== 日志窗口(暂时隐藏) ========== */
.float-window {
    display: none;
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 300px;
    height: 230px;
    background-color: rgba(243, 242, 238, 0.92);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    box-shadow: var(--shadow);
    padding: 12px;
}

.window-title {
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875em;
    color: var(--text-secondary);
}

#log {
    width: 100%;
    background: transparent;
    color: var(--text-color);
    border: none;
    padding: 8px 0;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    overflow-y: scroll;
    max-height: calc(100% - 30px);
    height: 100%;
}

/* ========== 表格 ========== */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.875em;
    font-family: var(--font-serif);
}

td,
th {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--table-header-bg);
    font-weight: 700;
    color: var(--text-color);
    text-transform: none;
}

tr:hover {
    background: var(--hover-bg);
}

tr:nth-child(even) {
    background: var(--table-stripe);
}

/* ========== 代码编辑器 ========== */
.CodeMirror {
    height: auto;
    min-height: 180px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    background: var(--code-bg);
    color: var(--text-color);
    overflow: unset !important;
}

.CodeMirror-sizer {
    padding-right: 0 !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    border-right-width: 0 !important;
}

.CodeMirror-scroll {
    min-height: 180px;
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
}

.CodeMirror-gutters {
    border-right: 1px solid var(--border-color);
    background: transparent;
}

.CodeMirror-linenumber {
    color: #999;
}

.cm-keyword {
    color: var(--accent-color);
    font-weight: 700;
}

.cm-variable {
    color: #8b4b00;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    padding: 0 2px;
}

.cm-string {
    color: #3a7d5a;
}

.cm-number {
    color: #6b3a7d;
}

.cm-bracket {
    color: #65758b;
    font-weight: 600;
}

/* ========== 状态指示器 ========== */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    margin-right: 6px;
}

.status-indicator.connected {
    background: var(--btn-success);
}

/* ========== 布局网格 ========== */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

/* ========== 工具提示 ========== */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-color);
    color: var(--bg-color);
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    z-index: 1000;
    pointer-events: none;
    font-family: var(--font-serif);
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ========== 加载动画 ========== */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--text-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ========== 其他元素 ========== */
a {
    text-decoration: none;
    color: var(--link-color);
}

a:hover,
a:active {
    text-decoration: underline;
}

blockquote {
    font-style: italic;
    border-left: 3px solid var(--border-color);
    margin-left: 1.5em;
    padding-left: 1em;
    color: var(--text-secondary);
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--text-color);
}

select {
    font-family: var(--font-serif);
}

/* ========== 移动端适配 ========== */
@media (max-width: 768px) {
    body {
        padding: 12px;
        font-size: 15px;
    }

    .container {
        max-width: 100%;
    }

    .header {
        padding: 24px 0 16px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .connection-panel {
        padding: 12px 0;
        margin: 0 0 16px;
    }

    .connection-buttons {
        gap: 8px;
        flex-direction: column;
    }

    .btn {
        padding: 12px 18px;
        font-size: 14px;
        min-height: 44px;
        width: 100%;
        border-radius: 3px;
    }

    .tabs {
        flex-direction: column;
        border-bottom: none;
    }

    .tab {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
        border-bottom: 1px solid var(--border-light);
    }

    .tab.active {
        border-bottom: 2px solid var(--text-color);
    }

    .content {
        padding: 0;
    }

    .card {
        padding: 12px 0;
        margin-bottom: 12px;
    }

    .feature-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-control-inline {
        width: 100%;
        margin-right: 0;
        margin-bottom: 8px;
    }

    .button-group {
        flex-direction: column;
        gap: 8px;
    }

    .button-group .btn {
        width: 100%;
        margin: 0;
    }

    .float-window {
        right: 12px;
        bottom: 12px;
        width: calc(100% - 24px);
        max-width: 300px;
    }

    .canvas-container {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px;
    }

    .header h1 {
        font-size: 1.3em;
    }

    .btn {
        font-size: 14px;
        padding: 10px 14px;
    }
}