/* ==========================================
   赠品录入系统 - 全局样式
   ========================================== */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== 头部导航 ===== */
.app-header {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    padding: 16px 24px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.app-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.role-super { background: #fef3c7; color: #92400e; }
.role-admin { background: #dbeafe; color: #1e40af; }
.role-input { background: #d1fae5; color: #065f46; }

.btn-outline-white {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.5);
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-outline-white:hover {
    background: rgba(255,255,255,0.15);
    border-color: #fff;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.nav-tab {
    padding: 8px 20px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.85);
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s;
}

.nav-tab:hover {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

.nav-tab.active {
    background: #fff;
    color: var(--primary);
    font-weight: 600;
}

/* ===== 卡片 ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 18px;
    margin-bottom: 12px;
}

.card-body {
    padding: 24px;
}

/* ===== Tab切换 ===== */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== 表单 ===== */
.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}

.form-input, .form-select, .form-textarea {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #fff;
    color: var(--text);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-input { width: 240px; }
.form-select { width: 200px; }
.form-textarea { width: 100%; resize: vertical; }

.required { color: var(--danger); }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #059669; }

.btn-warning {
    background: var(--warning);
    color: #fff;
}
.btn-warning:hover { background: #d97706; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #dc2626; }

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== 录入表单 ===== */
.input-form {
    max-width: 600px;
}

.input-form .form-group {
    margin-bottom: 20px;
}

.input-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}

.input-form .form-input {
    width: 100%;
}

/* ===== 图片粘贴区域 ===== */
.field-type-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    vertical-align: middle;
    margin-left: 4px;
}
.field-type-image {
    background: #ede9fe;
    color: #7c3aed;
    border: 1px solid #c4b5fd;
}

.paste-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.paste-area:hover, .paste-area.active {
    border-color: var(--primary);
    background: rgba(79,70,229,0.03);
}

.paste-area .paste-icon {
    font-size: 36px;
    margin-bottom: 8px;
    opacity: 0.5;
}

.paste-area .paste-text {
    color: var(--text-muted);
    font-size: 13px;
}

.paste-area img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.paste-area .remove-img {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    display: none;
}

.paste-area.has-image .remove-img { display: block; }
.paste-area.has-image .paste-icon,
.paste-area.has-image .paste-text { display: none; }

.paste-area .uploading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 14px;
    color: var(--primary);
}

/* ===== 查询结果 ===== */
.query-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.query-result {
    margin-top: 24px;
}

.result-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.result-card .result-header {
    background: #f8fafc;
    padding: 12px 20px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.result-card .result-body {
    padding: 20px;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
}

.result-table th, .result-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.result-table th {
    background: #f8fafc;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 13px;
    width: 120px;
}

.result-table td {
    font-size: 14px;
}

.result-table img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}

.result-table img:hover {
    transform: scale(1.05);
}

.no-result {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 15px;
}

/* ===== 后台表格 ===== */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th, .data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 13px;
    position: sticky;
    top: 0;
}

.data-table tr:hover td {
    background: #f8fafc;
}

.data-table img {
    max-width: 80px;
    max-height: 60px;
    border-radius: 4px;
    cursor: pointer;
}

.exported-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.exported-yes { background: #d1fae5; color: #065f46; }
.exported-no  { background: #fef3c7; color: #92400e; }

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px 0;
}

.pagination button {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.pagination button:hover { background: #f1f5f9; }
.pagination button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ===== 弹窗 ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding-top: 60px;
    overflow-y: auto;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 640px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { transform: translateY(-20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 18px; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ===== 自定义字段项 ===== */
.custom-field-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.custom-field-item .form-input {
    width: 140px;
}

.custom-field-item .form-select {
    width: 100px;
}

.custom-field-item .field-order {
    width: 50px;
}

.custom-field-item .field-required-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    cursor: pointer;
}

/* ===== Toast提示 ===== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    padding: 12px 24px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 360px;
}

.toast.show {
    transform: translateX(0);
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--primary); }

/* ===== 图片预览弹窗 ===== */
.image-preview-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.image-preview-overlay.show {
    display: flex;
}

.image-preview-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .app-container { padding: 12px; }
    .app-header { padding: 16px; }
    .app-header h1 { font-size: 20px; }
    .card-body { padding: 16px; }
    .form-row { flex-direction: column; align-items: stretch; }
    .form-input, .form-select { width: 100%; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 8px 6px; }
}

/* ===== 登录页 ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text);
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 16px;
    min-height: 20px;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 16px;
}

/* ===== 小弹窗 ===== */
.modal-sm {
    max-width: 440px;
}

/* 文本辅助 */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
