/**
 * 二手车商城 - 通用样式
 */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
        'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: var(--gray-800);
    background: var(--gray-100);
    line-height: 1.6;
    min-height: 100vh;
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

.form-label .required::after {
    content: ' *';
    color: var(--danger);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    transition: var(--transition);
    background: white;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

/* 卡片 */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* 标签 */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
}

.tag-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.tag-success {
    background: #d1fae5;
    color: var(--success);
}

.tag-warning {
    background: #fef3c7;
    color: var(--warning);
}

.tag-danger {
    background: #fee2e2;
    color: var(--danger);
}

.tag-gray {
    background: var(--gray-200);
    color: var(--gray-600);
}

/* 状态标签 */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-onsale {
    background: #d1fae5;
    color: #065f46;
}

.status-onsale::before {
    background: var(--success);
}

.status-sold {
    background: #fee2e2;
    color: #991b1b;
}

.status-sold::before {
    background: var(--danger);
}

.status-off {
    background: var(--gray-200);
    color: var(--gray-600);
}

.status-off::before {
    background: var(--gray-400);
}

/* 空状态 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--gray-500);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state-desc {
    font-size: 14px;
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    z-index: 9999;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 320px;
    word-break: break-word;
}

.toast.show {
    transform: translateX(0);
}

.toast-info {
    background: var(--primary);
}

.toast-success {
    background: var(--success);
}

.toast-warning {
    background: var(--warning);
}

.toast-error {
    background: var(--danger);
}

/* 确认对话框 */
.confirm-overlay,
.modal-overlay {
    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: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.confirm-overlay.show,
.modal-overlay.show {
    opacity: 1;
}

.confirm-dialog {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 360px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.confirm-overlay.show .confirm-dialog {
    transform: scale(1);
}

.confirm-message {
    font-size: 15px;
    margin-bottom: 20px;
    color: var(--gray-800);
    line-height: 1.6;
}

.confirm-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* 模态框 */
.modal-container {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-container {
    transform: scale(1);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-500);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* 图片上传 */
.image-upload {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--gray-50);
}

.image-upload:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.image-upload-icon {
    font-size: 32px;
    color: var(--gray-400);
    margin-bottom: 8px;
}

.image-upload-text {
    font-size: 14px;
    color: var(--gray-500);
}

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
}

.image-preview-remove:hover {
    background: var(--danger);
}

/* 响应式 */
@media (max-width: 768px) {
    .toast {
        left: 16px;
        right: 16px;
        top: auto;
        bottom: 80px;
        transform: translateY(120%);
        max-width: none;
        font-size: 14px;
        padding: 10px 16px;
        border-radius: 8px;
        text-align: center;
    }

    .toast.show {
        transform: translateY(0);
    }

    .confirm-dialog,
    .modal-container {
        width: calc(100% - 24px);
        max-height: 80vh;
    }

    .confirm-dialog {
        padding: 20px;
    }

    .confirm-message {
        font-size: 14px;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-header h3 {
        font-size: 15px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-close {
        width: 36px;
        height: 36px;
        font-size: 22px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
    }

    .btn-lg {
        padding: 12px 20px;
        font-size: 16px;
    }

    .form-input,
    .form-select,
    .form-textarea {
        padding: 12px 14px;
        font-size: 16px;
    }

    .form-label {
        font-size: 14px;
    }

    .form-hint,
    .form-error {
        font-size: 12px;
    }

    .card-header {
        padding: 14px 16px;
    }

    .card-body {
        padding: 16px;
    }

    .card-footer {
        padding: 10px 16px;
    }

    .tag {
        font-size: 11px;
        padding: 2px 8px;
    }

    .status-badge {
        font-size: 11px;
        padding: 3px 8px;
    }

    .image-upload {
        padding: 16px;
    }

    .image-upload-icon {
        font-size: 28px;
    }

    .image-upload-text {
        font-size: 13px;
    }

    .image-preview-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .image-preview-remove {
        width: 24px;
        height: 24px;
        font-size: 14px;
    }
}

/* 动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.animate-fade-in {
    animation: fadeIn 0.3s ease;
}

.animate-slide-up {
    animation: slideUp 0.3s ease;
}

/* 骨架屏 */
.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========== 备案号 ========== */
.mine-icp {
    padding: 24px 16px 32px;
    text-align: center;
    font-size: 12px;
}

.mine-icp a {
    color: var(--gray-400);
    text-decoration: none;
}

.login-footer .footer-icp {
    font-size: 12px;
}

.login-footer .footer-icp a {
    color: var(--gray-400);
    text-decoration: none;
}

.login-footer .footer-icp a:hover {
    color: var(--gray-600);
}
