/**
 * 通用CSS样式
 * 应用于整个应用的页面布局和组件样式
 */

/* 全局样式 */
html {
    height: 100%;
}

body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 粘性布局 - 确保底部栏始终在底部 */
.main-content {
    flex: 1 0 auto;
}

footer {
    flex-shrink: 0;
    margin-top: auto;
}

/* 导航栏样式 */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

/* 卡片样式 */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    border-radius: 0.5rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

/* 表格样式 */
.table {
    margin-bottom: 0;
}

.table th {
    border-top: none;
    font-weight: 600;
    font-size: 0.9rem;
    color: #495057;
}

.table-hover tbody tr:hover {
    background-color: rgba(0,0,0,0.025);
}

/* 列头字体颜色更亮 */
.table-dark th {
    color: #ffffff !important;
    font-weight: 500;
}

/* 表格响应式 */
.table-responsive {
    overflow-x: auto;
}

/* 按钮样式 */
.btn {
    border-radius: 0.375rem;
    font-weight: 500;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* 操作按钮组 */
.action-buttons {
    white-space: nowrap;
}

/* 表单样式 */
.form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13,110,253,0.25);
}

.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13,110,253,0.25);
}

/* 只读表单控件 */
.form-control[readonly] {
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* 密码字段 */
.password-field {
    font-family: monospace;
    letter-spacing: 2px;
}

/* 模态框样式 */
.modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.modal-title {
    font-weight: 600;
}

.modal-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* 徽章样式 */
.badge {
    font-weight: 500;
}

/* 状态徽章 */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* 状态样式 - 通用 */
.status-enabled {
    background-color: transparent !important;
    color: #198754 !important;
    font-weight: bold;
}

.status-disabled {
    background-color: transparent !important;
    color: #dc3545 !important;
    font-weight: bold;
}

/* 状态样式 - 账号 */
.status-active {
    background-color: #198754;
    color: white;
}

.status-inactive {
    background-color: #6c757d;
    color: white;
}

/* 状态样式 - 策略 */
.status-paused {
    color: #ffc107;
    font-weight: bold;
}

.status-stopped {
    color: #dc3545;
    font-weight: bold;
}

/* 状态样式 - 订单 */
.status-pending {
    color: #6c757d;
    font-weight: bold;
}

.status-partial {
    color: #ffc107;
    font-weight: bold;
}

.status-filled {
    color: #198754;
    font-weight: bold;
}

.status-cancelled {
    color: #dc3545;
    font-weight: bold;
}

.status-rejected {
    color: #6f42c1;
    font-weight: bold;
}

/* 方向样式 */
.direction-buy {
    color: #198754;
}

.direction-sell {
    color: #dc3545;
}

/* 操作类型样式 */
.action-open {
    color: #0d6efd;
}

.action-close {
    color: #fd7e14;
}

.action-close-today {
    color: #dc3545;
}

/* 盈亏样式 */
.profit-positive {
    color: #dc3545 !important;
}

.profit-negative {
    color: #198754 !important;
}

.profit-zero {
    color: #6c757d !important;
}

/* 统一盈亏样式（与仪表盘保持一致） */
.text-profit {
    color: #dc3545 !important;  /* 红色 - 盈利 */
}

.text-loss {
    color: #28a745 !important;  /* 绿色 - 亏损 */
}

/* 筛选区域 */
.filter-section {
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

/* 参数区域 */
.params-section {
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-top: 1rem;
}

/* Cron 配置说明 */
.cron-info {
    background-color: #e9ecef;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-top: 1rem;
}

.cron-code {
    background-color: #212529;
    color: #f8f9fa;
    border-radius: 0.25rem;
    padding: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

/* 进度区域 */
.progress-section {
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
}

/* 警告提示样式 */
.alert {
    border: none;
    border-radius: 0.5rem;
}

/* 代码样式 */
code {
    background-color: #e9ecef;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

/* 加载动画 */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* 文本工具类 */
.text-truncate {
    max-width: 200px;
}

/* 空数据提示 */
.empty-state {
    padding: 3rem 1rem;
    text-align: center;
}

.empty-state i {
    font-size: 4rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    .action-buttons {
        white-space: nowrap;
    }

    .btn-sm {
        padding: 0.125rem 0.25rem;
        font-size: 0.75rem;
    }
}

/* 打印样式 */
@media print {
    .navbar,
    .btn,
    .modal,
    .alert {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 橙色背景类 */
.bg-orange {
    background-color: #fd7e14 !important;
}

/* ==================== 可编辑表格样式 ==================== */
.editable-table {
    border-collapse: separate;
    border-spacing: 0;
}

.editable-table thead th {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
    padding: 10px 8px;
    vertical-align: middle;
}

.editable-table tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.editable-table tbody tr td {
    vertical-align: middle;
}

.editable-table tbody tr:hover {
    background-color: #f8f9fa;
}

.editable-table tbody tr:last-child {
    border-bottom: none;
}

.editable-table .editable-cell {
    position: relative;
    padding: 8px !important;
    font-size: 16px;
    vertical-align: middle;
}

.editable-table .editable-cell input {
    width: 100%;
    border: 1px solid #0d6efd;
    border-radius: 6px;
    padding: 0px 10px;
    font-size: 16px;
    background-color: #fff;
    transition: all 0.2s ease;
}

.editable-table .editable-cell input:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.editable-table .editing-row {
    background: linear-gradient(90deg, #e7f1ff 0%, #f8f9fa 100%);
    box-shadow: inset 3px 0 0 #0d6efd;
}

.editable-table .editing-row .editable-cell {
    background-color: #fff;
}

.editable-table .weekday-cell {
    color: #6c757d;
    font-size: 16px;
    font-weight: 500;
    vertical-align: middle;
}

.editable-table tfoot tr {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border-top: 2px solid #dee2e6;
}

.editable-table tfoot td {
    padding: 12px 8px;
    font-weight: 600;
    color: #495057;
    vertical-align: middle;
}

/* 可编辑表格按钮样式 */
.editable-table .btn-sm {
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.4;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.editable-table .btn-sm i {
    font-size: 14px;
    line-height: 1;
}

.editable-table .btn-edit-fund:hover {
    background-color: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}

.editable-table .btn-save-fund:hover {
    background-color: #198754;
    color: #fff;
    border-color: #198754;
}

.editable-table .btn-cancel-edit:hover {
    background-color: #6c757d;
    color: #fff;
    border-color: #6c757d;
}

.editable-table .btn-delete-fund:hover {
    background-color: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

/* 新增一行按钮样式 */
.btn-success {
    background: linear-gradient(135deg, #198754 0%, #146c43 100%);
    border: none;
    box-shadow: 0 2px 4px rgba(25, 135, 84, 0.2);
}

.btn-success:hover {
    background: linear-gradient(135deg, #157347 0%, #0f5132 100%);
    box-shadow: 0 4px 8px rgba(25, 135, 84, 0.3);
    transform: translateY(-1px);
}

/* 账号列表字段颜色样式 */
.code-color {
    color: #e83e8c !important; /* 粉红色 - 用于实盘账号 */
    font-weight: 500;
}

.bs-info-rgb {
    color: rgb(0, 86, 179) !important; /* 蓝色 - 用于模拟账号（更暗的蓝色） */
}

/* 实盘账号徽章背景色 */
.badge-code-bg {
    background-color: #e83e8c !important; /* 粉红色背景 */
}

/* 账户权益超浅灰色 */
.text-extra-muted {
    color: #adb5bd !important; /* 比 text-muted 更浅的灰色 */
}

/* 账户下拉菜单选中状态颜色样式 */
/* 模拟账号（测试账号）选中时 - 蓝色背景，白色文字 */
.dropdown-item.active:has(.bs-info-rgb),
.dropdown-item:active:has(.bs-info-rgb) {
    background-color: rgb(0, 86, 179) !important;
}

.dropdown-item.active:has(.bs-info-rgb) .bs-info-rgb,
.dropdown-item:active:has(.bs-info-rgb) .bs-info-rgb,
.dropdown-item:hover:has(.bs-info-rgb) .bs-info-rgb {
    color: white !important;
}

/* 实盘账号选中时 - 粉红色背景，白色文字 */
.dropdown-item.active:has(.code-color),
.dropdown-item:active:has(.code-color) {
    background-color: #e83e8c !important;
}

.dropdown-item.active:has(.code-color) .code-color,
.dropdown-item:active:has(.code-color) .code-color,
.dropdown-item:hover:has(.code-color) .code-color {
    color: white !important;
}

/* 悬停状态也应用相同背景色 */
.dropdown-item:hover:has(.bs-info-rgb) {
    background-color: rgb(0, 86, 179) !important;
}

.dropdown-item:hover:has(.code-color) {
    background-color: #e83e8c !important;
}

/* ==================== 趋势页按钮组样式 ==================== */

/* 分类按钮激活状态样式 */
/* 注：btn-outline-secondary.active 使用 Bootstrap 默认样式，
   不在此处覆盖，以免影响其他页面（如订单查询页）的按钮激活色 */
.btn-outline-warning.active {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #fff !important;
}

.btn-outline-primary.active {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: #fff !important;
}

.btn-outline-danger.active {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: #fff !important;
}

.btn-outline-success.active {
    background-color: #198754 !important;
    border-color: #198754 !important;
    color: #fff !important;
}

.btn-outline-info.active {
    background-color: #0dcaf0 !important;
    border-color: #0dcaf0 !important;
    color: #fff !important;
}

/* 周期按钮样式 */
.btn-period {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* MACD 排序按钮选中状态 */
.sort-period-btn.active {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: #fff !important;
}

/* MACD 排序按钮组样式 */
#macdSortButtons .sort-period-btn {
    padding: 4px 12px;
    font-size: 12px;
    margin-right: 0 !important;  /* 覆盖通用规则，移除右边距 */
    border-radius: 0 !important;  /* 按钮组内按钮移除圆角 */
}

/* 第一个按钮左侧圆角 */
#macdSortButtons .sort-period-btn:first-child {
    border-top-left-radius: 0.25rem !important;
    border-bottom-left-radius: 0.25rem !important;
}

/* 最后一个按钮右侧圆角 */
#macdSortButtons .sort-period-btn:last-child {
    border-top-right-radius: 0.25rem !important;
    border-bottom-right-radius: 0.25rem !important;
}

/* 移除按钮之间的边框重叠 */
#macdSortButtons .sort-period-btn + .sort-period-btn {
    margin-left: -1px !important;
}

/* 类别下拉菜单样式 */
.category-dropdown {
    position: relative;
    display: inline-block;
}

.category-dropdown .btn-category-filter {
    border: 1px solid var(--bs-border-color, #dee2e6);
    background-color: transparent;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    color: var(--bs-body-color, #212529);
    transition: all 0.2s;
    border-left: 2px solid #6c757d;  /* 前面添加竖线 */
}

.category-dropdown .btn-category-filter:hover {
    background-color: var(--bs-tertiary-bg, #f8f9fa);
    border-color: var(--bs-border-color-translucent, #adb5bd);
}

.category-dropdown .btn-category-filter.active {
    border-color: #0d6efd !important;
    color: #0d6efd !important;
}

.category-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 160px;
    padding: 0.375rem 0;
    margin: 0.125rem 0 0;
    font-size: 0.875rem;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.175);
}

.category-dropdown:hover .category-dropdown-menu {
    display: block;
}

.category-dropdown-menu .dropdown-item {
    display: block;
    width: 100%;
    padding: 0.375rem 1.5rem;
    clear: both;
    font-weight: 400;
    color: #212529;
    text-align: inherit;
    text-decoration: none;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
    cursor: pointer;
    transition: all 0.15s;
}

.category-dropdown-menu .dropdown-item:hover {
    color: #1e2125;
    background-color: #e9ecef;
}

.category-dropdown-menu .dropdown-item.active {
    color: #0d6efd;
    background-color: #e7f1ff;
    font-weight: 500;
}