/* ============================================================
   edit_ranking.css - 排行编辑器样式（含工具栏浮动、颜色选择器优化）
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    background: #f5f7fb;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", SimHei, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: #333;
    padding: 24px;
}
.editor-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    padding: 24px 30px 30px;
}
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.header-bar h2 {
    font-weight: 400;
    font-size: 22px;
}
.header-bar .actions {
    display: flex;
    gap: 10px;
    align-items: center;
}
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
    color: #1a1a1a;
}
.form-group .hint {
    font-weight: 400;
    color: #6b7280;
    font-size: 12px;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 15px;
    transition: 0.2s;
    background: #fafbfc;
    font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #1a1a1a;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}
.form-divider {
    margin: 20px 0;
    border: none;
    border-top: 1px solid #e5e7eb;
}

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-primary {
    background: #1a1a1a;
    color: #fff;
}
.btn-primary:hover {
    background: #333;
}
.btn-outline {
    background: transparent;
    border: 1px solid #d1d5db;
}
.btn-outline:hover {
    background: #f3f4f6;
}
.btn-danger {
    background: #dc2626;
    color: #fff;
}
.btn-danger:hover {
    background: #b91c1c;
}
.btn-success {
    background: #16a34a;
    color: #fff;
}
.btn-success:hover {
    background: #15803d;
}
.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}
.footer-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* 图片上传 */
.image-upload-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.image-upload-wrapper .file-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 300px;
}
.image-upload-wrapper .file-wrapper input[type="file"] {
    flex: 1;
    padding: 6px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 13px;
    background: #fafbfc;
}
.image-upload-wrapper .or-text {
    color: #6b7280;
    font-size: 13px;
}
.image-upload-wrapper input[type="text"] {
    flex: 2;
    min-width: 200px;
}

/* ============================================================
   ✅ 修改：封面图片预览 → 缩略图（最大 160×120px）
   ============================================================ */
.ranking-image-preview {
    margin-top: 10px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    display: inline-block;       /* 让容器自适应内容宽度 */
    max-width: 160px;            /* 限制最大宽度 */
    vertical-align: top;
    line-height: 0;              /* 消除图片下方间隙 */
}
.ranking-image-preview img {
    width: 100%;
    max-height: 120px;           /* 限制最大高度 */
    object-fit: cover;           /* 保持比例裁切，不变形 */
    display: block;
    border-radius: 8px;
}
.ranking-image-preview .remove-image-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    padding: 0;
    line-height: 1;
}
.ranking-image-preview .remove-image-btn:hover {
    background: rgba(220,38,38,0.8);
}

/* ===== 条目卡片 ===== */
.ranking-item {
    background: #fafbfc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}
.ranking-item .item-header {
    cursor: pointer;
    user-select: none;
    padding: 12px 18px;
    background: #f5f7fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}
.ranking-item .item-header:hover {
    background: #edf0f5;
}
.ranking-item .item-header .toggle-icon {
    font-size: 18px;
    color: #6b7280;
    transition: transform 0.3s;
    margin-right: 8px;
}
.ranking-item .item-header .item-title-display {
    font-weight: 500;
    font-size: 16px;
    flex: 1;
}
.ranking-item .item-body {
    padding: 16px 18px 18px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    display: none;
}
.ranking-item .item-body.open {
    display: block;
}
.ranking-item .item-header-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.ranking-item .item-style-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.ranking-item .item-style-row .form-group {
    flex: 1;
    min-width: 120px;
    margin-bottom: 0;
}

/* ===== Quill 编辑器 ===== */
.ranking-item .item-editor {
    min-height: 120px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-top: 4px;
    overflow: hidden;
}
.ranking-item .item-editor .ql-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    border: none !important;
    border-bottom: 1px solid #e5e7eb !important;
    padding: 6px 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
}
.ranking-item .item-editor .ql-container {
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    border: none !important;
    min-height: 120px;
    font-size: 15px;
}
.ranking-item .item-editor .ql-editor {
    min-height: 100px;
    font-size: 15px;
    line-height: 1.7;
}
.ranking-item .item-editor .ql-editor img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}
.ranking-item .item-editor .ql-editor iframe,
.ranking-item .item-editor .ql-editor video {
    max-width: 100%;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
}

/* 自定义视频按钮 */
.ql-toolbar button.ql-video-code {
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 2px 8px;
    margin: 0 2px;
    cursor: pointer;
    background: #f9f9f9;
    font-size: 12px;
    height: 26px;
    line-height: 1.2;
    white-space: nowrap;
}
.ql-toolbar button.ql-video-code:hover {
    background: #e6e6e6;
}

/* ===== 颜色选择器 ===== */
.color-picker-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
}
.color-picker-input {
    width: 60px;
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    background: #fff;
}
.color-picker-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    cursor: pointer;
    flex-shrink: 0;
}
.color-picker-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 100;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px;
    width: 180px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    flex-wrap: wrap;
    gap: 4px;
}
.color-picker-dropdown.active {
    display: flex;
}
.color-picker-dropdown .color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border 0.15s;
}
.color-picker-dropdown .color-swatch:hover {
    border-color: #888;
}
.color-picker-dropdown .color-swatch.active {
    border-color: #1a1a1a;
    box-shadow: 0 0 0 1px #fff, 0 0 0 3px #1a1a1a;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: #fff;
    padding: 10px 28px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    z-index: 9999;
    max-width: 90%;
    text-align: center;
    animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== 响应式 ===== */
@media (max-width: 640px) {
    body { padding: 12px; }
    .editor-wrapper { padding: 16px; }
    .header-bar h2 { font-size: 18px; }

    /* 手机端输入框字号 ≥16px，避免 iOS 聚焦输入框时页面自动放大 */
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px !important;
    }

    .ranking-item { padding: 0; }
    .ranking-item .item-header { padding: 10px 14px; }
    .ranking-item .item-body { padding: 12px 14px 14px; }
    .ranking-item .item-header-row { flex-direction: column; }
    .ranking-item .item-style-row { flex-direction: column; }
    .image-upload-wrapper .file-wrapper { flex-direction: column; align-items: stretch; }
    .image-upload-wrapper .or-text { display: none; }
    .color-picker-input { width: 50px; }

    /* 移动端缩略图再小一点 */
    .ranking-image-preview {
        max-width: 120px;
    }
    .ranking-image-preview img {
        max-height: 90px;
    }
}