/* ========== 基础重置和变量 ========== */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #eff6ff;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --text-dark: #1e293b;
    --text-medium: #475569;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-focus: #bfdbfe;
    --bg-white: #ffffff;
    --bg-light: #f8fafc;
    --bg-lightest: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* ========== 全局样式 ========== */
.book-form-container {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    font-family: var(--font-sans);
    color: var(--text-dark);
}

/* ========== 页头样式 ========== */
.page-header-wrapper {
    margin-bottom: 24px;
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
}

.header-title-section {
    display: flex;
    flex-direction: column;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.subtitle {
    margin: 8px 0 0 0;
    color: var(--text-medium);
    font-size: 0.9rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-medium);
    background-color: var(--bg-lightest);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.btn-back:hover {
    background-color: var(--border-color);
    color: var(--text-dark);
    text-decoration: none;
}

.btn-back i {
    font-size: 14px;
}

/* 进度条样式 */
.form-progress {
    min-width: 180px;
}

.progress-bar-container {
    height: 6px;
    background-color: var(--bg-lightest);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 3px;
    transition: width var(--transition-base);
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: right;
    display: block;
    margin-top: 4px;
}

/* ========== 表单布局 ========== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
}

.form-main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ========== 表单卡片样式 ========== */
.form-card {
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition-base);
}

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

.card-header {
    padding: 16px 20px;
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.card-title {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.9375rem;
}

.card-body {
    padding: 20px;
}

.form-section {
    padding: 0;
}

/* ========== 表单元素样式 ========== */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

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

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 8px;
    font-size: 0.9375rem;
}

.form-control {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-dark);
    background-color: var(--bg-white);
    background-clip: padding-box;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    border-color: var(--border-focus);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:disabled, .form-control[readonly] {
    background-color: var(--bg-lightest);
    opacity: 0.6;
}

.form-help {
    margin-top: 6px;
    font-size: 0.8125rem;
    color: var(--text-light);
}

.form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.char-counter {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* 带按钮输入框 */
.input-with-button {
    display: flex;
    align-items: center;
}

.input-with-button .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex-grow: 1;
}

.btn-append {
    height: 42px;
    padding: 0 14px;
    background-color: var(--bg-lightest);
    border: 1px solid var(--border-color);
    border-left: none;
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    color: var(--text-medium);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.btn-append:hover {
    background-color: var(--border-color);
    color: var(--text-dark);
}

/* 文本域 */
textarea.form-control {
    min-height: 150px;
    resize: vertical;
}

/* 数字输入控件 */
.number-control {
    display: flex;
    align-items: center;
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.number-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-lightest);
    border: 1px solid var(--border-color);
    color: var(--text-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1rem;
    user-select: none;
}

.number-btn:hover {
    background-color: var(--border-color);
    color: var(--text-dark);
}

.decrement {
    border-top-left-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-md);
}

.increment {
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

.number-control .form-control {
    flex: 1;
    border-radius: 0;
    border-left: none;
    border-right: none;
    text-align: center;
    padding: 10px 0;
}

/* 价格输入 */
.price-input {
    position: relative;
}

.currency-symbol {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-medium);
}

.price-input .form-control {
    padding-left: 30px;
}

.price-slider {
    margin-top: 16px;
}

.range-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background-color: var(--border-color);
    outline: none;
    margin: 14px 0;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--bg-white);
    box-shadow: var(--shadow-sm);
}

.slider-marks {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-light);
}

/* ========== 按钮样式 ========== */
.btn-primary {
    padding: 12px 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9375rem;
    cursor: pointer;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

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

.btn-secondary {
    padding: 10px 16px;
    background-color: var(--bg-white);
    color: var(--text-medium);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9375rem;
    cursor: pointer;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background-color: var(--bg-lightest);
    color: var(--text-dark);
}

.btn-secondary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(226, 232, 240, 0.5);
}

/* ========== 标签输入样式 ========== */
.tag-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tag-input-wrapper .form-control {
    flex-grow: 1;
}

.btn-tag-add {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-tag-add:hover {
    background-color: var(--primary-hover);
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    min-height: 32px;
}

.tag {
    display: inline-flex;
    align-items: center;
    background-color: var(--primary-light);
    border-radius: 50px;
    padding: 6px 10px 6px 14px;
    font-size: 0.8125rem;
    color: var(--primary-color);
    transition: all var(--transition-fast);
}

.tag:hover {
    background-color: rgba(59, 130, 246, 0.2);
}

.tag-text {
    margin-right: 6px;
}

.tag-remove {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all var(--transition-fast);
}

.tag-remove:hover {
    background-color: rgba(59, 130, 246, 0.3);
    color: white;
}

/* ========== 封面上传区域 ========== */
.cover-preview-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cover-preview {
    width: 100%;
    aspect-ratio: 5/7;
    background-color: var(--bg-lightest);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.cover-preview:hover {
    background-color: var(--bg-light);
}

.cover-preview.dragover {
    background-color: var(--primary-light);
}

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

.no-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-light);
    padding: 24px;
    text-align: center;
}

.no-cover-placeholder i {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.placeholder-tip {
    font-size: 0.8125rem;
    margin-top: 8px;
    color: var(--text-muted);
}

.upload-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.upload-btn-group {
    display: flex;
    gap: 8px;
}

.btn-upload {
    flex-grow: 1;
    padding: 10px 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

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

.btn-remove {
    width: 42px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-remove:hover {
    background-color: #fee2e2;
    border-color: #fca5a5;
    color: #ef4444;
}

.upload-tips {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ========== 表单提交区域 ========== */
.form-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.secondary-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.form-tip {
    margin-top: 8px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-align: center;
}

.form-tip i {
    color: var(--info-color);
    margin-right: 4px;
}

/* 必填项标记 */
.required {
    color: var(--danger-color);
    margin-left: 4px;
}

/* 无效输入状态 */
.is-invalid {
    border-color: var(--danger-color) !important;
}

.invalid-feedback {
    display: block;
    color: var(--danger-color);
    font-size: 0.8125rem;
    margin-top: 6px;
}

/* ========== Select2 定制 ========== */
.select2-container--classic .select2-selection--single {
    height: 42px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-white);
}

.select2-container--classic .select2-selection--single .select2-selection__rendered {
    line-height: 40px;
    color: var(--text-dark);
    padding-left: 14px;
}

.select2-container--classic .select2-selection--single .select2-selection__arrow {
    height: 40px;
    border-left: 1px solid var(--border-color);
}

.select2-container--classic .select2-selection--single:focus {
    border-color: var(--border-focus);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ========== 模态框样式 ========== */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
}

.modal-title {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 1.125rem;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 16px 20px;
}

.modal-btn {
    min-width: 100px;
}

/* 裁剪模态框 */
.img-container {
    max-height: 500px;
    overflow: hidden;
    margin-bottom: 20px;
}

#cropperImage {
    display: block;
    max-width: 100%;
}

.cropper-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 16px;
}

.control-group {
    display: flex;
    gap: 8px;
}

.control-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background-color: var(--bg-lightest);
    border: 1px solid var(--border-color);
    color: var(--text-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.control-btn:hover {
    background-color: var(--border-color);
    color: var(--text-dark);
}

/* 图书预览模态框 */
.preview-header {
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
}

.preview-body {
    padding: 0;
    background-color: var(--bg-lightest);
}

/* 添加到你的CSS文件中 */
.book-preview {
    display: flex;
    flex-direction: row;
    gap: 20px;
}

.preview-cover-section {
    flex: 0 0 200px;
}

.preview-details-section {
    flex: 1;
}

.book-preview-cover {
    height: 280px;
    width: 200px;
    overflow: hidden;
    border-radius: 4px;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.preview-cover-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-tag {
    display: inline-block;
    background: #e9ecef;
    color: #495057;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-right: 5px;
    margin-bottom: 5px;
}

.book-tags-preview {
    margin: 15px 0;
}

.book-description-preview {
    margin-top: 20px;
}

.section-title {
    font-size: 16px;
    margin-bottom: 10px;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 5px;
}

.book-meta {
    margin-top: 10px;
    text-align: center;
}

.book-price {
    font-size: 18px;
    font-weight: bold;
    color: #dc3545;
}

.book-stock {
    font-size: 14px;
    color: #6c757d;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .book-preview {
        flex-direction: column;
    }

    .preview-cover-section {
        margin: 0 auto;
    }
}

.preview-details-section {
    padding: 24px;
}

.book-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 8px 0;
}

.book-author {
    color: var(--text-medium);
    font-size: 1rem;
    margin-bottom: 24px;
}

.book-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    background-color: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
}

.info-value {
    font-weight: 500;
    color: var(--text-dark);
}

.book-tags-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.preview-tag {
    display: inline-block;
    background-color: var(--primary-light);
    color: var(--primary-color);
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.8125rem;
}

.no-tags {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.book-description-preview {
    background-color: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 12px 0;
}

.description-content {
    font-size: 0.9375rem;
    color: var(--text-medium);
    line-height: 1.6;
}

.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
}

.preview-footer {
    background-color: var(--bg-white);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ========== 通知样式 ========== */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 320px;
}

.notification {
    background-color: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 12px;
    animation-duration: 0.5s;
}

.success-notification {
    border-left: 4px solid var(--success-color);
}

.error-notification {
    border-left: 4px solid var(--danger-color);
}

.warning-notification {
    border-left: 4px solid var(--warning-color);
}

.info-notification {
    border-left: 4px solid var(--info-color);
}

.notification-icon {
    color: var(--text-light);
}

.success-notification .notification-icon {
    color: var(--success-color);
}

.error-notification .notification-icon {
    color: var(--danger-color);
}

.warning-notification .notification-icon {
    color: var(--warning-color);
}

.info-notification .notification-icon {
    color: var(--info-color);
}

.notification-content {
    flex-grow: 1;
}

.notification-content p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-dark);
}

.notification-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    transition: color var(--transition-fast);
}

.notification-close:hover {
    color: var(--text-medium);
}

/* ========== 动画效果 ========== */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* ========== 响应式样式 ========== */
@media (max-width: 1200px) {
    .form-grid {
        grid-template-columns: 1fr 320px;
        gap: 20px;
    }
}

@media (max-width: 992px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .book-preview {
        grid-template-columns: 1fr;
    }

    .preview-cover-section {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 24px;
    }

    .book-preview-cover {
        max-width: 240px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .book-form-container {
        padding: 16px 12px;
    }

    .page-header {
        padding: 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .secondary-actions {
        grid-template-columns: 1fr;
    }

    .card-body {
        padding: 16px;
    }

    .book-info-grid {
        grid-template-columns: 1fr;
    }
}
.cover-preview {
    min-height: 250px;
    width: 100%;
    border: 1px dashed #ccc;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.cover-preview img.cover-image {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}
.img-container {
    max-height: 500px;
    overflow: auto;
}
#cropperImage {
    max-width: 100%;
    display: block;
}