/* ==========================================================================
   站点统计后台 - 公共样式
   说明：页面同时引入了 Bootstrap 5，这里补充布局与主题变量。
   ========================================================================== */

:root {
    --primary-color: #4f46e5;
    --primary-soft: #eef2ff;
    --sidebar-width: 250px;
    --page-bg: #f4f6fb;
    --card-border: #e5e7eb;
    --text-muted: #6b7280;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--page-bg);
    color: #111827;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
}

a {
    text-decoration: none;
}

/* ---------- 整体布局 ---------- */
#app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: #0f172a;
    color: #cbd5e1;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    z-index: 1030;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    letter-spacing: .5px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #94a3b8;
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease;
}

.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #ffffff;
}

.sidebar .nav-link.active {
    background: rgba(79, 70, 229, .22);
    color: #c7d2fe;
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.sidebar .nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.top-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    background: #ffffff;
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* ---------- 卡片 ---------- */
.stat-card {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 20px;
    height: 100%;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(16, 24, 40, .08);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex: 0 0 auto;
}

.custom-card {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
    overflow: hidden;
}

.custom-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #eef2f7;
    font-weight: 600;
    color: #111827;
}

/* ---------- 表格 ---------- */
.table > :not(caption) > * > * {
    padding: .7rem .75rem;
}

.table thead th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

.page-path {
    display: inline-block;
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .84rem;
    color: #1d4ed8;
}

.user-agent-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.u-a {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .8rem;
    color: var(--text-muted);
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- 意见建议 ---------- */
.feedback-content-preview {
    max-width: 460px;
    cursor: pointer;
    color: #1d4ed8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feedback-content-preview:hover {
    text-decoration: underline;
}

.feedback-detail-content {
    white-space: pre-wrap;
    word-break: break-word;
    background: #f8fafc;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 14px 16px;
    max-height: 50vh;
    overflow-y: auto;
    line-height: 1.7;
}

.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #ffffff;
    font-size: .85rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

/* ---------- 登录页 ---------- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(1200px 600px at 10% 10%, #e0e7ff 0%, transparent 60%),
        radial-gradient(1000px 500px at 90% 90%, #cffafe 0%, transparent 55%),
        #f8fafc;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 36px 32px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .12);
}

.login-brand {
    font-size: 1.45rem;
    font-weight: 800;
    color: #111827;
    letter-spacing: -.02em;
}

.api-badge {
    cursor: pointer;
    user-select: none;
}

.login-error {
    display: none;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: .84rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.login-error.show {
    display: block;
}

/* ---------- 提示条 ---------- */
#sa-toast-container {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sa-toast {
    min-width: 240px;
    max-width: 380px;
    padding: 12px 14px;
    border-radius: 10px;
    color: #ffffff;
    font-size: .86rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .22);
    animation: sa-toast-in .18s ease-out;
    word-break: break-word;
}

.sa-toast.success { background: #16a34a; }
.sa-toast.danger { background: #dc2626; }
.sa-toast.info { background: #2563eb; }

@keyframes sa-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 0 40px rgba(15, 23, 42, .35);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .top-navbar {
        padding: 12px 14px;
    }
}

/* 打印/导出时的简化样式 */
@media print {
    .sidebar,
    .top-navbar,
    .btn {
        display: none !important;
    }
}
