/* ============================================================
   P1Pro 插线板控制台 - 全局样式
   包含：暗色主题、登录页、控制台、设备卡片、插孔网格等
   ============================================================ */

/* ============ 主题变量 ============ */
:root {
    color-scheme: dark;
    --bg: #121212;
    --panel: #1e1e1e;
    --panel-2: #262626;
    --panel-3: #2f2f2f;
    --border: #2a2a2a;
    --border-strong: #3a3a3a;
    --text: #e0e0e0;
    --text-dim: #a0a0a0;
    --muted: #707070;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --green: #4ade80;
    --red: #f87171;
    --orange: #fbbf24;
    --radius: 8px;
}

/* ============ 全局重置 ============ */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============ 布局容器 ============ */
.wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 22px 16px 60px;
}

.brand-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.2rem;
    color: #38bdf8;
    margin-top: 0;
    margin-bottom: 18px;
    font-weight: bold;
}

.brand-logo {
    height: 32px;
    width: auto;
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

/* ============ 卡片 ============ */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 14px;
}

.card h2 {
    font-size: 1.05rem;
    color: #38bdf8;
    margin-top: 0;
    margin-bottom: 12px;
}

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border-strong);
    background: var(--panel-2);
    color: var(--text);
    padding: 7px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.2;
    white-space: nowrap;
    transition: background-color .2s ease, border-color .2s ease;
}

.btn:hover:not(:disabled) {
    background: var(--panel-3);
    border-color: #4a4a4a;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-danger {
    color: var(--red);
    border-color: #4a2a2a;
    background: transparent;
}

.btn-danger:hover:not(:disabled) {
    background: #2a1a1a;
    border-color: #6b3a3a;
}

.btn-success {
    background: var(--green);
    border-color: var(--green);
    color: #10251a;
    font-weight: 600;
}

.btn-success:hover:not(:disabled) {
    background: #6ee7a0;
    border-color: #6ee7a0;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12.5px;
}

/* ============ 设备操作按钮组（靠右排列） ============ */
.device-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}

/* ============ 插孔开关按钮（绿色开 / 红色关） ============ */
button.on {
    background: #22c55e;
    border-color: #22c55e;
    color: #fff;
}

button.on:hover:not(:disabled) {
    background: #16a34a;
    border-color: #16a34a;
}

button.off {
    background: #db5151;
    border-color: #db5151;
    color: #fff;
}

button.off:hover:not(:disabled) {
    background: #ef4444;
    border-color: #ef4444;
}

/* ============ 表单 ============ */
input,
select {
    padding: 8px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: #181818;
    color: var(--text);
    width: 100%;
}

input::placeholder {
    color: #6f6f6f;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

.select-compact {
    width: auto;
    min-width: 180px;
    cursor: pointer;
}

.plug-name-input:focus,
.device-name-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.3);
}

/* ============ 状态文字 ============ */
.status-text {
    font-size: 14px;
    color: #94a3b8;
    margin-top: 10px;
}

.sub {
    color: var(--text-dim);
    font-size: 12px;
}

/* ============ 操作日志 ============ */
.log-box {
    background: #020617;
    color: #10b981;
    padding: 12px;
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    height: 150px;
    overflow-y: auto;
    margin-top: 10px;
    white-space: pre-wrap;
}

/* ============ 插孔网格 ============ */
.plug-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.plug-item {
    background: #1e293b;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid #334155;
}

.plug-name {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 6px;
    font-weight: bold;
}

/* ============ 编辑图标按钮（铅笔 SVG） ============ */
.edit-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #94a3b8;
    background: transparent;
    border: none;
    padding: 2px;
    margin: 0;
    transition: color 0.15s;
    line-height: 0;
}

.edit-icon-btn:hover {
    color: #38bdf8;
    background: transparent;
}

/* ============ 二维码 ============ */
.qr-box {
    text-align: center;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #181818;
    margin-top: 14px;
}

.qr-box img {
    width: 200px;
    height: 200px;
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.qr-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-top: 10px;
    color: var(--text-dim);
    font-size: 12.5px;
}

/* ============================================================
   登录页样式（login.html）
   全屏居中卡片 + 蓝色渐变标题 + 实心按钮
   ============================================================ */

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background-color: #1e1e1e;
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    padding: 40px 30px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-badge {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.auth-badge img {
    width: 120px;
    height: 120px;
    object-fit: contain;
}

.auth-card h1 {
    font-size: 1.4rem;
    margin: 0 0 12px;
    color: #e0e0e0;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-card>p {
    color: #a0a0a0;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0 0 26px;
}

.auth-input {
    width: 100%;
    background-color: #121212;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.95rem;
    font-family: inherit;
    padding: 12px 14px;
    margin-bottom: 12px;
    text-align: center;
}

.auth-input::placeholder {
    color: #6f6f6f;
}

.auth-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.auth-input:disabled {
    opacity: .6;
}

.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background-color: #3b82f6;
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .2s ease, transform .1s ease;
}

.auth-btn:hover:not(:disabled) {
    background-color: #2563eb;
}

.auth-btn:active:not(:disabled) {
    transform: scale(.97);
}

.auth-btn:disabled {
    opacity: .7;
    cursor: not-allowed;
}

.auth-note {
    color: #707070;
    font-size: 12px;
    line-height: 1.6;
    margin-top: 18px;
}

/* ============ 加载动画 ============ */
.spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255, 255, 255, .18);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: kg-spin .7s linear infinite;
    flex: none;
}

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

/* ============ 空状态 ============ */
.empty {
    text-align: center;
    color: var(--muted);
    padding: 34px 0;
}

/* ============ 用电概览卡片 ============ */
.power-hero {
    text-align: center;
    padding: 12px 0 16px;
}

.power-hero-value {
    font-size: 2.6rem;
    font-weight: bold;
    color: #38bdf8;
    line-height: 1.1;
}

.power-hero-unit {
    font-size: 1rem;
    color: #94a3b8;
    margin-left: 4px;
    font-weight: normal;
}

.power-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    border-top: 1px solid #334155;
    padding-top: 14px;
}

.power-metric {
    text-align: center;
}

.power-metric-value {
    font-size: 1.15rem;
    font-weight: 600;
    color: #e0e0e0;
}

.power-metric-label {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

@media (max-width: 480px) {
    .power-hero-value {
        font-size: 2rem;
    }

    .power-metric-value {
        font-size: 1rem;
    }

    .power-metric-label {
        font-size: 10px;
    }
}

/* ============ 功率曲线点击详情 ============ */
.power-detail {
    font-size: 14px;
    color: #cbd5e1;
    margin-top: 6px;
    min-height: 22px;
}

.power-detail strong {
    color: #38bdf8;
    font-size: 15px;
}

/* ============ Tab 切换（等宽平分 + 底部指示条） ============ */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 22px;
    flex-wrap: nowrap;
    width: 100%;
}

.tab {
    position: relative;
    flex: 1;
    padding: 12px 8px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    font-size: 15px;
    font-family: inherit;
    text-align: center;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.tab:hover:not(.active) {
    color: #cbd5e1;
    background: #222;
    border-color: #3a3a3a;
}

.tab.active {
    color: #fff;
    background: #222;
    border-color: #3a3a3a;
    font-weight: 600;
}

/* 激活态：按钮下方的小绿条（跟随按钮宽度） */
.tab.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -7px;
    height: 3px;
    background: #22c55e;
    border-radius: 2px;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

/* ============ 动画降级（尊重用户偏好） ============ */
@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 1.6s;
    }
}