:root {
    --primary-blue: #3498db;
    --secondary-blue: #2980b9;
    --light-blue: #ecf0f1;
    --dark-blue: #2c3e50;
    --success-green: #27ae60;
    --warning-orange: #f39c12;
    --error-red: #e74c3c;
    --gray-light: #f8f9fa;
    --gray-medium: #6c757d;
    --gray-dark: #343a40;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--gray-light);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    color: var(--gray-dark);
    min-height: 100vh;
}

/* 导航栏样式 */
.navbar-custom {
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 0.8rem 0;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.5rem;
    color: white !important;
}

.navbar-brand:hover {
    color: rgba(255,255,255,0.9) !important;
}

.navbar-text {
    color: rgba(255,255,255,0.9) !important;
}

.nav-link {
    color: rgba(255,255,255,0.8) !important;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: white !important;
}

/* 按钮样式 */
.btn-primary-custom {
    background: var(--primary-blue);
    border-color: var(--secondary-blue);
    transition: all 0.3s ease;
    font-weight: 500;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
}

.btn-primary-custom:hover {
    background: var(--secondary-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    border-color: var(--secondary-blue);
}

.btn-success {
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
}

.btn-outline-secondary {
    border-radius: 6px;
}

/* 卡片样式 */
.card-custom {
    border: none;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 20px;
    overflow: hidden;
    background: white;
}

.card-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

.card-header-custom {
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
    color: white;
    border-radius: 15px 15px 0 0 !important;
    padding: 1rem 1.5rem;
    border: none;
}

.card-header-custom h5 {
    margin: 0;
    font-weight: 600;
    font-size: 1.1rem;
}

/* 登录页面样式 */
.login-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-card .form-control {
    border-radius: 10px;
    padding: 0.75rem 1rem;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.login-card .form-control:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

/* 扫码界面样式 */
.scanner-modal .modal-content {
    background: #000;
    border: none;
    border-radius: 15px;
    overflow: hidden;
}

.scanner-modal .modal-header {
    border-bottom: 1px solid #333;
    background: #1a1a1a;
}

.scanner-modal .modal-title {
    color: white;
    font-weight: 600;
}

.scanner-modal .btn-close {
    filter: invert(1);
    opacity: 0.8;
}

.scanner-modal .btn-close:hover {
    opacity: 1;
}

#scanner-viewport {
    width: 100%;
    height: 300px;
    background: #000;
    position: relative;
    overflow: hidden;
}

.scanner-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 250px;
    height: 150px;
    border: 2px solid var(--primary-blue);
    border-radius: 10px;
    box-shadow: 0 0 0 1000px rgba(0,0,0,0.3);
    pointer-events: none;
}

.scanner-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--primary-blue);
    animation: scan 2s linear infinite;
    box-shadow: 0 0 10px var(--primary-blue);
}

@keyframes scan {
    0% { top: 0; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

/* 商品图片样式 */
.product-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s ease;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.product-image:hover {
    transform: scale(1.1);
    border-color: var(--primary-blue);
}

.product-image-lg {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* 表格样式 */
.table-responsive {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    background-color: var(--light-blue);
    border: none;
    font-weight: 600;
    padding: 1rem;
    color: var(--dark-blue);
    border-bottom: 2px solid var(--primary-blue);
}

.table td {
    padding: 1rem;
    vertical-align: middle;
    border-color: #f1f3f4;
    background: white;
}

.table tbody tr:hover td {
    background-color: #f8f9fa;
}

.table-warning td {
    background-color: #fff3cd !important;
}

/* 表单样式 */
.form-control {
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.form-control:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--gray-dark);
}

.form-text {
    color: var(--gray-medium);
    font-size: 0.875rem;
}

.input-group-text {
    background-color: var(--light-blue);
    border: 2px solid #e9ecef;
    border-right: none;
    color: var(--gray-medium);
}

/* 警告提示 */
.alert {
    border: none;
    border-radius: 10px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border-left: 4px solid transparent;
}

.alert-success {
    background: linear-gradient(135deg, #d5f4e6, #eafaf1);
    color: var(--success-green);
    border-left-color: var(--success-green);
}

.alert-danger {
    background: linear-gradient(135deg, #fadbd8, #fdedec);
    color: var(--error-red);
    border-left-color: var(--error-red);
}

.alert-warning {
    background: linear-gradient(135deg, #fdebd0, #fef5e7);
    color: var(--warning-orange);
    border-left-color: var(--warning-orange);
}

.alert-info {
    background: linear-gradient(135deg, #d6eaf8, #ebf5fb);
    color: var(--secondary-blue);
    border-left-color: var(--secondary-blue);
}

/* 徽章样式 */
.badge {
    font-weight: 500;
    padding: 0.5em 0.75em;
    border-radius: 6px;
}

.badge.bg-success {
    background: linear-gradient(135deg, var(--success-green), #229954) !important;
}

.badge.bg-danger {
    background: linear-gradient(135deg, var(--error-red), #c0392b) !important;
}

.badge.bg-light {
    color: var(--gray-dark) !important;
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    min-width: 200px;
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.loading-text {
    color: var(--gray-dark);
    font-weight: 500;
    margin: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 移动端优化 */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
    
    .table-responsive {
        font-size: 0.9rem;
        border-radius: 8px;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .card-custom {
        margin-bottom: 15px;
        border-radius: 12px;
    }
    
    .card-header-custom {
        padding: 0.75rem 1rem;
    }
    
    .scanner-modal .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
    }
    
    .scanner-modal .modal-content {
        height: 100vh;
        border-radius: 0;
    }
    
    #scanner-viewport {
        height: 60vh;
    }
    
    .scanner-overlay {
        width: 80%;
        height: 30%;
    }
    
    .login-card {
        margin: 10px;
        padding: 1.5rem;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    input, select, textarea {
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    .product-image {
        min-width: 44px;
        min-height: 44px;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .scanner-modal .modal-content {
        background: #1a1a1a;
    }
    
    .scanner-overlay {
        border-color: #4dabf7;
    }
    
    .scanner-line {
        background: #4dabf7;
        box-shadow: 0 0 10px #4dabf7;
    }
}

/* 实用工具类 */
.text-primary-custom {
    color: var(--primary-blue) !important;
}

.bg-primary-custom {
    background-color: var(--primary-blue) !important;
}

.border-primary-custom {
    border-color: var(--primary-blue) !important;
}

.shadow-custom {
    box-shadow: 0 4px 6px rgba(52, 152, 219, 0.1) !important;
}

/* 代码样式 */
code {
    background: var(--light-blue);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: var(--primary-blue);
    font-weight: 500;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-blue);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-blue);
}

/* 空状态样式 */
.text-muted i {
    opacity: 0.6;
}

/* 输入验证样式 */
.is-invalid {
    border-color: var(--error-red) !important;
}

.is-invalid:focus {
    box-shadow: 0 0 0 0.2rem rgba(231, 76, 60, 0.25) !important;
}