/* ==========================================================================
   1. 基础变量与全局复位
   ========================================================================== */
:root {
    --primary: #007aff;
    --primary-dark: #0056b3;
    --primary-light: rgba(0, 122, 255, 0.1);
    --bg: #f2f2f7;
    --card: #ffffff;
    --text: #1c1c1e;
    --muted: #8e8e93;
    --border: #d1d1d6;
    --danger: #ff3b30;
    --success: #34c759;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 50px;
}

[v-cloak] { display: none; }

/* ==========================================================================
   2. Toast 通知组件
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    transition: transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    background: var(--danger);
}

.toast i { font-size: 1.1rem; }

/* ==========================================================================
   3. 导航栏 (Navbar)
   ========================================================================== */
.navbar {
    height: 64px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
}

.nav-brand { font-weight: 800; font-size: 1.1rem; color: var(--text); flex: 1; }
.nav-brand i { color: var(--primary); font-size: 1.4rem; }

.nav-tabs {
    display: flex;
    background: #e3e3e8;
    padding: 2px;
    border-radius: 10px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.nav-tabs button {
    border: none;
    background: none;
    padding: 6px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--muted);
    white-space: nowrap;
}

.nav-tabs button.active { background: white; color: var(--text); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); }
.nav-status { flex: 1; display: flex; justify-content: flex-end; align-items: center; font-size: 0.75rem; color: var(--muted); }
.dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; margin-right: 6px; }

/* ==========================================================================
   3. 布局容器与通用按钮
   ========================================================================== */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0 25px 0;
}

.page-header h2 { font-size: 1.6rem; margin: 0; font-weight: 700; }
.page-header h3 { font-size: 1.2rem; margin: 0; font-weight: 700; }

.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 122, 255, 0.15);
}

.btn-sm { padding: 6px 14px; font-size: 0.8rem; border-radius: 8px; }

.btn-icon {
    background: #f2f2f7;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text);
}

.btn-icon.delete:hover { color: var(--danger); background: #ffdada; }

/* ==========================================================================
   4. 策略卡片 (Rules) - 修复关键词对齐 & 底部按钮
   ========================================================================== */
.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.rule-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.rule-card.inactive { opacity: 0.6; filter: grayscale(0.8); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.title-area h3 { margin: 0; font-size: 1.15rem; font-weight: 700; }

.card-meta {
    font-size: 0.75rem;
    color: var(--muted);
    display: flex;
    gap: 12px;
    margin-top: 6px;
}

/* 关键词与输入框：高度像素级对齐 */
.tags-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 15px 0;
    align-items: center;
}

.tag, .tag-input input {
    height: 32px; /* 统一高度 */
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
}

.tag {
    background: #f2f2f7;
    padding: 0 12px;
    border-radius: 16px;
    font-weight: 500;
    gap: 6px;
    border: 1px solid rgba(0,0,0,0.03);
}

.tag i { cursor: pointer; color: var(--muted); font-size: 1rem; }

.tag-input input {
    border: 1px dashed var(--border);
    border-radius: 16px;
    padding: 0 12px;
    width: 85px;
    outline: none;
    background: transparent;
    transition: width 0.2s;
}

.tag-input input:focus { width: 130px; border-color: var(--primary); border-style: solid; }

.logic-info { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.badge {
    background: #f2f2f7;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #48484a;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge.logic { color: var(--primary); background: var(--primary-light); }

.card-footer {
    border-top: 1px solid #f2f2f7;
    margin-top: 15px;
    padding-top: 15px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.btns { display: flex; gap: 10px; flex-shrink: 0; }


/* ==========================================================================
   6. 资产管理 (Assets)
   ========================================================================== */
.asset-section { margin-bottom: 40px; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 15px; }
.asset-card {
    background: white; padding: 16px; border-radius: 14px; border: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.asset-info { flex: 1; overflow: hidden; margin-right: 15px; }
.asset-info strong { font-size: 0.95rem; display: block; }
.asset-info code {
    display: block; background: #f2f2f7; padding: 6px 8px; border-radius: 6px;
    font-size: 0.75rem; margin-top: 6px; color: var(--primary); word-break: break-all; font-family: monospace;
}

.asset-btns { display: flex; align-items: center; gap: 15px; flex-shrink: 0; }
.asset-btns i { font-size: 1.2rem; color: var(--muted); cursor: pointer; transition: 0.2s; padding: 5px; }
.asset-btns i:hover { color: var(--primary); }
.asset-btns .delete-icon:hover { color: var(--danger); }

/* ==========================================================================
   7. 日志与抽屉
   ========================================================================== */
.log-item { background: var(--card); padding: 15px; border-radius: var(--radius-lg); display: flex; gap: 15px; border: 1px solid var(--border); margin-bottom: 12px; }
.log-icon { width: 48px; height: 48px; border-radius: 10px; background: #eee; flex-shrink: 0; }
.log-info { flex: 1; min-width: 0; }
.app-name { font-weight: 700; font-size: 0.9rem; }
.time { font-size: 0.7rem; color: var(--muted); }
.log-content { font-size: 0.85rem; color: #444; margin-top: 4px; word-break: break-all; }
.status-tag { font-size: 0.75rem; font-weight: 700; margin-top: 8px; display: inline-block; }
.status-tag.success { color: var(--success); }

.drawer-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(5px); display: flex; align-items: flex-end; z-index: 2000; }
.drawer { background: white; width: 100%; max-width: 500px; margin: 0 auto; border-radius: 24px 24px 0 0; padding: 25px; max-height: 85vh; overflow-y: auto; }
@media (min-width: 768px) { .drawer-overlay { align-items: center; justify-content: center; } .drawer { border-radius: 20px; } }

.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.close-btn { font-size: 1.8rem; color: var(--muted); cursor: pointer; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 8px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 12px; outline: none; font-family: inherit; }

.app-selector, .bark-selector { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; background: #f2f2f7; border-radius: 12px; }
.app-chip, .bark-chip { background: white; border: 1px solid var(--border); padding: 6px 14px; border-radius: 8px; font-size: 0.8rem; cursor: pointer; font-weight: 600; }
.app-chip.active, .bark-chip.active { background: var(--primary); color: white; }

.drawer-footer { display: flex; justify-content: center; margin-top: 25px; }
.btn-submit { width: 180px; border-radius: 25px; }

/* 过滤器栏 */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.filter-bar select {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    font-size: 0.8rem;
    color: var(--text);
    min-width: 100px;
}

/* 紧凑型日志卡片 */
.log-item-compact {
    background: var(--card);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    gap: 12px;
    margin-bottom: 8px; /* 间距变小 */
    border: 1px solid var(--border);
    position: relative;
}

.log-mini-icon {
    width: 36px; /* 图标缩小 */
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
}

.log-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.log-line-1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-line-1 .app-name {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--primary);
}

.log-line-1 .log-time {
    font-size: 0.7rem;
    color: var(--muted);
}

.log-line-2 {
    font-size: 0.85rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.log-title {
    font-weight: 600;
}

.log-line-3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
}

.status-pill {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
}

.status-pill.pushed {
    background: rgba(52, 199, 89, 0.1);
    color: var(--success);
}

.status-pill.blocked {
    background: #f2f2f7;
    color: var(--muted);
}

.log-del-btn {
    font-size: 1rem;
    color: var(--muted);
    cursor: pointer;
    padding: 2px;
}

.log-del-btn:hover {
    color: var(--danger);
}

.btn-danger-soft {
    background: #ffdada;
    color: var(--danger);
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ==========================================================================
   8. 开关与响应式
   ========================================================================== */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #e5e5ea; transition: .3s; border-radius: 24px; cursor: pointer; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 2px; bottom: 2px; background: white; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
input:checked + .slider { background: var(--success); }
input:checked + .slider:before { transform: translateX(20px); }

@media (max-width: 600px) {
    .nav-brand span { display: none; }
    .nav-tabs button { padding: 6px 12px; font-size: 0.8rem; }
    .rules-grid { grid-template-columns: 1fr; }
}

/* 统计看板 */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.bg-blue { background: linear-gradient(135deg, #007aff, #0055ff); }
.bg-red { background: linear-gradient(135deg, #ff3b30, #ff0000); }
.bg-purple { background: linear-gradient(135deg, #af52de, #5e5ce6); }
.bg-green { background: linear-gradient(135deg, #34c759, #30b34d); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-num { font-size: 1.5rem; font-weight: 800; line-height: 1.1; color: var(--text); }
.stat-num.small { font-size: 1.1rem; } /* 文字较多时缩小 */
.stat-label { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
