/* ============================================
   STOCKET Design System - Shared Variables & Styles
   ============================================ */

:root {
    /* Brand Colors - Keep #ec4899 as brand identity */
    --brand: #ec4899;
    --brand-light: rgba(236, 72, 153, 0.15);
    --brand-border: rgba(236, 72, 153, 0.3);
    --brand-hover: rgba(236, 72, 153, 0.1);
    --brand-hover-bg: rgba(236, 72, 153, 0.1);
    --brand-hover-border: rgba(236, 72, 153, 0.3);

    /* Data Accent Colors */
    --accent: #6366f1;
    --accent-light: rgba(99, 102, 241, 0.15);
    --accent-secondary: #06b6d4;
    --accent-secondary-light: rgba(6, 182, 212, 0.15);
    --accent-tertiary: #8b5cf6;
    --accent-info: #60a5fa;

    /* Semantic Colors */
    --up: #22c55e;
    --up-bg: rgba(34, 197, 94, 0.12);
    --down: #ef4444;
    --down-bg: rgba(239, 68, 68, 0.12);
    --neutral: #94a3b8;

    /* Surface Layers - The key to removing "amateur" feel */
    --bg-base: #09090b;
    --bg-surface: #141416;
    --bg-elevated: #1c1c20;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --bg-overlay: rgba(0, 0, 0, 0.75);
    --overlay: rgba(0, 0, 0, 0.75);

    /* Borders - Subtle, not harsh */
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-active: rgba(236, 72, 153, 0.4);

    /* Text */
    --text-primary: #f0f0f0;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-dim: #52525b;

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 0 1px var(--border-active), 0 0 20px rgba(236, 72, 153, 0.1);

    /* Typography */
    --font-main: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --font-number: "Inter", "Noto Sans SC", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}

/* ============================================
   Typography
   ============================================ */
html, body {
    font-family: var(--font-main);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 数字统一字面 */
.summary-card-value,
.data-value,
.value-positive,
.value-negative,
.rank-cell,
.breadth-table td,
.stocks-table td,
.history-table td {
    font-family: var(--font-number);
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.data-value {
    font-size: 13px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   Sidebar Styles
   ============================================ */
.sidebar-group {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px;
    background: var(--bg-base);
}

.sidebar-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    padding: 4px 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-group-header:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.sidebar-group-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.sidebar-group-icon {
    font-size: 18px;
    color: var(--text-muted);
}

.sidebar-group-content {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-group.collapsed .sidebar-group-content {
    display: none;
}

.sidebar-item:hover {
    background-color: var(--bg-hover);
}

/* 全站侧边栏文字体系（统一栏目风格，使用更高优先级覆盖各页面局部规则） */
aside .sidebar-group-header {
    font-family: var(--font-main) !important;
    font-weight: 700 !important;
    color: rgba(203, 213, 225, 0.76) !important;
}

aside .sidebar-group-title,
aside .sidebar-group-title.sidebar-text {
    font-family: var(--font-main) !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    letter-spacing: 0.01em !important;
    color: rgba(226, 232, 240, 0.78) !important;
}

aside a.sidebar-item,
aside .sidebar-item {
    font-family: var(--font-main) !important;
    font-weight: 650 !important;
    letter-spacing: 0 !important;
    color: rgba(226, 232, 240, 0.84) !important;
}

aside .sidebar-item .sidebar-text,
aside .sidebar-item .sidebar-text.text-sm,
aside .sidebar-item .sidebar-text.font-medium,
aside .sidebar-item span:not(.material-icons-round) {
    font-family: var(--font-main) !important;
    font-size: 15px !important;
    font-weight: 650 !important;
    color: rgba(241, 245, 249, 0.9) !important;
}

aside .sidebar-item .material-icons-round,
aside .sidebar-group-icon {
    font-size: 21px !important;
    color: rgba(203, 213, 225, 0.84) !important;
    font-variation-settings: 'wght' 500;
}

aside .sidebar-item:hover .sidebar-text,
aside .sidebar-item:hover span:not(.material-icons-round),
aside .sidebar-item:hover .material-icons-round,
aside .sidebar-group-header:hover .sidebar-group-title,
aside .sidebar-group-header:hover .sidebar-group-icon {
    color: #ffffff !important;
}

/* 全站侧边栏强制统一（跨栏目统一视觉，不依赖页面私有样式） */
aside .sidebar-group {
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 16px !important;
    background: rgba(255, 255, 255, 0.015) !important;
    padding: 8px !important;
}

aside .sidebar-group-header {
    min-height: 34px;
    border-radius: 10px !important;
}

aside .sidebar-item {
    min-height: 44px;
    border-radius: 10px !important;
}

aside .sidebar-item .sidebar-text,
aside .sidebar-item span:not(.material-icons-round) {
    color: #f1f5f9 !important;
    font-size: 15px !important;
    font-weight: 700 !important;
}

aside .sidebar-group-title,
aside .sidebar-group-title.sidebar-text {
    color: rgba(226, 232, 240, 0.86) !important;
    font-size: 12px !important;
    font-weight: 700 !important;
}

aside .sidebar-item .material-icons-round,
aside .sidebar-group-icon {
    color: rgba(226, 232, 240, 0.9) !important;
    font-size: 22px !important;
}

/* Sidebar collapse states */
aside.collapsed .sidebar-group {
    margin-bottom: 8px;
    border: 0;
    background: transparent;
    padding: 0;
}

aside.collapsed .sidebar-group-header {
    display: none;
}

aside.collapsed .sidebar-group-content {
    display: flex !important;
    margin-top: 0;
}

/* ============================================
   Transitions & Animations
   ============================================ */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ============================================
   Skeleton Loading
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-surface) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-card {
    height: 80px;
    border-radius: var(--radius-md);
}

.skeleton-chart {
    height: 300px;
    border-radius: var(--radius-lg);
}

/* ============================================
   Card Component
   ============================================ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

/* ============================================
   Value Colors
   ============================================ */
.value-positive {
    color: var(--up);
    font-weight: 600;
}

.value-negative {
    color: var(--down);
    font-weight: 600;
}

.value-neutral {
    color: var(--text-muted);
}

/* ============================================
   Custom Scrollbar
   ============================================ */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ============================================
   Summary Cards — White Gradient Border Style
   ============================================ */
.summary-cards {
    position: relative;
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-radius: 16px;
    border: 1px solid transparent;
    background:
        linear-gradient(180deg, rgba(15, 16, 20, 0.98), rgba(11, 12, 15, 0.98)) padding-box,
        linear-gradient(180deg, rgba(255, 255, 255, 0.46) 0%, rgba(255, 255, 255, 0.18) 38%, rgba(255, 255, 255, 0.08) 100%) border-box;
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 28px rgba(0, 0, 0, 0.35);
}

.summary-cards::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 35%);
}

.summary-card {
    flex: 1;
    padding: 22px 20px;
    position: relative;
    transition: background 0.2s ease;
    min-width: 0;
}

.summary-card + .summary-card {
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.summary-card:hover {
    background: rgba(255, 255, 255, 0.02);
}

.summary-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.summary-card-label {
    font-size: 12px;
    font-weight: 500;
    color: rgba(239, 241, 245, 0.72);
    letter-spacing: 0;
    text-transform: none;
}

.summary-card-icon {
    display: none;
}

.summary-card-value {
    font-size: 34px;
    font-weight: 700;
    color: #f8fafc;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    letter-spacing: -0.03em;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.07);
}

.summary-card-sub {
    font-size: 12px;
    color: rgba(226, 232, 240, 0.52);
    margin-top: 10px;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
}

.summary-card-value.positive { color: #4ade80; }
.summary-card-value.negative { color: #fb7185; }

/* ============================================
   Table Heatmap Bar Background
   ============================================ */
.heatmap-bar {
    position: relative;
}

.heatmap-bar::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    border-radius: 2px;
    opacity: 0.15;
    z-index: 0;
    transition: width 0.3s ease;
}

.heatmap-bar.positive::before {
    background: var(--up);
    width: var(--bar-width, 0%);
}

.heatmap-bar.negative::before {
    background: var(--down);
    width: var(--bar-width, 0%);
}

.heatmap-bar > * {
    position: relative;
    z-index: 1;
}

/* ============================================
   Responsive Utilities
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    .summary-cards {
        flex-wrap: wrap;
    }
    .summary-card {
        flex: 1 1 calc(33.333% - 1px);
    }
}

/* Mobile */
@media (max-width: 768px) {
    .summary-cards {
        flex-wrap: wrap;
        border-radius: 12px;
    }
    .summary-card {
        flex: 1 1 calc(50% - 1px);
        padding: 18px 14px;
        border-left: none;
        border-bottom: 1px solid var(--border);
    }
    .summary-card:nth-child(odd) {
        border-right: 1px solid var(--border);
    }
    .summary-card:nth-last-child(-n+2) {
        border-bottom: none;
    }
    .summary-card:last-child:nth-child(odd) {
        border-right: none;
    }
    .summary-card + .summary-card {
        border-left: none;
    }
    .summary-card-value {
        font-size: 24px;
    }

    /* Sidebar: overlay on mobile */
    aside {
        position: fixed !important;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    aside.mobile-open {
        transform: translateX(0);
    }
    aside.collapsed {
        transform: translateX(-100%);
    }

    /* Full-width content on mobile */
    main {
        margin-left: 0 !important;
    }

    /* Stack header items */
    header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 16px !important;
    }

    /* Responsive tables: horizontal scroll */
    .breadth-table,
    .stocks-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .breadth-table table,
    .stocks-table {
        min-width: 600px;
    }

    /* Chart containers */
    .chart-wrapper,
    .compare-chart-wrapper {
        height: 280px !important;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .summary-cards {
        flex-direction: column;
    }
    .summary-card {
        flex: none;
        border-right: none !important;
    }
    .summary-card + .summary-card {
        border-top: 1px solid var(--border);
    }
    .summary-card-value {
        font-size: 22px;
    }
}
