/* Admin panel - matches site style */
.admin-back-link {
    position: absolute;
    right: 2rem;
    top: 1.5rem;
    color: white;
    text-decoration: none;
    font-weight: 500;
    z-index: 2;
}
.admin-back-link:hover {
    text-decoration: underline;
}

.admin-user-display {
    margin-right: 1rem;
    font-weight: 500;
}

.admin-header-actions {
    display: inline-flex;
    gap: 0.5rem;
    margin-right: 1rem;
}

.admin-header-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    background: rgba(255,255,255,0.2);
    color: white;
}

.admin-header-btn:hover {
    background: rgba(255,255,255,0.3);
}

.admin-logout-btn {
    background: rgba(231,76,60,0.8);
}

.admin-logout-btn:hover {
    background: rgba(231,76,60,1);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
}

/* 修改密码弹窗 - 布局与样式优化 */
.modal-content.modal-changepw {
    padding: 24px;
}

.modal-changepw-title {
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-changepw-form .modal-changepw-field {
    margin-bottom: 16px;
}

.modal-changepw-form .modal-changepw-field:last-of-type {
    margin-bottom: 24px;
}

.modal-changepw-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    margin-bottom: 6px;
}

.modal-changepw-form input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95rem;
}

.modal-changepw-form input:focus {
    outline: none;
    border-color: #764ba2;
}

.modal-changepw-actions {
    display: flex;
    gap: 12px;
    margin-top: 0;
}

.modal-changepw-actions .admin-btn-changepw {
    flex: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-changepw-actions .admin-btn-cancel {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.modal-changepw-actions .admin-btn-cancel:hover {
    background: rgba(102, 126, 234, 0.08);
}

.modal-changepw-error {
    color: #e74c3c;
    font-size: 0.9rem;
    margin-top: 12px;
    display: none;
}

/* 一、全局基础调整 */
.admin-main {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
}

.admin-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    box-sizing: border-box;
}

.admin-section {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin-bottom: 2rem;
    border: 1px solid rgba(0,0,0,0.05);
}

.admin-module-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #2c3e50;
    padding-bottom: 0;
    border: none;
}

.admin-two-col {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 1.5rem;
    align-items: flex-start;
}

.admin-col-brand {
    flex: 0 0 320px;
    flex-shrink: 0;
}

.admin-col-product {
    flex: 1 1 auto;
    min-width: 0;
}

/* 通用元素：输入框/下拉框 36px 高，按钮 36px 高 */
.admin-section input[type="text"],
.admin-section input[type="number"],
.admin-section input[type="email"],
.admin-section input[type="password"],
.admin-section select {
    height: 36px;
    padding: 0 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
}

.admin-section input[type="file"] {
    padding: 6px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9rem;
}

.admin-section textarea {
    min-height: 100px;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    resize: vertical;
}

.admin-btn {
    height: 36px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.9rem;
}

.admin-btn-brand {
    width: 100px;
}

.admin-btn-product {
    width: 120px;
}

@media (max-width: 900px) {
    .product-form-two-col {
        flex-direction: column;
    }
}

@media (max-width: 600px) {
    .admin-wrapper {
        padding: 16px;
    }
    .admin-two-col {
        flex-direction: column;
        flex-wrap: wrap;
    }
    .admin-col-brand {
        flex: 0 0 auto;
    }
    .admin-col-product {
        min-width: 0;
    }
    .brand-form-horizontal {
        flex-direction: column;
        align-items: stretch;
    }
    .brand-input {
        width: 100% !important;
    }
}

/* 二、品牌管理：水平表单 */
.brand-form-box {
    margin-bottom: 20px;
}

.brand-form-horizontal {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.brand-form-horizontal label {
    margin: 0;
    font-weight: 500;
    color: #2c3e50;
}

.brand-input {
    width: 220px !important;
    flex-shrink: 0;
}

.brand-list-box {
    margin-top: 20px;
}

/* 品牌表格：列宽 + 斑马纹 */
.brand-table .col-id { width: 60px; }
.brand-table .col-name { width: auto; }
.brand-table .col-actions { width: 120px; }

/* 三、产品管理：两列表单 */
.product-form-box {
    margin-bottom: 2rem;
}

.product-form-two-col {
    display: flex;
    gap: 24px;
}

.product-form-left,
.product-form-right {
    flex: 1;
    min-width: 0;
}

.product-form-left .form-group,
.product-form-right .form-group {
    margin-bottom: 24px;
}

.product-form-left .form-group:last-child,
.product-form-right .form-group:last-child {
    margin-bottom: 0;
}

.product-form-left label,
.product-form-right label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #2c3e50;
}

.product-form-left input,
.product-form-left select,
.product-form-right input,
.product-form-right select,
.product-form-right textarea {
    width: 100%;
}

/* Description 占满右侧宽度，增高，与 Price 行对齐 */
.product-form-right .form-group-desc {
    margin-bottom: 20px;
}

.product-form-right .form-group-desc textarea {
    height: 120px;
    min-height: 120px;
    width: 100%;
}

/* Add Product 按钮：描述框下方、右对齐，操作动线 填完描述->点添加 */
.product-form-right .form-actions-wrap {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    margin-top: 20px;
    margin-bottom: 24px;
}

.product-form-right #current-image-preview {
    margin-top: 12px;
}

.form-actions-right {
    justify-content: flex-end;
    gap: 12px;
}

/* 产品表格：列宽 + 图片缩略图 */
.products-table .col-id { width: 60px; }
.products-table .col-image { width: 80px; }
.products-table .col-model { width: auto; }
.products-table .col-brand { width: auto; }
.products-table .col-price { width: 100px; text-align: right; }
.products-table .col-actions { width: 140px; }

.products-table td.col-price {
    text-align: right;
}

.admin-section table img,
.products-table .product-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}

#current-image-preview .preview-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

#current-image-preview img,
#current-image-preview .preview-thumb {
    max-width: 150px;
    max-height: 150px;
    object-fit: contain;
    margin-top: 0.5rem;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.admin-section .add-to-cart-btn {
    margin-top: 0;
    height: 36px;
}

.admin-section .checkout-btn {
    background: #95a5a6;
}
.admin-section .checkout-btn:hover {
    background: #7f8c8d;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-section th, .admin-section td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
}

.admin-section th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
}

/* 斑马纹 + 行悬停 */
.admin-section tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.admin-section tbody tr:hover {
    background: #e9ecef !important;
}

/* Edit/Delete 按钮间距 4px */
.admin-section .btn-edit {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.35rem 0.7rem;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-right: 4px;
}
.admin-section .btn-edit:hover {
    background: #764ba2;
}

.admin-section .btn-danger {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 0.35rem 0.7rem;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}
.admin-section .btn-danger:hover {
    background: #c0392b;
}

.list-box {
    background: #fafbfc;
    padding: 1.5rem;
    border-radius: 12px;
    margin-top: 1rem;
}

/* 分页：表格底部居中，简化为 上一页/页码/下一页 */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem;
    flex-wrap: wrap;
}

.pagination-bottom {
    margin-top: 1rem;
}

.products-list-box .pagination {
    min-height: 40px;
}

.pagination-info, .pagination-page {
    font-size: 0.9rem;
    color: #666;
}

.pagination-btn {
    padding: 0.4rem 0.8rem;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.pagination-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Profile page */
.profile-section {
    max-width: 480px;
    margin: 2rem auto;
}

.profile-info p {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: #2c3e50;
}

.profile-info strong {
    display: inline-block;
    min-width: 5rem;
    color: #555;
}

.profile-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

.profile-section .logout-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.profile-section .logout-btn:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
}

.admin-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}
