/* ============================================================
   Household Assets — Shared Styles
   Used by all pages: login, dashboard, admin, reports
   ============================================================ */

@layer utilities {
    .content-auto {
        content-visibility: auto;
    }
    .gradient-bg {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    .card-shadow {
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    }
    .hover-lift {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    .hover-lift:hover {
        transform: translateY(-5px);
        box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15);
    }

    /* 按钮专用悬停效果 — 不使用 translateY 避免 hover 死循环（transform 影响点击区域） */
    .btn-lift {
        transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    }
    .btn-lift:hover {
        transform: scale(1.03);
        box-shadow: 0 8px 20px -5px rgba(59, 130, 246, 0.35);
    }

}

/* ---------------------- 日期输入框统一样式 ---------------------- */
/* 所有页面的 flatpickr 日期选择器和原生日期输入框共用此样式
   宽度通过 Tailwind w-* 类控制，此处只定义外观 */
.date-input {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #374151;
    background-color: #fff;
    transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}
.date-input::placeholder {
    color: #9ca3af;
    font-size: 0.875rem;
}
.date-input:focus {
    outline: none;
    border-color: #1e40af;
    box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.3);
}
/* flatpickr 挂载后会给 input 添加 flatpickr-input 类，保持一致 */
input.flatpickr-input.date-input {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* ---------------------- 动画 ---------------------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes bounceSubtle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ---------------------- 工具类 ---------------------- */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.table-container {
    max-height: 600px;
    overflow-y: auto;
}

.table-container thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f9fafb;
}

.filter-container {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid #e2e8f0;
}

/* ---- 通用筛选控件类（逐步替代 ID 选择器） ---- */
.filter-select {
    width: 180px;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
}

.filter-input {
    width: 180px;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
}

.filter-date {
    width: 180px;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
}

.filter-keyword {
    width: 220px;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
}

.stat-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px -10px rgba(0, 0, 0, 0.1);
}

.loading-spinner {
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.modal-backdrop {
    backdrop-filter: blur(8px);
}

/* ---------------------- 导航 ---------------------- */
.nav-link {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s, color 0.2s;
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.nav-link:not(.active) {
    background-color: transparent;
    color: rgba(255, 255, 255, 0.8);
}

.nav-link:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.95);
}

/* ---------------------- 表格 ---------------------- */
.resizable-th {
    position: relative;
    user-select: none;
}

.resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    background-color: transparent;
    cursor: col-resize;
}

.resize-handle:hover {
    background-color: #3b82f6;
}

.resizable-table th .sortable-header,
.resizable-table th .detail-sortable-header {
    font-size: 1rem;
}

.sortable-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.sort-indicator {
    display: inline-block;
    min-width: 12px;
    text-align: center;
    color: #9ca3af;
    font-size: 0.75rem;
    font-weight: bold;
    line-height: 1;
}

.sort-indicator.active {
    color: #1e40af;
}

/* ---------------------- 统计区域 ---------------------- */
#statisticsSection {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

#detailStatisticsSection {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

/* ---------------------- Flatpickr 覆盖 ---------------------- */
.flatpickr-calendar {
    width: 310px;
    font-size: 0.85rem;
}

.flatpickr-day {
    height: 30px;
    width: 30px;
    line-height: 30px;
}

/* 明细查询表格容器 */
.detail-table-container {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
    font-size: 0.875rem;
}

.detail-table-container thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f9fafb;
    font-size: 0.65rem;
}

/* 明细查询两行表头文本 */
.detail-sortable-header span:first-child {
    line-height: 1.2;
    text-align: left;
}

/* 明细查询表格列宽分配 — fixed 布局确保名称列尽可能宽且无横向滚动 */
.detail-table-container table {
    table-layout: fixed;
    width: 100%;
}

.detail-table-container thead th:nth-child(1),
.detail-table-container tbody td:nth-child(1) { width: 8%; }   /* 日期 */
.detail-table-container thead th:nth-child(2),
.detail-table-container tbody td:nth-child(2) { width: 8%; }   /* 账户 */
.detail-table-container thead th:nth-child(3),
.detail-table-container tbody td:nth-child(3) { width: 6%; }   /* 持有人 */
.detail-table-container thead th:nth-child(4),
.detail-table-container tbody td:nth-child(4) { width: 8%; }   /* 名称 */
.detail-table-container thead th:nth-child(5),
.detail-table-container tbody td:nth-child(5) { width: 6%; }   /* 数量 */
.detail-table-container thead th:nth-child(6),
.detail-table-container tbody td:nth-child(6) { width: 7%; }   /* 净值 */
.detail-table-container thead th:nth-child(7),
.detail-table-container tbody td:nth-child(7) { width: 7%; }   /* 计算净值 */
.detail-table-container thead th:nth-child(8),
.detail-table-container tbody td:nth-child(8) { width: 6%; }   /* 投资类型 */
.detail-table-container thead th:nth-child(9),
.detail-table-container tbody td:nth-child(9) { width: 8%; }   /* 投资子类型 */
.detail-table-container thead th:nth-child(10),
.detail-table-container tbody td:nth-child(10) { width: 5%; }  /* 清仓次数 */
.detail-table-container thead th:nth-child(11),
.detail-table-container tbody td:nth-child(11) { width: 7%; }  /* 年化收益率 */
.detail-table-container thead th:nth-child(12),
.detail-table-container tbody td:nth-child(12) { width: 7%; }  /* 累计收益 */
.detail-table-container thead th:nth-child(13),
.detail-table-container tbody td:nth-child(13) { width: 7%; }  /* 日收益 */
.detail-table-container thead th:nth-child(14),
.detail-table-container tbody td:nth-child(14) { width: 6%; }  /* 计算金额 */
.detail-table-container thead th:nth-child(15),
.detail-table-container tbody td:nth-child(15) { width: 4%; }  /* 币种 */

/* 明细查询排序表头样式 */
.detail-sortable-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.detail-sort-indicator {
    color: #9ca3af;
    font-size: 0.75rem;
}

.detail-sort-indicator.active {
    color: #1e40af;
}

/* ---------------------- Admin 页面 ---------------------- */

/* 表格排序（覆盖 shared 的 flex 布局，admin 使用 table-cell） */
th.sortable-header {
    display: table-cell;
    cursor: pointer;
    user-select: none;
}

.sortable-header:hover {
    color: #1e40af;
}

.sort-indicator {
    font-size: 0.65rem;
    margin-left: 2px;
}

.sort-indicator.desc::after {
    content: ' ▼';
    color: #1e40af;
}

.sort-indicator.asc::after {
    content: ' ▲';
    color: #1e40af;
}

/* Tab 导航 */
.tab-btn {
    position: relative;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    cursor: pointer;
    background: none;
    white-space: nowrap;
}

.tab-btn:hover {
    color: #1e40af;
}

.tab-btn.active {
    color: #1e40af;
    border-bottom-color: #1e40af;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ---------------------- AI 对话框显隐 ---------------------- */
.hidden-dialog {
    display: none !important;
}

.visible-dialog {
    display: flex !important;
}

/* AI 加载动画点 */
.ai-typing-dot {
    animation: aiTypingBounce 1.4s infinite ease-in-out both;
}
.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes aiTypingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
