/* ========================================
   多模板编辑器通用样式
   ======================================== */

/* 编辑器模式切换 */
.editor-mode-switch {
    display: flex;
    gap: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.mode-option:hover {
    background: #e9ecef;
}

.mode-option input[type="radio"] {
    display: none;
}

.mode-option span {
    font-size: 14px;
    color: #666;
}

.mode-option input[type="radio"]:checked+span {
    color: #ff6600;
    font-weight: 600;
}

.mode-option input[type="radio"]:checked+span::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ff6600;
    margin-right: 8px;
}

/* 模板编辑器工具栏 */
.template-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    border-right: 1px solid #eee;
}

.toolbar-group:last-child {
    border-right: none;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    color: #333;
    font-weight: normal;
}

.toolbar-btn:hover {
    background: #e0e0e0;
}

.toolbar-btn:active {
    background: #d0d0d0;
}

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

.toolbar-select {
    height: 36px;
    padding: 0 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
}

.toolbar-select:hover {
    border-color: #ccc;
}

.toolbar-select:focus {
    border-color: #ff6600;
}

/* Markdown按钮特殊样式 */
.markdown-group .toolbar-btn {
    background: #6c757d;
    color: white;
}

.markdown-group .toolbar-btn:hover {
    background: #5a6268;
}

/* 模板选择区域 */
.template-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 30px;
}

.template-option {
    flex: 0 0 calc(20% - 12px);
    min-width: 150px;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    background: #fff;
}

.template-option:hover {
    border-color: #ff6600;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 102, 0, 0.2);
}

.template-option.selected {
    border-color: #ff6600;
    background: #fff5f0;
    box-shadow: 0 0 0 3px rgba(255, 102, 0, 0.1);
}

.template-option .template-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.template-option .template-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.template-option .template-desc {
    font-size: 12px;
    color: #666;
}

/* 编辑区域 */
.template-edit-area {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 5px;
    min-height: 800px;
}

/* 模板容器样式 */
.news-template {
    max-width: 800px;
    margin: 0 auto;
    padding: 5px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* 模板头部 */
.template-header {
    margin-bottom: 5px;
}

.template-header h1 {
    font-size: 1.6em;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 5px 0;
    line-height: 1.4;
    padding: 10px 0;
    border-bottom: 2px solid #eee;
}

/* 模板元数据 */
.template-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #7f8c8d;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.meta-item label {
    font-weight: 500;
    color: #95a5a6;
}

.meta-item .editable {
    color: #34495e;
    padding: 0px 0px;
    border-radius: 4px;
    background: #f8f9fa;
}

.meta-item .editable:hover,
.meta-item .editable:focus {
    background: #fff;
    outline: 1px solid #ddd;
}

.meta-divider {
    color: #ddd;
}

/* 模板封面 */
.template-cover {
    margin-bottom: 50px;
}

.template-cover img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

/* 模板内容区域 */
.template-content {
    margin-top: 5px;
    min-height: 800px;
}

.template-content .editable {
    min-height: 300px;
    padding: 5px;
    border: 1px dashed #ddd;
    border-radius: 8px;
    line-height: 1.2;
    font-size: 15px;
    color: #34495e;
}

.template-content .editable:focus {
    border-style: solid;
    border-color: #ff6600;
}

/* 可编辑元素样式 */
.editable {
    position: relative;
    transition: all 0.2s ease;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}

.editable:hover {
    background: rgba(255, 102, 0, 0.05);
    outline: 1px dashed #ff6600;
}

.editable:focus {
    background: rgba(255, 102, 0, 0.1);
    outline: 2px solid #ff6600;
}

.editable[contenteditable="true"] {
    outline: none;
    min-height: 24px;
}

/* 确保标题元素可编辑 */
.editable h1,
.editable h2,
.editable h3,
.editable h4,
.editable h5,
.editable h6 {
    cursor: text;
    user-select: text;
}

/* 可编辑段落样式 */
.editable p {
    margin: 0;
    padding: 2px 0;
}

.editable[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
}

/* 可编辑图片 */
.editable-image {
    cursor: pointer;
    border: 2px dashed transparent;
    transition: all 0.2s ease;
}

.editable-image:hover {
    border-color: #ff6600;
    opacity: 0.9;
}

.image-upload-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.editable-image:hover+.image-upload-hint,
.editable-image-container:hover .image-upload-hint {
    opacity: 1;
}

/* ========================================
   模板1 - 简约图文型
   ======================================== */
.template-classic {
    max-width: 100%;
    margin: 0 auto;
    background: #fff;
    padding: 5px;
}

.template-classic .template-header {
    text-align: center;
    margin-bottom: 5px;
    padding-bottom: 0px;

}

.template-classic .template-header h1 {
    font-size: 20px;
    color: #333;
    margin-bottom: 5px;
    align-items: start;
    align-self: left;
}

.template-classic .template-meta {
    color: #666;
    font-size: 14px;
}

.template-classic .template-meta span {
    margin: 0 0;
}

.template-classic .template-cover {
    margin-bottom: 5px;
}

.template-classic .template-cover img {
    width: 100%;
    border-radius: 8px;
}

.template-classic .template-content {
    line-height: 1.2;
    color: #333;
    font-size: 15px;
}

/* ========================================
   模板2 - 卡片列表型
   ======================================== */
.template-cards {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    padding: 40px;
}

.template-cards .template-header {
    text-align: center;
    margin-bottom: 5px;
}

.template-cards .template-cards-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 30px 0;
}

.template-cards .template-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.template-cards .template-card img {
    width: 100%;
    border-radius: 6px;
    margin-bottom: 15px;
}

.template-cards .template-card h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 10px;
}

.template-cards .template-card p {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

.template-cards .template-content {
    margin-top: 30px;
    padding-top: 5px;
    border-top: 1px solid #eee;
}

/* ========================================
   模板3 - 人物专访型
   ======================================== */
.template-interview {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    padding: 40px;
}

.template-interview .template-header {
    text-align: center;
    margin-bottom: 40px;
}

.template-interview .template-profile {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 40px;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 12px;
}

.template-interview .profile-avatar img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
}

.template-interview .profile-info h2 {
    font-size: 24px;
    color: #333;
    margin-bottom: 8px;
}

.template-interview .profile-info p {
    color: #666;
    margin-bottom: 5px;
}

.template-interview .template-quote {
    margin-bottom: 40px;
}

.template-interview .template-quote blockquote {
    font-size: 20px;
    font-style: italic;
    color: #ff6600;
    border-left: 4px solid #ff6600;
    padding: 20px 30px;
    background: #fff5f0;
    border-radius: 0 8px 8px 0;
}

.template-interview .template-content {
    line-height: 1.2;
    font-size: 15px;
}

/* ========================================
   模板4 - 赛事预告型
   ======================================== */
.template-preview {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    padding: 40px;
}

.template-preview .template-header {
    text-align: center;
    margin-bottom: 40px;
}

.template-preview .template-matchup {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin-bottom: 40px;
    padding: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.template-preview .team {
    text-align: center;
}

.template-preview .team img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: white;
    padding: 10px;
    margin-bottom: 15px;
}

.template-preview .team h3 {
    font-size: 22px;
    color: white;
}

.template-preview .vs {
    font-size: 32px;
    font-weight: bold;
}

.template-preview .template-match-info {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.template-preview .template-match-info p {
    margin: 10px 0;
    font-size: 16px;
}

.template-preview .template-match-info strong {
    color: #333;
}

/* ========================================
   模板5 - 数据统计型
   ======================================== */
.template-stats {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    padding: 40px;
}

.template-stats .template-header {
    text-align: center;
    margin-bottom: 40px;
}

.template-stats .template-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.template-stats .stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    border-radius: 12px;
    text-align: center;
}

.template-stats .stat-value {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 8px;
}

.template-stats .stat-label {
    font-size: 14px;
    opacity: 0.9;
}

.template-stats .template-cover {
    margin-bottom: 30px;
}

.template-stats .template-cover img {
    width: 100%;
    border-radius: 8px;
}

.template-stats .template-content {
    line-height: 1.2;
    font-size: 15px;
}

/* ========================================
   响应式样式
   ======================================== */
@media (max-width: 768px) {
    .template-option {
        flex: 0 0 calc(33.33% - 10px);
    }

    .template-classic,
    .template-cards,
    .template-interview,
    .template-preview,
    .template-stats {
        padding: 5px
    }

    .template-cards .template-cards-container {
        grid-template-columns: 1fr;
    }

    .template-interview .template-profile {
        flex-direction: column;
        text-align: center;
    }

    .template-preview .template-matchup {
        flex-direction: column;
        gap: 20px;
    }

    .template-stats .template-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .template-option {
        flex: 0 0 calc(50% - 7.5px);
    }

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

/* ========================================
   工具栏增强样式 - 颜色选择器
   ======================================== */
.toolbar-color-btn {
    position: relative;
}

.toolbar-color-popup {
    display: none;
    position: fixed;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 99999;
    grid-template-columns: repeat(5, 28px);
    gap: 4px;
}

.toolbar-color-popup div:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.15s ease;
}

/* ========================================
   图片调整大小手柄
   ======================================== */
.image-resize-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    user-select: none;
    -webkit-user-select: none;
}

.image-resize-wrapper img {
    display: block;
    max-width: 100%;
    cursor: pointer;
    outline: 2px solid #ff6600;
    outline-offset: 2px;
}

.image-resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ff6600;
    border: 2px solid #fff;
    border-radius: 2px;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.image-resize-nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.image-resize-ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.image-resize-sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.image-resize-se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.image-size-info {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
}

/* ========================================
   工具栏图片尺寸组
   ======================================== */
.toolbar-image-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 4px;
    border-left: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
}

.toolbar-image-group .toolbar-btn {
    font-size: 11px;
    letter-spacing: -1px;
}

/* ========================================
   工具栏字号选择器
   ======================================== */
.toolbar-fontsize {
    min-width: 70px;
}

/* ========================================
   可编辑区域内的图片样式
   ======================================== */
.editable img {
    max-width: 100%;
    height: auto;
    cursor: pointer;
    transition: outline 0.15s ease;
}

.editable img:hover {
    outline: 2px dashed #ff6600;
    outline-offset: 2px;
}