/* 全局样式 */
body {
    background-color: #f8f9fa;
    min-height: 100vh;
    padding-top: 0;
    overflow-x: hidden;
}

/* 卡片样式 */
.card {
    margin-bottom: 20px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.card-header {
    font-weight: bold;
}

/* 仪表盘统计卡片 */
.stats-card {
    text-align: center;
    transition: all 0.3s;
}

.stats-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.stats-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.stats-number {
    font-size: 2rem;
    font-weight: bold;
}

.stats-label {
    font-size: 1rem;
    color: #6c757d;
}

/* 表格样式 */
.table th {
    background-color: #f8f9fa;
}

/* 导航栏活跃项样式 */
.navbar .nav-link.active {
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

/* 表单样式 */
.form-label {
    font-weight: 500;
}

/* 主要内容区域 */
.content-wrapper {
    padding: 20px 0;
}

/* 产品列表中的库存状态标识 */
.stock-status-low {
    color: #dc3545;
}

.stock-status-normal {
    color: #28a745;
}

/* 侧边栏导航样式 */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 0;
    box-shadow: 0 0 10px rgba(0,0,0,.1);
    background-color: #0d6efd;
    color: white;
    width: 250px;
    transition: all 0.3s ease;
}

.sidebar-sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    padding-top: 1rem;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar .navbar-brand {
    padding: 1rem;
    font-size: 1.3rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: block;
    width: 100%;
    color: white;
    text-decoration: none;
    text-align: center; /* 添加文本居中对齐 */
    margin: 0 auto; /* 添加水平居中对齐 */
    font-weight: bold; /* 加粗显示 */
}

.sidebar .navbar-nav {
    width: 100%;
    padding: 0.5rem 0;
}

.sidebar .nav-item {
    width: 100%;
}

.sidebar .nav-link {
    padding: 0.8rem 1rem;
    color: rgba(255,255,255,0.8);
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #fff;
    background-color: rgba(255,255,255,0.1);
    border-left: 3px solid #fff;
}

.sidebar .nav-link i {
    width: 24px;
    text-align: center;
    margin-right: 8px;
}

.main-content {
    margin-left: 250px;
    padding: 1rem;
    transition: all 0.3s ease;
    width: calc(100% - 250px);
    overflow-x: auto;
    box-sizing: border-box;
    max-width: 100%;
}

.user-dropdown {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

.user-dropdown .dropdown-toggle {
    color: white;
    text-decoration: none;
}

.user-dropdown .dropdown-menu {
    left: auto;
    right: 10px;
    margin-top: 0.5rem;
}

/* 相关样式 */
.chart-container {
    position: relative;
    margin: auto;
    height: 250px;
}

.product-legend {
    max-height: 220px;
    overflow-y: auto;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 6px;
    flex-shrink: 0;
}

.legend-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.legend-value {
    font-weight: bold;
    margin-left: 5px;
    white-space: nowrap;
}

/* 产品库存占比图表特有样式 */
.stock-chart-container {
    height: 250px;
}

/* 移动设备响应式处理 */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: fixed;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1050;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 0.5rem;
    }
    
    .sidebar-sticky {
        height: 100%;
    }
    
    .chart-container {
        height: 200px;
    }
    
    /* 移动端导航按钮 */
    .mobile-nav-toggle {
        display: block;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1060;
        background-color: #0d6efd;
        color: white;
        border: none;
        border-radius: 4px;
        padding: 8px 12px;
        font-size: 1.25rem;
        cursor: pointer;
    }
    
    /* 移动端表格优化 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 移动端按钮优化 */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 1rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
    }
    
    /* 表单元素优化 */
    .form-control, .form-select {
        height: 38px;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    /* 间距优化 */
    .card {
        margin-bottom: 15px;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    /* 移动端页面标题 */
    h2 {
        font-size: 1.5rem;
        margin-top: 40px; /* 为顶部导航按钮留出空间 */
    }
    
    /* 增大按钮点击区域 */
    .btn {
        min-height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 表单元素触摸优化 */
    .form-control, .form-select {
        min-height: 38px;
        padding: 10px 12px;
        font-size: 16px; /* 防止iOS自动缩放 */
    }
    
    /* 数字输入框优化 */
    .mobile-number-input {
        -moz-appearance: textfield; /* 移除Firefox默认箭头 */
    }
    
    .mobile-number-input::-webkit-outer-spin-button,
    .mobile-number-input::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    
    /* 移动端表格样式 */
    .table th, .table td {
        white-space: nowrap;
    }
    
    /* 移动端卡片样式 */
    .card {
        border-radius: 8px;
    }
    
    /* 移动端间距调整 */
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    /* 移动端表单布局 */
    .form-group {
        margin-bottom: 15px;
    }
    
    /* 移动端导航抽屉阴影 */
    .sidebar.show {
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    }
    
    /* 移动端页面标题 */
    h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    /* 移动端表格提示信息 */
    .mobile-table-notice {
        padding: 8px;
        background-color: #f8f9fa;
        border-radius: 4px;
        text-align: center;
    }
    
    /* 移动端滚动指示器 */
    .table-responsive::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 20px;
        background: linear-gradient(to right, rgba(255,255,255,0), rgba(0,0,0,0.05));
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    .table-responsive:not(.scrolled-right)::after {
        opacity: 1;
    }
    
    /* 下拉刷新指示器 */
    .refresh-indicator {
        padding: 10px;
        background-color: rgba(255, 255, 255, 0.9);
        border-radius: 50%;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
}

/* 小屏幕手机优化 */
@media (max-width: 576px) {
    .card-body {
        padding: 0.5rem;
    }
    
    .table th, .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.875rem;
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
    }
    
    .btn-group .btn {
        margin-bottom: 0.25rem;
        border-radius: 0.25rem !important;
    }
    
    /* 改进表单布局 */
    .row > [class*="col-"] {
        margin-bottom: 0.75rem;
    }
    
    /* 更紧凑的表单 */
    .form-label {
        margin-bottom: 0.25rem;
        font-size: 0.9rem;
    }
    
    /* 更紧凑的卡片 */
    .card-body {
        padding: 0.75rem;
    }
    
    /* 更小的按钮组 */
    .btn-group-sm > .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* 简化的警告框 */
    .alert {
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.75rem;
    }
}

/* 隐藏移动导航按钮（默认） */
.mobile-nav-toggle {
    display: none;
}

/* 登录页面样式 */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #0d6efd 0%, #0099ff 100%);
    z-index: 9999;
}

.login-card {
    width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: none;
}

.login-header {
    text-align: center;
    padding: 1.5rem 1rem;
    background-color: #0d6efd;
    color: white;
}

.login-logo {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: white;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 0;
    color: white;
}

.login-body {
    padding: 1.5rem;
    background: white;
}

.login-body .form-label {
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.login-body .form-control {
    margin-bottom: 1rem;
}

.login-body .btn-primary {
    padding: 0.5rem 1rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.login-body .text-muted {
    margin-top: 0.75rem !important;
    font-size: 0.85rem;
}

.login-body .form-check {
    margin-bottom: 1rem;
}

/* BOM编辑页面样式 */
.bom-item {
    border: 1px solid rgba(0,0,0,.125);
    border-radius: 0.25rem;
    padding: 15px;
    margin-bottom: 10px;
    position: relative;
    background-color: #fff;
    transition: all 0.2s;
}

.bom-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

.bom-remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
}

.auto-price-toggle {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid rgba(0,0,0,.125);
    border-radius: 0.25rem;
    background-color: #f8f9fa;
}

.total-price-display {
    font-size: 1.2rem;
    font-weight: bold;
    color: #0d6efd;
    margin-top: 10px;
}

/* Table responsiveness enhancement */
.table-responsive {
    width: 100%;
    margin-bottom: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    margin-bottom: 0;
}

/* 紧凑型表格样式 */
.table.table-hover.table-striped td, 
.table.table-hover.table-striped th {
    padding: 0.5rem;
    font-size: 0.9rem;
}

/* 改进表格按钮组样式 */
.table .btn-sm {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
}

/* Card content overflow handling */
.card {
    overflow: hidden;
    max-width: 100%;
}

.card-body {
    overflow-x: auto;
}

/* Table cell whitespace handling - 移除nowrap限制，允许文本换行 */
.table th, .table td {
    white-space: normal;
}

/* 运营管理页面样式 */
.operation-stats-card {
    transition: transform 0.3s;
    border-radius: 10px;
    overflow: hidden;
    height: 100%;
    position: relative;
}

.operation-stats-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.operation-stats-label {
    color: #6c757d;
    font-weight: 500;
    margin-bottom: 8px;
}

.operation-stats-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    opacity: 0.7;
}

.text-purple {
    color: #6f42c1;
}

/* 总销售额显示 */
.total-sales-display {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    background-color: #f8f9fa;
    margin: 15px 0;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.05);
}

/* 运营成本表格样式增强 */
.operation-table th {
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
}

.operation-table td {
    vertical-align: middle;
}

.profit-positive {
    color: #28a745;
    font-weight: 600;
}

.profit-negative {
    color: #dc3545;
    font-weight: 600;
}

/* 图表容器样式 */
.chart-container {
    padding: 15px;
    position: relative;
    min-height: 250px;
}

/* 销售数据周期切换按钮 */
.period-toggle .btn {
    padding: 0.25rem 1rem;
    transition: all 0.2s;
}

.period-toggle .btn.active {
    font-weight: 600;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}