/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.page-title {
    text-align: center;
    color: #333;
    margin-bottom: 40px;
    font-size: 32px;
}

/* 闪现消息 */
.flash-messages {
    margin-bottom: 20px;
}

.flash {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 16px;
}

.flash-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* 产品网格 */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.product-card {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.product-card.selected {
    border-color: #667eea;
    background: #e7e9ff;
}

.product-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 15px;
}

.product-name {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
}

.product-radio {
    margin-top: 10px;
}

.product-radio input[type="radio"] {
    margin-right: 5px;
}

/* 按钮 */
.button-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 25px;
}

.button-container .btn {
    width: 100%;
    margin-right: 0;
}

.btn {
    padding: 12px 40px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    margin-right: 10px;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-sm {
    padding: 8px 20px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
}

/* 选中的产品显示 */
.selected-product {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 30px;
    text-align: center;
}

.selected-product h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #666;
}

.product-display img {
    max-width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
    margin: 15px 0;
}

.product-display p {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

/* 表单 */
.redeem-form {
    max-width: 100%;
    margin: 0 auto;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="tel"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* 自定义下拉框样式 */
.custom-select {
    position: relative;
    width: 100%;
    user-select: none;
}

.custom-select-trigger {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    transition: border-color 0.3s;
}

.custom-select-trigger:hover {
    border-color: #667eea;
}

.custom-select.active .custom-select-trigger {
    border-color: #667eea;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.custom-select-trigger span {
    color: #333;
}

.custom-select-trigger .arrow-icon {
    width: 20px;
    height: 20px;
    color: #666;
    transition: transform 0.3s;
}

.custom-select.active .arrow-icon {
    transform: rotate(180deg);
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.custom-select.active .custom-select-options {
    display: block;
}

.custom-option {
    padding: 12px 15px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

.custom-option:hover {
    background-color: #f0f0f0;
}

.custom-option.selected {
    background-color: #667eea;
    color: white;
}

/* 滚动条美化 */
.custom-select-options::-webkit-scrollbar {
    width: 8px;
}

.custom-select-options::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 0 8px 0;
}

.custom-select-options::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.custom-select-options::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

.validation-message {
    margin: 20px 0;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
}

.validation-message.success {
    background: #d4edda;
    color: #155724;
}

.validation-message.error {
    background: #f8d7da;
    color: #721c24;
}

/* 成功/失败页面 */
.text-center {
    text-align: center;
}

.success-icon,
.error-icon {
    font-size: 100px;
    margin: 40px 0;
}

.success-icon {
    color: #28a745;
}

.error-icon {
    color: #dc3545;
}

.success-title,
.error-title {
    font-size: 36px;
    margin-bottom: 20px;
}

.success-message,
.error-message {
    font-size: 18px;
    color: #666;
    margin-bottom: 40px;
}

/* 管理后台 */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
}

.admin-header {
    background: white;
    padding: 20px 40px;
    border-radius: 15px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.admin-header h1 {
    color: #333;
    font-size: 24px;
}

.admin-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
}

.admin-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.admin-section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 24px;
}

.form-inline {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.form-inline label {
    font-weight: 600;
}

.form-inline input[type="number"] {
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    width: 150px;
}

/* 表格 */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table thead {
    background: #f8f9fa;
}

table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
}

table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
}

table tr:hover {
    background: #f8f9fa;
}

.code,
.password {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #667eea;
}

.generated-codes {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.generated-codes h3 {
    margin-bottom: 15px;
    color: #333;
}

.note {
    margin-top: 15px;
    color: #666;
    font-style: italic;
}

.no-data {
    text-align: center;
    color: #999;
    padding: 40px;
    font-size: 18px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
    }

    .page-title {
        font-size: 24px;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .admin-header {
        flex-direction: column;
        gap: 15px;
    }

    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .form-inline input[type="number"] {
        width: 100%;
    }

    table {
        font-size: 14px;
    }

    table th,
    table td {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   礼品选择页面样式 (新设计)
   ============================================ */

.gift-container {
    max-width: 400px;
    margin: 0 auto;
    background: linear-gradient(180deg, #f3f4f6 0%, #ffffff 100%);
    border-radius: 20px;
    padding: 30px 20px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* 顶部区域 */
.gift-header {
    text-align: center;
    margin-bottom: 40px;
}

.gift-icon {
    width: 120px;
    height: 120px;
    margin: 0 auto 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.gift-title {
    font-size: 28px;
    color: #333;
    font-weight: 700;
    margin-bottom: 10px;
}

.gift-subtitle {
    font-size: 16px;
    color: #666;
}

/* 产品网格 */
.gift-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.gift-card {
    position: relative;
}

.gift-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.gift-label {
    display: block;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

.gift-label:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.gift-radio:checked + .gift-label {
    border-color: #667eea;
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.3);
    transform: translateY(-5px);
}

.gift-radio:checked + .gift-label::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.gift-image {
    width: 100%;
    height: 120px;
    overflow: hidden;
    background: #f8f9fa;
}

.gift-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gift-label:hover .gift-image img {
    transform: scale(1.05);
}

.gift-name {
    padding: 15px;
    text-align: center;
    font-size: 16px;
    color: #333;
    font-weight: 600;
    background: white;
}

/* 确认按钮 */
.gift-footer {
    margin-bottom: 20px;
}

.gift-confirm-btn {
    width: 100%;
    padding: 18px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(90deg, #7c3aed 0%, #3b82f6 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.3);
}

.gift-confirm-btn:disabled {
    background: #d1d5db;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

.gift-confirm-btn:not(:disabled):hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.4);
}

.gift-confirm-btn:not(:disabled):active {
    transform: translateY(-1px);
}

/* 温馨提示 */
.gift-tips {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 15px 20px;
    margin-top: 25px;
    background: linear-gradient(135deg, #ede9fe 0%, #e0e7ff 100%);
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.gift-tips svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.gift-tips span {
    font-size: 14px;
    color: #4c1d95;
    line-height: 1.6;
}

/* 版权信息 */
.gift-copyright {
    text-align: center;
    padding: 20px 10px 10px;
    font-size: 13px;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
    margin-top: 20px;
}

/* 响应式设计 - 手机端优化 */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .gift-container {
        padding: 25px 15px 15px;
        border-radius: 15px;
    }

    .gift-icon {
        width: 90px;
        height: 90px;
        margin-bottom: 20px;
    }

    .gift-icon svg {
        width: 50px;
        height: 50px;
    }

    .gift-header {
        margin-bottom: 25px;
    }

    .gift-title {
        font-size: 22px;
        margin-bottom: 8px;
    }

    .gift-subtitle {
        font-size: 13px;
    }

    .gift-grid {
        gap: 12px;
        margin-bottom: 20px;
    }

    .gift-image {
        height: 160px;
    }

    .gift-name {
        font-size: 14px;
        padding: 10px;
    }

    .gift-confirm-btn {
        padding: 15px;
        font-size: 16px;
    }

    .gift-tips {
        padding: 12px 15px;
        font-size: 13px;
    }

    .gift-tips svg {
        width: 18px;
        height: 18px;
    }

    .gift-tips span {
        font-size: 13px;
    }

    .gift-copyright {
        font-size: 12px;
        padding: 15px 10px 5px;
    }

    .gift-footer {
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    .gift-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .gift-image {
        height: 140px;
    }

    .gift-title {
        font-size: 20px;
    }

    .gift-icon {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 375px) {
    .gift-container {
        padding: 20px 12px 12px;
    }

    .gift-title {
        font-size: 18px;
    }

    .gift-subtitle {
        font-size: 12px;
    }

    .gift-grid {
        gap: 8px;
    }

    .gift-image {
        height: 120px;
    }

    .gift-name {
        font-size: 12px;
        padding: 6px;
    }
}

/* ============================================
   管理后台分页和状态样式
   ============================================ */

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 30px;
    padding: 20px 0;
}

.page-link {
    padding: 8px 15px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    cursor: pointer;
}

.page-link:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
}

.page-link.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
    cursor: default;
}

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.status-unused {
    background: #d4edda;
    color: #155724;
}

.status-used {
    background: #f8d7da;
    color: #721c24;
}

/* 密码加密显示 */
.password-encrypted {
    color: #999;
    font-style: italic;
    font-size: 14px;
}

/* 产品缩略图 */
.product-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.product-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.product-cell span {
    font-weight: 600;
}

/* 响应式设计 - 分页 */
@media (max-width: 768px) {
    .pagination {
        flex-wrap: wrap;
        gap: 5px;
    }

    .page-link {
        padding: 6px 10px;
        font-size: 12px;
    }

    .product-cell {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .product-thumb {
        width: 40px;
        height: 40px;
    }
}

/* ============================================
   区域标题和刷新按钮样式
   ============================================ */

/* 区域标题容器 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    margin-bottom: 0;
    flex: 1;
}

/* 区域操作按钮组 */
.section-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* 刷新图标动画 */
.refresh-icon {
    display: inline-block;
    font-style: normal;
    transition: transform 0.5s ease;
}

.btn-secondary:hover .refresh-icon {
    transform: rotate(180deg);
}

.btn-secondary:active .refresh-icon {
    animation: spin 0.6s linear;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 响应式设计 - 区域标题 */
@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .section-actions .btn {
        flex: 1;
        min-width: 120px;
    }
}

/* ============================================
   订单号样式
   ============================================ */

.order-number {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #667eea;
    font-size: 14px;
    letter-spacing: 0.5px;
}
