/* A1 用户端 UI 设计系统 —— 100% 还原高保真原型（深色顶栏 + 紫罗兰主色 + 极简卡片） */

:root {
    --a1-bg: #f4f5f7;
    --a1-surface: #ffffff;
    --a1-nav: #0f1117;
    --a1-nav-text: #e8eaed;
    --a1-primary: #7c3aed;
    --a1-primary-hover: #6d28d9;
    --a1-violet-600: #7c3aed;
    --a1-success: #16a34a;
    --a1-danger: #dc2626;
    --a1-muted: #6b7280;
    --a1-border: #e5e7eb;
    --a1-label: #9ca3af;
    --a1-text: #111827;
}

/* ── 全局重置 ───────────────────────────── */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--a1-bg) !important;
    color: var(--a1-text);
    -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── 布局骨架 ───────────────────────────── */
.a1-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.a1-main {
    flex: 1;
    width: 100%;
    max-width: 72rem; /* 6xl */
    margin: 0 auto;
    padding: 24px 16px;
}
@media (min-width: 640px) {
    .a1-main { padding: 32px 32px; }
}

/* ── 顶部导航（桌面 + 移动） ─────────────── */
.a1-header {
    background-color: var(--a1-nav);
    height: 56px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}
@media (max-width: 639.98px) {
    .a1-header { height: 48px; padding: 0 16px; gap: 12px; }
}

.a1-header-left { display: flex; align-items: center; gap: 24px; }

.a1-logo {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: var(--a1-violet-600);
    color: #fff;
    font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.a1-nav { display: flex; align-items: center; height: 56px; }
@media (max-width: 639.98px) { .a1-nav { height: 48px; flex: 1; } }

.a1-nav-item {
    height: 100%;
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px; font-weight: 500;
    color: #9ca3af;
    position: relative;
    padding: 0 20px;
    transition: color .15s;
    text-decoration: none;
}
@media (max-width: 639.98px) {
    .a1-nav-item { font-size: 12px; padding: 0 12px; }
}
.a1-nav-item:hover { color: #e5e7eb; }
.a1-nav-item.active { color: #fff; }
.a1-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 4px;
    background: #8b5cf6;
}

/* ── 页头（Profile 条 / 我的应用标题） ───── */
.a1-page-head { display: flex; align-items: center; gap: 20px; margin-bottom: 32px; }

.a1-avatar {
    width: 64px; height: 64px;
    border-radius: 9999px;
    background: linear-gradient(to bottom right, #8b5cf6, #9333ea, #4338ca);
    color: #fff;
    font-size: 24px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 15px -3px rgba(139,92,246,.15);
    flex-shrink: 0;
}

.a1-page-title { font-size: 20px; font-weight: 600; color: var(--a1-text); letter-spacing: -0.02em; margin: 0; }
.a1-page-subtitle { font-size: 14px; color: #9ca3af; margin: 2px 0 0; }

.a1-head-action { margin-left: auto; }

.a1-page-icon { color: var(--a1-text); flex-shrink: 0; }

/* ── 网格 ───────────────────────────────── */
.a1-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}
@media (min-width: 1024px) {
    .a1-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
.a1-col { display: flex; flex-direction: column; gap: 20px; }

/* ── 卡片 ───────────────────────────────── */
.a1-card {
    background: var(--a1-surface);
    border-radius: 16px;
    border: 1px solid #f3f4f6;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    overflow: hidden;
}
.a1-card + .a1-card { margin-top: 20px; }

.a1-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #f9fafb;
}
.a1-card-title-wrap { display: flex; align-items: center; gap: 10px; }
.a1-card-icon { color: #9ca3af; display: inline-flex; }
.a1-card-title { font-size: 14px; font-weight: 600; color: #1f2937; letter-spacing: -0.01em; margin: 0; }
.a1-card-body { padding: 24px; }

/* ── 信息行 ─────────────────────────────── */
.a1-info-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f9fafb;
}
.a1-info-row:last-child { border-bottom: none; }
.a1-info-label {
    width: 112px; flex-shrink: 0;
    font-size: 12px; font-weight: 500;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.a1-info-value { font-size: 14px; color: #374151; text-align: right; }
.a1-info-value.mono { font-family: 'SF Mono', 'DM Mono', Menlo, monospace; font-size: 12px; color: #6b7280; }

.a1-meta-row { display: flex; align-items: center; gap: 16px; margin-top: 16px; padding-top: 16px; }
.a1-meta { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #9ca3af; }
.a1-meta-dot { color: #e5e7eb; }

/* ── 徽章 ───────────────────────────────── */
.a1-badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px; font-weight: 500;
    letter-spacing: .025em;
    border: 1px solid transparent;
}
.a1-badge-success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.a1-badge-info { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.a1-badge-warn { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

/* ── 按钮 ───────────────────────────────── */
.a1-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px; font-weight: 600;
    border: none; cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
    text-decoration: none;
    line-height: 1.4;
}
.a1-btn-primary { background: var(--a1-violet-600); color: #fff; }
.a1-btn-primary:hover { background: var(--a1-primary-hover); }

.a1-btn-outline {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #4b5563;
    font-weight: 500;
}
.a1-btn-outline:hover { background: #f9fafb; }
.a1-btn-outline.a1-btn-danger { border-color: #fecaca; color: #dc2626; }
.a1-btn-outline.a1-btn-danger:hover { background: #fef2f2; }

.a1-btn-social {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    font-size: 12px; font-weight: 500;
    color: #4b5563;
    background: #fff; cursor: pointer;
    transition: all .15s;
}
.a1-btn-social:hover { background: #f9fafb; border-color: #d1d5db; }

.a1-btn-logout {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    font-size: 14px; font-weight: 500;
    color: #6b7280;
    background: #fff; cursor: pointer;
    transition: all .15s;
}
.a1-btn-logout:hover { color: #dc2626; border-color: #fecaca; background: #fef2f2; }

/* ── 表单 ───────────────────────────────── */
.a1-form { display: flex; flex-direction: column; gap: 12px; }
.a1-form-item { display: flex; flex-direction: column; gap: 4px; }
.a1-form-label {
    font-size: 12px; font-weight: 500;
    color: #9ca3af;
    text-transform: uppercase; letter-spacing: .05em;
}
.a1-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    font-size: 14px; color: #374151;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.a1-input:focus { border-color: #a78bfa; box-shadow: 0 0 0 3px rgba(139,92,246,.3); }
.a1-input:disabled { background: #f9fafb; color: #9ca3af; }

.a1-form-hint { font-size: 12px; color: #9ca3af; margin-top: 8px; }

/* ── 社会化登录 ─────────────────────────── */
.a1-social-hint { font-size: 12px; color: #9ca3af; margin: 0 0 16px; }
.a1-social-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.a1-social-ico { display: inline-flex; }

/* SVG 图标 */
.a1-svg { display: inline-block; vertical-align: middle; }

/* ── MFA / TOTP 条目 ────────────────────── */
.a1-item {
    border-radius: 12px;
    border: 1px solid #f3f4f6;
    background: rgba(249,250,251,.6);
    padding: 16px;
}
.a1-item + .a1-item { margin-top: 12px; }
.a1-item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.a1-item-head-left { display: flex; align-items: center; gap: 8px; }
.a1-item-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: #ede9fe;
    color: #7c3aed;
    display: flex; align-items: center; justify-content: center;
}
.a1-item-title { font-size: 14px; font-weight: 600; color: #1f2937; margin: 0; }
.a1-item-meta-row {
    display: flex; flex-flow: row wrap; align-items: center;
    column-gap: 40px; row-gap: 2px;
    padding-top: 12px; margin-top: 12px;
    border-top: 1px solid #f3f4f6;
}
.a1-item-footer { padding-top: 12px; margin-top: 12px; border-top: 1px solid #f3f4f6; }

/* ── 空状态（Passkey） ──────────────────── */
.a1-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 32px 0; gap: 12px;
    text-align: center;
}
.a1-empty-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    background: #f3f4f6;
    color: #d1d5db;
    display: flex; align-items: center; justify-content: center;
}
.a1-empty-title { font-size: 14px; color: #9ca3af; margin: 0; }
.a1-empty-sub { font-size: 12px; color: #d1d5db; margin: 0; max-width: 192px; }

/* ── 我的应用卡片 ───────────────────────── */
.a1-apps-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 640px) { .a1-apps-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (min-width: 1280px) { .a1-apps-grid { grid-template-columns: repeat(4, minmax(0,1fr)); } }

.a1-app-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #f3f4f6;
    padding: 20px;
    display: flex; flex-direction: column; gap: 16px;
    transition: box-shadow .15s, border-color .15s;
}
.a1-app-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); border-color: #e5e7eb; }

.a1-app-card-head { display: flex; align-items: center; gap: 12px; }
.a1-app-icon {
    width: 48px; height: 48px;
    border-radius: 16px;
    background: linear-gradient(to bottom right, #8b5cf6, #6b21a8);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    flex-shrink: 0;
}
.a1-app-name { font-size: 14px; font-weight: 600; color: #111827; margin: 0; }
.a1-app-type {
    display: inline-block;
    margin-top: 2px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px; font-weight: 600;
    letter-spacing: .1em;
    background: #f5f3ff; color: #7c3aed;
    border: 1px solid #ede9fe;
}

.a1-app-body {
    border-top: 1px solid #f9fafb;
    padding-top: 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.a1-app-label { font-size: 14px; font-weight: 500; color: #374151; margin: 0; }
.a1-app-metas { display: flex; flex-direction: column; gap: 6px; }
.a1-app-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #9ca3af; }
.a1-app-meta a, .a1-app-link { color: #8b5cf6; text-decoration: none; }
.a1-app-meta a:hover, .a1-app-link:hover { text-decoration: underline; }
.a1-app-meta .truncate {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 192px;
}
.a1-app-open { color: #a78bfa; flex-shrink: 0; display: inline-flex; }
.a1-app-open:hover { color: #7c3aed; }

/* ── 模态框 ─────────────────────────────── */
.a1-modal {
    position: fixed; inset: 0; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background-color: rgba(0,0,0,.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.a1-modal[hidden] { display: none; }

.a1-modal-lg {
    background: #fff;
    border-radius: 24px;
    width: 100%; max-width: 512px;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0,0,0,.18);
}
.a1-modal-sm {
    background: #fff;
    border-radius: 16px;
    width: 100%; max-width: 384px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0,0,0,.16);
}

.a1-modal-header {
    position: relative;
    padding: 32px 32px 24px;
    border-bottom: 1px solid #f3f4f6;
}
.a1-modal-close {
    position: absolute; top: 24px; right: 24px;
    width: 32px; height: 32px;
    border-radius: 9999px;
    border: none; background: transparent;
    color: #9ca3af; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s;
}
.a1-modal-close:hover { color: #4b5563; background: #f3f4f6; }
.a1-modal-title { font-size: 20px; font-weight: 600; color: #111827; letter-spacing: -0.02em; margin: 0; }

.a1-modal-body { padding: 28px 32px; }
.a1-modal-field-label { display: block; font-size: 14px; font-weight: 500; color: #374151; margin-bottom: 8px; }

.a1-pw-wrap { position: relative; }
.a1-pw-input {
    width: 100%;
    padding: 14px 44px 14px 16px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    font-size: 14px; color: #1f2937;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.a1-pw-input::placeholder { color: #d1d5db; }
.a1-pw-input:focus { border-color: #a78bfa; box-shadow: 0 0 0 3px rgba(139,92,246,.3); }
.a1-pw-toggle {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    border: none; background: transparent;
    color: #d1d5db; cursor: pointer;
    padding: 0; display: flex;
    transition: color .15s;
}
.a1-pw-toggle:hover { color: #6b7280; }

.a1-modal-footer { padding: 0 32px 32px; display: flex; gap: 12px; }
.a1-modal-footer .a1-btn-flex { flex: 1; justify-content: center; }
.a1-btn-flex {
    display: flex; align-items: center; justify-content: center;
    padding: 14px;
    border-radius: 12px;
    font-size: 14px; font-weight: 600;
    border: none; cursor: pointer;
    transition: background-color .15s;
}
.a1-btn-flex-outline {
    border: 1px solid #e5e7eb;
    color: #4b5563; font-weight: 500;
    background: #fff;
}
.a1-btn-flex-outline:hover { background: #f9fafb; }
.a1-btn-flex-primary { background: var(--a1-violet-600); color: #fff; }
.a1-btn-flex-primary:hover { background: var(--a1-primary-hover); }
.a1-btn-flex-primary:disabled { opacity: .4; cursor: not-allowed; }
.a1-btn-flex-danger { background: var(--a1-danger); color: #fff; }
.a1-btn-flex-danger:hover { background: #b91c1c; }

/* 弹窗中部状态（creating / done） */
.a1-modal-state {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 40px 0; gap: 16px;
    text-align: center;
}
.a1-state-icon {
    width: 64px; height: 64px;
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
}
.a1-state-icon.loading { background: #f5f3ff; }
.a1-state-icon.done { background: #ecfdf5; }
.a1-state-title { font-size: 14px; font-weight: 600; color: #1f2937; margin: 0; }
.a1-state-sub { font-size: 12px; color: #9ca3af; margin: 0; }

@keyframes a1-spin { to { transform: rotate(360deg); } }
.a1-spin { animation: a1-spin 1s linear infinite; }

/* ── 退出确认弹窗 ───────────────────────── */
.a1-logout-body { padding: 28px 28px 20px; }
.a1-logout-icon {
    width: 48px; height: 48px;
    border-radius: 9999px;
    background: #fef2f2;
    color: var(--a1-danger);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.a1-logout-title { font-size: 16px; font-weight: 600; color: #111827; margin: 0 0 4px; }
.a1-logout-sub { font-size: 14px; color: #9ca3af; margin: 0; }
.a1-logout-footer { padding: 0 28px 28px; display: flex; gap: 12px; }

/* ── Footer ─────────────────────────────── */
.a1-footer {
    padding: 16px 0;
    text-align: center;
    font-size: 12px;
    color: #d1d5db;
    border-top: 1px solid #f3f4f6;
}

/* ── Toast（保留项目提示能力，风格适配） ── */
.a1-toast-container {
    position: fixed;
    top: 70px; right: 20px;
    z-index: 9999;
    display: flex; flex-direction: column; gap: 10px;
}
.a1-toast {
    min-width: 300px; max-width: 360px;
    padding: 14px 18px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #f3f4f6;
    border-left: 4px solid;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    display: flex; align-items: center; gap: 10px;
    font-size: 14px; color: #374151;
    animation: a1-slide-in .3s ease;
}
.a1-toast.a1-toast-success { border-left-color: var(--a1-success); }
.a1-toast.a1-toast-error { border-left-color: var(--a1-danger); }
.a1-toast.a1-toast-warning { border-left-color: #f59e0b; }
.a1-toast.a1-toast-info { border-left-color: #8b5cf6; }
.a1-toast-close {
    margin-left: auto; cursor: pointer;
    border: none; background: transparent; color: #9ca3af;
    font-size: 16px; line-height: 1; padding: 0;
}
.a1-toast-close:hover { color: #4b5563; }

@keyframes a1-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes a1-slide-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}
