/* ============================================================
 * panel.css — 面板设置 / 紧凑排版 / 蓝控控件 / 熄屏常亮(AOD)
 *
 * 依赖：pages.css 定义的 --np-* 设计令牌。
 * 本文件在 pages.css 之后加载，负责：
 *  1. [data-theme] 显式浅色/深色覆盖（与系统跟随解耦，避免闪烁）；
 *  2. html.np-compact 紧凑排版（缩间距/内边距/字号，小窗不溢出可滚动）；
 *  3. 蓝控控件系统：按钮(主/次)、开关、滑块 的四态（默认/悬停/按下/禁用）+ 对比度；
 *  4. 面板设置页与 AOD 叠层布局。
 * ============================================================ */

/* ---------- 1. 显式主题变量（优先级高于 pages.css 的媒体查询） ---------- */
html[data-theme="light"] {
    --np-primary: #2f6bff;
    --np-primary-dark: #1f54e0;
    --np-primary-darker: #1742b8;
    --np-primary-soft: rgba(47, 107, 255, 0.10);
    --np-primary-softer: rgba(47, 107, 255, 0.06);
    --np-on-primary: #ffffff;

    --np-bg: #f6f7f9;
    --np-card: #ffffff;
    --np-subtle: #eef1f5;
    --np-border: #e2e6ec;
    --np-border-strong: #cdd4de;

    --np-text: #12151c;
    --np-text-secondary: #515a68;
    --np-text-muted: #828b9a;

    --np-shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --np-shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);
}

html[data-theme="dark"] {
    --np-primary: #4f8bff;
    --np-primary-dark: #3f78f0;
    --np-primary-darker: #2f63d6;
    --np-primary-soft: rgba(79, 139, 255, 0.16);
    --np-primary-softer: rgba(79, 139, 255, 0.10);
    --np-on-primary: #ffffff;

    --np-bg: #0c0e12;
    --np-card: #15181e;
    --np-subtle: #1c2027;
    --np-border: #272c35;
    --np-border-strong: #363c47;

    --np-text: #e9ecf1;
    --np-text-secondary: #a4acbc;
    --np-text-muted: #767e8e;

    --np-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --np-shadow-md: 0 12px 32px rgba(0, 0, 0, 0.55);
}

/* 主题切换平滑过渡（仅首帧后生效，防初始闪烁） */
html.theme-ready,
html.theme-ready body,
html.theme-ready .np-card,
html.theme-ready .np-panel,
html.theme-ready .np-btn,
html.theme-ready .np-switch,
html.theme-ready input,
html.theme-ready select {
    transition: background-color .22s ease, color .22s ease, border-color .22s ease, box-shadow .22s ease;
}

/* ---------- 2. 紧凑排版 ---------- */
/* 默认（舒适）间距由 pages.css 定义；紧凑模式在此收紧。 */
html.np-compact {
    --np-radius: 9px;
    --np-radius-lg: 12px;
    --np-gap: 10px;
}

html.np-compact body.np-body { font-size: 13px; line-height: 1.55; }
html.np-compact .np-page-title { font-size: 18px; }
html.np-compact .np-page-subtitle { font-size: 12px; margin: 2px 0 0; }
html.np-compact .np-main { padding-top: 10px; }
html.np-compact .np-card,
html.np-compact .np-panel { padding: 10px 12px; border-radius: 9px; }
html.np-compact .np-grid { gap: 10px; }
html.np-compact .np-stat-value { font-size: 20px; }
html.np-compact .np-stat-label { font-size: 11px; }
html.np-compact .np-header { padding: 6px 0; }
html.np-compact .np-nav-link { padding: 5px 9px; font-size: 13px; }
html.np-compact .np-btn { padding: 5px 11px; font-size: 13px; }
html.np-compact .np-footer { padding: 14px 0; font-size: 12px; }

/* 小窗口：禁止横向溢出，容器可滚动 */
.np-main, .np-container, .np-container-wide {
    min-width: 0;
}
.np-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--np-gap, 14px);
    min-width: 0;
}
.np-card, .np-panel {
    min-width: 0;
    overflow-wrap: break-word;
}
/* 任意长文本/URL 截断而非撑破布局 */
.np-ellipsis, .np-card .np-mono, .np-card dt, .np-card dd {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 560px) {
    html.np-compact .np-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    html.np-compact .np-stat-value { font-size: 17px; }
}

/* ---------- 3. 蓝控控件系统（按钮 / 开关 / 滑块 四态） ---------- */
.np-btn {
    --_bg: var(--np-primary);
    --_fg: var(--np-on-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: var(--np-radius-sm, 8px);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    user-select: none;
    background: var(--_bg);
    color: var(--_fg);
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .05s ease, opacity .15s ease;
    text-decoration: none;
}
.np-btn:hover { --_bg: var(--np-primary-dark); }
.np-btn:active { --_bg: var(--np-primary-darker); transform: translateY(1px); }
.np-btn:focus-visible { outline: 2px solid var(--np-primary); outline-offset: 2px; }
.np-btn:disabled,
.np-btn.is-disabled {
    --_bg: var(--np-subtle);
    color: var(--np-text-muted);
    cursor: not-allowed;
    opacity: .8;
    transform: none;
}

/* 次按钮：描边蓝 */
.np-btn-ghost {
    --_bg: transparent;
    --_fg: var(--np-primary);
    border-color: var(--np-primary);
    color: var(--np-primary);
}
.np-btn-ghost:hover { --_bg: var(--np-primary-soft); --_fg: var(--np-primary-dark); }
.np-btn-ghost:active { --_bg: var(--np-primary-softer); --_fg: var(--np-primary-darker); }
.np-btn-ghost:disabled,
.np-btn-ghost.is-disabled {
    --_bg: transparent;
    border-color: var(--np-border-strong);
    color: var(--np-text-muted);
}

/* 开关控件 */
.np-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex: none;
}
.np-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.np-switch .np-switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--np-border-strong);
    transition: background-color .18s ease;
}
.np-switch .np-switch-knob {
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.3);
    transition: transform .18s ease;
}
.np-switch input:hover ~ .np-switch-track { background: var(--np-primary-dark); opacity: .85; }
.np-switch input:checked ~ .np-switch-track { background: var(--np-primary); opacity: 1; }
.np-switch input:checked ~ .np-switch-knob { transform: translateX(18px); }
.np-switch input:active ~ .np-switch-knob { width: 22px; }
.np-switch input:focus-visible ~ .np-switch-track { outline: 2px solid var(--np-primary); outline-offset: 2px; }
.np-switch input:disabled { cursor: not-allowed; }
.np-switch input:disabled ~ .np-switch-track { background: var(--np-border); opacity: .6; }
.np-switch input:disabled:checked ~ .np-switch-track { background: var(--np-text-muted); opacity: .55; }

/* 滑块 / 进度条（统一蓝色） */
.np-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--np-border-strong);
    outline: none;
    cursor: pointer;
}
.np-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--np-primary);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
    transition: background-color .15s ease, transform .05s ease;
}
.np-range:hover::-webkit-slider-thumb { background: var(--np-primary-dark); }
.np-range:active::-webkit-slider-thumb { background: var(--np-primary-darker); transform: scale(1.08); }
.np-range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--np-primary); outline-offset: 2px; }
.np-range:disabled { opacity: .6; cursor: not-allowed; }
.np-range:disabled::-webkit-slider-thumb { background: var(--np-text-muted); }
.np-range::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--np-primary); border: 2px solid #fff; cursor: pointer;
}
.np-range::-moz-range-thumb:hover { background: var(--np-primary-dark); }
.np-range:disabled::-moz-range-thumb { background: var(--np-text-muted); }

/* 进度条（filled 部分蓝） */
.np-progress {
    position: relative;
    height: 6px;
    border-radius: 999px;
    background: var(--np-border-strong);
    overflow: hidden;
}
.np-progress > i {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background: linear-gradient(90deg, var(--np-primary), var(--np-primary-dark));
    border-radius: 999px;
    transition: width .2s ease;
}

/* ---------- 4. 面板设置页布局 ---------- */
.np-settings {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    max-width: 880px;
    margin: 0 auto;
}
.np-settings-section {
    background: var(--np-card);
    border: 1px solid var(--np-border);
    border-radius: var(--np-radius);
    box-shadow: var(--np-shadow);
    padding: 16px 18px;
}
.np-settings-section h2 {
    margin: 0 0 4px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.np-settings-section .np-section-desc {
    margin: 0 0 12px;
    color: var(--np-text-muted);
    font-size: 12.5px;
}
.np-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--np-border);
    min-width: 0;
}
.np-row:first-of-type { border-top: none; }
.np-row .np-row-text { min-width: 0; }
.np-row .np-row-title { font-weight: 600; font-size: 14px; }
.np-row .np-row-hint { color: var(--np-text-muted); font-size: 12px; margin-top: 2px; }
.np-row .np-row-control { flex: none; display: flex; align-items: center; gap: 8px; }

.np-disabled-note {
    margin-left: 8px;
    font-size: 11px;
    color: var(--np-warning, #b7791f);
    background: rgba(245,166,35,.12);
    border: 1px solid rgba(245,166,35,.34);
    border-radius: 6px;
    padding: 1px 6px;
    white-space: nowrap;
}
.np-select {
    background: var(--np-card);
    color: var(--np-text);
    border: 1px solid var(--np-border-strong);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
}
.np-num {
    width: 72px;
    background: var(--np-card);
    color: var(--np-text);
    border: 1px solid var(--np-border-strong);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 13px;
}
.np-inline-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 10px; }
.np-inline-controls label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--np-text-secondary); }

/* 分段控制器（熄灯模式：网页内全屏 / 整体全屏） */
.np-seg {
    display: inline-flex;
    border: 1px solid var(--np-border-strong);
    border-radius: 8px;
    overflow: hidden;
    background: var(--np-card);
}
.np-seg-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--np-text-secondary);
    padding: 7px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
    font-family: var(--np-font, system-ui, sans-serif);
}
.np-seg-btn + .np-seg-btn { border-left: 1px solid var(--np-border-strong); }
.np-seg-btn:hover { color: var(--np-text); background: var(--np-primary-softer); }
.np-seg-btn.active { background: var(--np-primary); color: var(--np-on-primary); }
.np-seg-btn.active:hover { background: var(--np-primary-dark, var(--np-primary)); }
.np-history-list { margin-top: 10px; max-height: 220px; overflow: auto; border: 1px solid var(--np-border); border-radius: 8px; }
.np-history-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 8px;
    padding: 6px 10px;
    font-size: 12.5px;
    border-bottom: 1px solid var(--np-border);
}
.np-history-row:last-child { border-bottom: none; }
.np-history-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-empty { color: var(--np-text-muted); font-size: 13px; padding: 10px; }

/* 主题切换下拉 */
.np-theme-menu { position: relative; display: inline-block; }
.np-theme-menu .np-theme-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--np-card); color: var(--np-text);
    border: 1px solid var(--np-border-strong); border-radius: 8px;
    padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.np-theme-menu .np-theme-btn:hover { border-color: var(--np-primary); color: var(--np-primary); }
.np-theme-menu .np-theme-pop {
    position: absolute; right: 0; top: calc(100% + 6px);
    background: var(--np-card); border: 1px solid var(--np-border);
    border-radius: 10px; box-shadow: var(--np-shadow-md);
    padding: 6px; min-width: 160px; z-index: 50; display: none;
}
.np-theme-menu.open .np-theme-pop { display: block; }
.np-theme-menu .np-theme-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; border: none; background: transparent; color: var(--np-text);
    border-radius: 8px; cursor: pointer; font-size: 13px; text-align: left;
}
.np-theme-menu .np-theme-item:hover { background: var(--np-primary-soft); color: var(--np-primary-dark); }
.np-theme-menu .np-theme-item.is-active { background: var(--np-primary-soft); color: var(--np-primary-dark); font-weight: 600; }

/* ---------- 5. AOD 叠层（熄屏常亮） ----------
 * 样式已抽到独立文件 css/aod.css（首页 index.php 与设置页 settings.php 共用），
 * 避免与 panel.css 的视觉主题耦合。本文件不再重复定义 #npAod。
 */

.np-toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: var(--np-card); color: var(--np-text);
    border: 1px solid var(--np-border-strong); border-radius: 10px;
    box-shadow: var(--np-shadow-md); padding: 10px 16px; font-size: 13px;
    z-index: 10000; opacity: 0; pointer-events: none; transition: opacity .2s ease;
    max-width: 90vw;
}
.np-toast.show { opacity: 1; }
