/* 响应式设计 */
:root {
    --primary-color: #0d6efd;
    --sidebar-width: 250px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
}

/* 登录页面 */
.login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 24px;
}

/* 主容器 */
.main-container {
    min-height: 100vh;
}

/* 导航栏样式 - 渐变背景+书法字体 */
.navbar.bg-dark {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    height: 56px !important;
    min-height: 56px !important;
    max-height: 56px !important;
}

.navbar .navbar-brand {
    font-family: 'Liu Jian Mao Cao', cursive;
    font-size: 26px;
    opacity: 0.55;
    letter-spacing: 5px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.sidebar {
    height: calc(100vh - 56px);
    position: fixed;
    left: 0;
    top: 56px;
    padding-top: 20px;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
    background-color: #f8f9fa;
}

.sidebar .nav-link {
    color: #333;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar .nav-link:hover {
    background-color: #e9ecef;
    border-left-color: var(--primary-color);
}

.sidebar .nav-link.active {
    background-color: #e7f1ff;
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

main {
    margin-top: 56px;
    margin-left: var(--sidebar-width);
    padding: 20px;
}

/* 页面内容 */
.page-header {
    margin-bottom: 30px;
}

.page-header h2 {
    font-size: 28px;
    font-weight: bold;
    color: #333;
}

/* 表格样式 */
.table-responsive {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.table {
    margin-bottom: 0;
}

.table thead {
    background-color: #f8f9fa;
}

.table thead th {
    border: none;
    padding: 15px;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

.table tbody td {
    padding: 12px 15px;
    vertical-align: middle;
    border-bottom: 1px solid #dee2e6;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.form-control, .form-select {
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px 15px;
    font-size: 14px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* 按钮样式 */
.btn {
    border-radius: 5px;
    font-weight: 600;
    padding: 10px 20px;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0b5ed7;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* 卡片样式 */
.card {
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

/* 分页 */
.pagination {
    margin-top: 20px;
    justify-content: center;
}

.page-link {
    color: var(--primary-color);
    border: 1px solid #dee2e6;
}

.page-link:hover {
    background-color: var(--primary-color);
    color: white;
}

/* 警告/成功消息 */
.alert {
    border: none;
    border-radius: 5px;
    margin-bottom: 20px;
}

/* ========== 移动端响应式设计 ========== */
@media (max-width: 768px) {
    /* 
     * 移动端导航栏重构 - 简单固定布局
     * 使用固定的56px高度，不做动态计算
     */

    /* 顶部导航栏 - 固定在最顶部，移动端渐变背景 */
    .navbar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1050 !important;
        height: 56px !important;
        min-height: 56px !important;
        max-height: 56px !important;
        padding: 0 15px !important;
        margin: 0 !important;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    }

    /* 导航栏内部布局 */
    .navbar .container-fluid {
        height: 100% !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    /* 品牌文字 - 移动端书法字体半透明 */
    .navbar-brand {
        font-family: 'Liu Jian Mao Cao', cursive !important;
        font-size: 28px !important;
        padding: 0 !important;
        margin: 0 !important;
        opacity: 0.55 !important;
        letter-spacing: 6px !important;
        text-shadow: 1px 1px 2px rgba(0,0,0,0.2) !important;
        font-weight: normal !important;
    }

    /* 三横杠按钮 */
    .navbar-toggler {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 8px !important;
        border: none !important;
        background: transparent !important;
    }

    .navbar-toggler:focus {
        box-shadow: none !important;
        outline: none !important;
    }

    .navbar-toggler-icon {
        width: 24px !important;
        height: 24px !important;
    }

    /* 隐藏桌面端的用户信息和退出按钮 */
    .navbar-collapse {
        display: none !important;
    }

    /* 主容器 - 顶部留出导航栏空间 */
    #mainPage > .container-fluid,
    .main-container > .container-fluid {
        padding-top: 56px !important;
    }

    /* 侧边栏 - 固定定位，默认隐藏在左侧 */
    .sidebar {
        position: fixed !important;
        top: 56px !important;
        left: 0 !important;
        width: 200px !important;
        height: calc(100vh - 56px) !important;
        height: calc(100dvh - 56px) !important;
        background: #fff !important;
        border-right: 1px solid #dee2e6 !important;
        z-index: 1040 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease !important;
        overflow-y: auto !important;
        padding-top: 10px !important;
    }

    /* 侧边栏展开状态 */
    .sidebar.show {
        transform: translateX(0) !important;
    }

    /* 侧边栏遮罩层 */
    .sidebar-backdrop {
        position: fixed !important;
        top: 56px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: rgba(0, 0, 0, 0.5) !important;
        z-index: 1035 !important;
        display: none !important;
    }

    .sidebar-backdrop.show {
        display: block !important;
    }

    /* 侧边栏退出登录按钮 */
    .sidebar-logout {
        color: #dc3545 !important;
        font-weight: 500 !important;
    }

    /* 悬浮菜单按钮 - 已禁用 */
    .floating-menu-btn {
        display: none !important;
    }

    /* 主内容区 */
    main {
        margin-left: 0 !important;
        margin-top: 0 !important;
        padding: 10px !important;
    }

    /* 其他移动端样式 */
    .page-header h2 {
        font-size: 18px;
    }

    .table {
        font-size: 12px;
    }

    .table thead th, .table tbody td {
        padding: 6px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    /* 搜索表单紧凑布局 */
    .search-form-mobile {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .search-form-mobile .form-group {
        flex: 1 1 calc(50% - 4px);
        min-width: 140px;
        margin-bottom: 0 !important;
    }

    .search-form-mobile label {
        font-size: 12px;
        margin-bottom: 2px;
    }

    .search-form-mobile .form-control,
    .search-form-mobile .form-select {
        padding: 6px 8px;
        font-size: 13px;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 工具栏 */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar .btn {
    flex: 0 0 auto;
}

@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
    }

    .toolbar .btn {
        width: 100%;
    }
}

/* 出库移动端卡片 */
.stockout-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stockout-mobile-card {
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    background: #fff;
}

.stockout-mobile-card .card-body {
    padding: 8px 10px;
}

/* 卡片头部：单号+状态徽章 */
.stockout-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.stockout-card-header .order-number {
    font-weight: 600;
    font-size: 13px;
    color: #333;
}

.stockout-card-header .badges {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.stockout-card-header .badge {
    font-size: 10px;
    padding: 2px 5px;
}

/* 客户信息：单行显示 */
.stockout-card-customer {
    font-size: 13px;
    color: #555;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stockout-card-customer strong {
    color: #333;
}

/* 金额网格：三列紧凑显示 */
.stockout-card-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 6px;
    padding: 6px 8px;
    background: #f8f9fa;
    border-radius: 4px;
}

.stockout-card-metrics .metric {
    text-align: center;
}

.stockout-card-metrics .metric-label {
    font-size: 10px;
    color: #888;
    display: block;
}

.stockout-card-metrics .metric-value {
    font-size: 13px;
    font-weight: 600;
}

.stockout-card-metrics .metric-value.total { color: #333; }
.stockout-card-metrics .metric-value.paid { color: #28a745; }
.stockout-card-metrics .metric-value.owed { color: #dc3545; }

/* 底部：状态+操作按钮 */
.stockout-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stockout-card-status {
    font-size: 12px;
}

.stockout-card-actions {
    display: flex;
    gap: 4px;
}

.stockout-card-actions .btn {
    padding: 4px 10px;
    font-size: 12px;
}

/* 超紧凑模式 - 超小屏幕 */
@media (max-width: 400px) {
    .stockout-mobile-card .card-body {
        padding: 6px 8px;
    }

    .stockout-card-header .order-number {
        font-size: 12px;
    }

    .stockout-card-metrics .metric-value {
        font-size: 12px;
    }
}

/* 库存补货卡片 */
.restock-grid .restock-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.restock-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
}

.restock-quantity {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0d6efd;
}

.restock-card-body {
    padding: 4px 0;
}

.restock-card-footer .btn {
    width: 100%;
    padding: 3px 6px;
    font-size: 0.8rem;
}

.restock-card.restock-critical {
    border-color: #f5c2c7;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.12);
}

.restock-card.restock-low {
    border-color: #ffe69c;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.12);
}

.restock-card.restock-healthy {
    border-color: #bcd1ff;
}

@media (max-width: 576px) {
    .restock-card {
        padding: 8px;
    }
    .restock-quantity {
        font-size: 1.05rem;
    }
}

/* 搜索增强下拉 */
.select-search-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.select-search-input {
    font-size: 0.95rem;
    padding: 8px 12px;
}

@media (max-width: 576px) {
    .select-search-input {
        font-size: 1rem;
    }
}

/* 设置中心用户列表 - 响应式修复 */
#settingsUsersTable .btn { white-space: nowrap; min-width: 88px; }
#settingsUsersTable input.form-control-sm { min-width: 120px; }
@media (max-width: 576px) {
    #settingsUsersTableView { display: none !important; }
    #settingsUsersCardView { display: block !important; }
    #settingsUsersTable td { padding: 8px; }
    #settingsUsersTable .input-group { flex-wrap: nowrap; gap: 6px; }
    #settingsUsersTable .input-group .form-control { min-width: 90px; }
    #settingsUsersTable .d-flex { gap: 6px; flex-wrap: wrap; }
    #settingsUsersTable .btn { font-size: 12px; padding: 6px 10px; }
}
@media (min-width: 577px) {
    #settingsUsersCardView { display: none !important; }
}

/* 产品选择器模态框 */
.product-picker-categories {
    width: 90px;
    min-width: 90px;
    background: #f5f5f5;
    overflow-y: auto;
    border-right: 1px solid #eee;
    flex-shrink: 0;
}

.category-tab {
    padding: 14px 8px;
    text-align: center;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    word-break: break-all;
    line-height: 1.3;
}

.category-tab:hover {
    background: #fff;
}

.category-tab.active {
    background: #fff;
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.product-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: #fff;
}

.product-picker-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f0f0f0;
}

.product-picker-item:hover {
    background: #f8f9fa;
}

.product-picker-item:active {
    background: #e8f4ff;
}

.product-picker-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    background: #f5f5f5;
    margin-right: 10px;
    flex-shrink: 0;
    border: 1px solid #eee;
}

.product-picker-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.product-picker-name {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-picker-price {
    font-size: 14px;
    color: #e74c3c;
    font-weight: 500;
}

.product-picker-unit {
    font-size: 12px;
    color: #999;
}

.product-picker-spec {
    font-size: 12px;
    color: #999;
}

.product-picker-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.product-picker-stock {
    font-size: 12px;
    color: #999;
}

.product-picker-search input {
    border-radius: 6px;
    font-size: 14px;
}

.product-picker-search input:focus {
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}

/* 产品选择按钮样式 */
.btn-select-product {
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: 1px dashed #ccc;
    background: #fafafa;
    color: #666;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-select-product:hover {
    border-color: var(--primary-color);
    background: #f0f7ff;
    color: var(--primary-color);
}

.btn-select-product.has-product {
    border-style: solid;
    border-color: #28a745;
    background: #f0fff4;
    color: #333;
}

/* 移动端优化 */
@media (max-width: 576px) {
    .product-picker-categories {
        width: 72px;
        min-width: 72px;
    }
    
    .category-tab {
        padding: 12px 6px;
        font-size: 12px;
    }
    
    .product-picker-thumb {
        width: 44px;
        height: 44px;
    }
    
    .product-picker-item {
        padding: 8px 10px;
    }
    
    .product-picker-name {
        font-size: 14px;
    }
}
