/**
 * 仓库扫码枪 — 全局样式
 * 移动优先设计，适配 320px - 1024px
 */

/* ==================== 全局重置 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* ==================== 登录页 ==================== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 30px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.login-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-card h1 {
    font-size: 22px;
    margin-bottom: 4px;
}

.login-subtitle {
    color: #999;
    font-size: 13px;
    margin-bottom: 24px;
}

.login-tip {
    margin-top: 16px;
    color: #bbb;
    font-size: 12px;
}

/* ==================== 主布局 ==================== */
.scanner-app {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    background: #f0f2f5;
}

.scanner-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.scanner-header h1 {
    font-size: 17px;
    font-weight: 600;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

/* ==================== 标签栏 ==================== */
.scanner-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: #fff;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 47px;
    z-index: 99;
}

.tab-btn {
    padding: 10px 4px;
    border: none;
    background: none;
    font-size: 13px;
    color: #999;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.tab-content {
    display: none;
    padding: 12px;
}

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

/* ==================== 扫码区域 ==================== */
.scan-area {
    text-align: center;
    margin-bottom: 12px;
}

.qr-reader {
    width: 100%;
    margin: 0 auto 10px;
    border-radius: 10px;
    overflow: hidden;
    display: none;
}

.qr-reader video {
    width: 100%;
    border-radius: 10px;
}

/* 覆盖扫码引擎内部样式 */
.qr-reader video,
.qr-reader canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
}

/* Quagga overlay 层 */
.qr-reader .overlay {
    display: none;
}

#qr-shaded-region {
    border-width: 40px !important;
}

.scan-hint {
    color: #999;
    font-size: 13px;
    margin-top: 8px;
}

/* ==================== 扫码结果卡片 ==================== */
.scan-result {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.result-card {
    margin-bottom: 12px;
}

.result-info {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f5f5f5;
}

.result-label {
    color: #999;
    font-size: 13px;
}

.result-value {
    font-weight: 600;
    font-size: 14px;
    max-width: 60%;
    text-align: right;
    word-break: break-all;
}

/* ==================== 表单 ==================== */
.form-card {
    margin-bottom: 12px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
}

.required {
    color: #e53935;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
    color: #333;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

.form-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
}

/* ==================== 按钮 ==================== */
.btn-block {
    display: block;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.btn-secondary {
    background: #f0f2f5;
    color: #666;
    border: 1px solid #ddd;
}

.btn-success {
    background: linear-gradient(135deg, #52c41a 0%, #4caf50 100%);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #e53935 0%, #dc3545 100%);
    color: #fff;
}

.btn-sm {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #666;
    font-size: 13px;
    cursor: pointer;
}

.btn-primary:active, .btn-success:active, .btn-danger:active {
    transform: scale(0.97);
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.toast-success { background: #52c41a; color: #fff; }
.toast-error { background: #e53935; color: #fff; }
.toast-warning { background: #faad14; color: #fff; }
.toast-info { background: #333; color: #fff; }

/* ==================== 面板 ==================== */
.panel {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.panel-header h2 {
    font-size: 16px;
}

.stock-total {
    color: #999;
    font-size: 13px;
}

/* ==================== 库存卡片 ==================== */
.stock-card {
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
}

.stock-card:last-child {
    border-bottom: none;
}

.stock-card-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}

.stock-card-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #666;
    margin-top: 2px;
}

.expiry-danger { color: #e53935 !important; }
.expiry-warning { color: #faad14 !important; }

.alert-card {
    background: #fff8e1;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid #ffe082;
}

/* ==================== 出入库记录卡片 ==================== */
.record-card {
    padding: 12px;
    background: #fff;
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid #f0f0f0;
}

.record-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.record-qty {
    margin-left: auto;
    font-weight: 600;
    color: #333;
}

.record-card-meta {
    font-size: 12px;
    color: #999;
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
}

/* ==================== 徽章 ==================== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.badge-in { background: #e8f5e9; color: #4caf50; }
.badge-out { background: #ffebee; color: #e53935; }

/* ==================== 分页 ==================== */
.pagination {
    text-align: center;
    padding: 12px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.page-info {
    color: #999;
    font-size: 13px;
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    color: #ccc;
    padding: 40px 0;
    font-size: 14px;
}

/* ==================== 响应式 ==================== */
@media (max-width: 400px) {
    .scanner-tabs {
        grid-template-columns: repeat(2, 1fr);
    }

    .tab-btn {
        font-size: 12px;
        padding: 8px 4px;
    }

    .tab-content {
        padding: 10px;
    }

    .scanner-header h1 {
        font-size: 15px;
    }

    .login-card {
        padding: 30px 20px;
    }
}
