/* ========================================
   车机服务调试平台 - 样式表
   ======================================== */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
}

.header .version {
    font-size: 11px;
    background: rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

.header-right {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #94a3b8;
}

.separator { color: #475569; }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.status-dot.offline {
    background: #94a3b8;
}

/* Navigation */
.nav {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    padding: 0 16px;
    overflow-x: auto;
}

.nav-item {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: all 0.2s;
    text-decoration: none;
}

.nav-item:hover {
    color: var(--primary);
    background: #f8fafc;
}

.nav-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Main */
.main {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.stat-card.online-card { border-left-color: var(--success); }
.stat-card.warning-card { border-left-color: var(--danger); }

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Panel */
.panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.panel h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Inputs */
.input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.textarea {
    width: 100%;
    resize: vertical;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 13px;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    overflow-wrap: break-word;
}

.table th {
    font-weight: 600;
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background: #f8fafc;
}

.table-compact td {
    padding: 6px 10px;
    font-size: 12px;
}

/* Device Grid */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.device-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.device-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}

.device-name {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}

.device-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.switch-track {
    display: inline-block;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    position: relative;
    transition: background .2s;
}

.switch-on {
    background: var(--success);
}

.switch-off {
    background: #ccc;
}

.switch-thumb {
    display: block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: left .2s;
}

.switch-on .switch-thumb {
    left: 18px;
}

.switch-label {
    font-size: 11px;
    color: var(--text-muted);
}

.device-status {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.device-status.online {
    background: #dcfce7;
    color: #16a34a;
}

.device-status.offline {
    background: #f1f5f9;
    color: #94a3b8;
}

.device-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.device-info-item {
    font-size: 12px;
}

.device-info-item .label {
    color: var(--text-muted);
}

.device-info-item .value {
    font-weight: 500;
}

/* Progress Bars */
.progress-bar {
    background: #e2e8f0;
    border-radius: 4px;
    height: 6px;
    margin-top: 4px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.fill-green { background: var(--success); }
.fill-yellow { background: var(--warning); }
.fill-red { background: var(--danger); }
.fill-blue { background: var(--primary); }

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-critical { background: #fef2f2; color: #dc2626; }
.badge-warning { background: #fffbeb; color: #d97706; }
.badge-info { background: #fefce8; color: #ca8a04; }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-pending { background: #f1f5f9; color: #64748b; }
.badge-sent { background: #dbeafe; color: #2563eb; }
.badge-failed { background: #fef2f2; color: #dc2626; }

.severity-legend {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

/* Direction indicators */
.direction-in { color: var(--success); font-weight: 600; }
.direction-out { color: var(--primary); font-weight: 600; }

/* Forms */
.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.form-row label {
    font-weight: 500;
    font-size: 13px;
    min-width: 80px;
    color: var(--text-muted);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 24px;
}

/* Command buttons */
.cmd-buttons {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.cmd-buttons .btn {
    padding: 12px 32px;
    font-size: 15px;
    font-weight: 600;
}

/* Code block */
.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 6px;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

/* Activity list */
.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.activity-time {
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.pagination button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.text-muted { color: var(--text-muted); font-size: 13px; }

/* Engine status */
.engine-off { color: #94a3b8; }
.engine-running { color: var(--success); }
.engine-starting { color: var(--warning); }

/* JSON link */
.json-link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
    font-size: 12px;
}

/* 通信日志数据列 - 完整显示 */
.log-payload {
    color: var(--primary);
    cursor: pointer;
    font-size: 12px;
    font-family: "Consolas", "Courier New", monospace;
    word-break: break-all;
    white-space: normal;
    line-height: 1.6;
}

.log-payload:hover {
    background: #f0f7ff;
}

.json-link:hover {
    color: var(--primary-dark);
}

/* Signal strength */
.signal-bar {
    display: inline-flex;
    gap: 2px;
    align-items: flex-end;
    height: 14px;
}

.signal-bar span {
    width: 3px;
    background: #cbd5e1;
    border-radius: 1px;
}

.signal-bar span.active { background: var(--success); }
.signal-bar span:nth-child(1) { height: 4px; }
.signal-bar span:nth-child(2) { height: 7px; }
.signal-bar span:nth-child(3) { height: 10px; }
.signal-bar span:nth-child(4) { height: 14px; }

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    z-index: 2000;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

@keyframes slideIn {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .device-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .cmd-buttons { flex-wrap: wrap; }
}
