/* ============================================================
 * components.css
 * 通用控件：按钮、输入框、搜索框、标签、Toast、徽章
 * ============================================================ */

.btn {
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--radius-md);
    background: var(--intensity-6);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn:hover { background: var(--intensity-8); }
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[disabled] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--accent); }

.btn-danger { background: var(--destructive); color: white; }

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--intensity-4);
    border: var(--border);
    border-radius: var(--radius-md);
}

.search-bar input {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    min-width: 0;
}

.input-group { margin-bottom: 12px; }

.input-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
    font-weight: 500;
}

.input-field {
    width: 100%;
    height: 32px;
    border: var(--border);
    border-radius: var(--radius-sm);
    background: var(--intensity-4);
    color: var(--text-primary);
    padding: 0 10px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.input-field:focus { border-color: var(--primary); }

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tag {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: var(--intensity-6);
    color: var(--text-secondary);
}

.tag-success {
    background: color-mix(in srgb, var(--success) 18%, transparent);
    color: var(--success);
}

.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mb-12 { margin-bottom: 12px; }

.empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-tertiary);
    font-size: 12px;
}

.backup-notice {
    background: color-mix(in srgb, var(--warning) 12%, transparent);
    border: 0.5px solid color-mix(in srgb, var(--warning) 30%, transparent);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.tab-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border: var(--border);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.15s;
}

.tab-pill.active {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 20%, transparent);
}

.tab-pill:hover { color: var(--text-primary); }

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: calc(100% - 32px);
    max-width: 360px;
}

.toast {
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    animation: toastIn 0.2s ease-out, toastOut 0.2s ease-in 1.6s forwards;
    backdrop-filter: blur(8px);
}

.toast.success { background: rgba(64, 180, 62, 0.92); }
.toast.error { background: rgba(230, 92, 83, 0.92); }
.toast.warning { background: rgba(235, 164, 0, 0.92); color: rgba(0, 0, 0, 0.85); }

@keyframes toastIn {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
    to { transform: translateY(-10px); opacity: 0; }
}

/* ---------- Badge ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    background: var(--intensity-6);
    color: var(--text-secondary);
}

.badge.live {
    background: color-mix(in srgb, var(--success) 18%, transparent);
    color: var(--success);
}

.badge.live::before {
    content: "";
    width: 6px; height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* ---------- Pull-to-refresh indicator ---------- */
.pull-indicator {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 12px;
    overflow: hidden;
    transition: height 0.2s;
    background: var(--panel-bg);
    border-bottom: var(--border);
}

.pull-indicator.active { height: 36px; }
