/* ===================== CARDS v6.0 — Stitch Design System ===================== */
/* KPI Cards (Glass), Stat Cards, Drag Grid, Card Components */

/* ---- KPI GRID ---- */
.kpi-grid {
    display: grid;
    gap: 16px;
}

.kpi-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.kpi-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.kpi-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.kpi-grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.kpi-grid-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* ---- KPI CARD (Glass Card with Neon Line Glow) ---- */
.kpi-card {
    /* 移除生硬的渐变拼凑，只保留纯净底色 */
    background: var(--surface-dark);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

/* Neon diffuse glow — concentrated at top-left where colored lines intersect */
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle at 0% 0%, var(--kpi-color, var(--accent-blue)) 0%, transparent 70%);
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
    filter: blur(20px);
    transition: opacity 0.4s ease, filter 0.4s ease;
}

/* Secondary ambient glow — subtle bottom-right balance */
.kpi-card::after {
    content: '';
    position: absolute;
    bottom: -20%;
    right: -10%;
    width: 50%;
    height: 60%;
    background: radial-gradient(ellipse at center, var(--kpi-color, var(--accent-blue)) 0%, transparent 70%);
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
    filter: blur(25px);
}

.kpi-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.kpi-card:hover::before {
    opacity: 0.30;
    filter: blur(24px);
}

/* ---- LIGHT THEME: glass cards ---- */
[data-theme="light"] .kpi-card {
    /* 同样移除生硬的渐变拼凑 */
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .kpi-card::before {
    opacity: 0.06;
}

[data-theme="light"] .kpi-card::after {
    opacity: 0.03;
}

[data-theme="light"] .kpi-card:hover {
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.06);
}

.kpi-card-inner {
    padding: 18px 20px;
    position: relative;
    z-index: 1;
}

/* ---- 核心修复区：完美圆角的霓虹边线遮罩 ---- */
.kpi-card-inner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    /* 同步外层圆角 */
    border-radius: var(--radius-lg);
    /* 绘制真实的边框线条，通过粗细调节效果 */
    border-top: 2px solid var(--kpi-color, var(--accent-blue));
    border-left: 3px solid var(--kpi-color, var(--accent-blue));
    /* 给线条增加一点弥散光晕 */
    filter: drop-shadow(0 0 6px var(--kpi-color, var(--accent-blue)));
    /* 用遮罩让线条从左上角向两边平滑淡出 */
    -webkit-mask-image: radial-gradient(ellipse at top left, black 15%, transparent 70%);
    mask-image: radial-gradient(ellipse at top left, black 15%, transparent 70%);
}

/* 原来的 .kpi-card-inner::after 已删除，因为现在用遮罩统一处理了 */


/* ---- KPI TEXT ---- */
.kpi-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 4px;
}

.kpi-sub {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ---- HERO CARDS ---- */
.kpi-hero .kpi-card-inner {
    padding: 18px 22px;
}

.kpi-hero .kpi-value {
    font-size: 2rem;
}

.kpi-hero .kpi-label {
    font-size: 13px;
}

.kpi-hero .kpi-sub {
    font-size: 12px;
}

/* ---- GENERAL CARD (Glass) ---- */
.card {
    background: linear-gradient(145deg, rgba(24, 24, 27, 0.8) 0%, rgba(9, 9, 11, 0.6) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

[data-theme="light"] .card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(241, 245, 249, 0.7));
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .card-header {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

.card-title {
    font-size: 13px;
    font-weight: 600;
}

.card-body {
    padding: 14px 16px;
}

/* ---- DRAG GRID (Legacy) ---- */
.drag-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.drag-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.drag-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.drag-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.drag-card {
    background: linear-gradient(145deg, rgba(24, 24, 27, 0.8) 0%, rgba(9, 9, 11, 0.6) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
}

[data-theme="light"] .drag-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(241, 245, 249, 0.7));
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.drag-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.drag-card.dragging {
    opacity: 0.5;
    transform: scale(0.96);
    z-index: 50;
}

.drag-card.drop-target {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

@keyframes dropBounce {
    0% {
        transform: scale(0.92);
    }

    60% {
        transform: scale(1.03);
    }

    100% {
        transform: scale(1);
    }
}

.span-2 {
    grid-column: span 2;
}

.span-3 {
    grid-column: span 3;
}

.span-full {
    grid-column: 1 / -1;
}

/* ---- STAT MINI CARD (Glass) ---- */
.stat-mini {
    display: flex;
    flex-direction: column;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .stat-mini {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

.stat-mini-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-mini-value {
    font-size: 18px;
    font-weight: 700;
}

.stat-mini-sub {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* ---- SKELETON LOADING ---- */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.skeleton {
    background: #2a2b33;
    background-image: linear-gradient(90deg, #2a2b33 0px, #3a3b43 40px, #2a2b33 80px);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
    border-radius: 6px;
}

.skeleton-text {
    height: 12px;
    width: 80%;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 20px;
    width: 40%;
    margin-bottom: 12px;
}

/* ---- EMPTY STATE ---- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 16px;
}

.empty-state p {
    font-size: 13px;
    max-width: 300px;
}

/* ---- TOP LOSS ROWS ---- */
.top-loss-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: var(--transition);
}

.top-loss-row:hover {
    background: rgba(239, 68, 68, 0.06);
}

.top-loss-name {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-loss-value {
    font-size: 12px;
    font-weight: 700;
    font-family: 'SF Mono', 'Consolas', monospace;
    color: var(--accent-red);
    text-align: right;
    min-width: 60px;
}

.top-loss-pct {
    font-size: 11px;
    color: var(--text-dim);
    text-align: right;
    min-width: 50px;
}

/* ---- COST CHIP ---- */
.cost-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid;
    min-width: 65px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 10px;
}

.cost-chip:hover {
    transform: scale(1.03);
}

.cost-chip-label {
    opacity: 0.7;
    margin-bottom: 2px;
}

.cost-chip-value {
    font-size: 12px;
    font-weight: 700;
    font-family: 'SF Mono', 'Consolas', monospace;
}

/* ---- DRAG PLACEHOLDER ---- */
.drag-placeholder {
    background: rgba(59, 130, 246, 0.06);
    border: 2px dashed rgba(59, 130, 246, 0.35);
    border-radius: 14px;
    transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
    min-height: 60px;
}

.drag-card.drop-settle {
    animation: dropSettle 0.35s cubic-bezier(.25, .8, .25, 1);
}

@keyframes dropSettle {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ---- PROGRESS BAR ---- */
.progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.progress-label {
    font-size: 11px;
    color: var(--text-secondary);
    width: 90px;
    text-align: right;
    flex-shrink: 0;
}

.progress-track {
    flex: 1;
    height: 8px;
    background: #1f2128;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.progress-value {
    font-size: 11px;
    font-family: 'SF Mono', 'Consolas', monospace;
    width: 50px;
    flex-shrink: 0;
}