/* ============================================================
   时光字体 EMLOG 前台预览组件样式
   ============================================================ */

.sgf-widget-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    margin: 24px 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    --sgf-accent: #2563eb;
}

/* ========== 头部 ========== */
.sgf-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
    gap: 10px;
}

.sgf-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}

.sgf-frontend-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.sgf-tag {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
}
.sgf-tag-lang { background: #dbeafe; color: #1e40af; }
.sgf-tag-license { background: #dcfce7; color: #166534; }
.sgf-tag-fmt { background: #f1f5f9; color: #475569; }

/* ========== 控制面板 ========== */
.sgf-control-panel {
    padding: 16px 24px;
    border-bottom: 1px solid #f1f5f9;
    background: #fafbfc;
}

.sgf-live-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    min-height: 44px;
    max-height: 120px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}
.sgf-live-input:focus {
    border-color: var(--sgf-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.sgf-input-notice {
    font-size: 12px;
    color: #ef4444;
    margin-top: 4px;
    min-height: 16px;
}

/* ========== 工具栏 ========== */
.sgf-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.sgf-tool-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sgf-tool-group label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}

/* 字号滑块 */
.sgf-slider-group {
    gap: 10px;
}
.sgf-size-val {
    font-size: 12px;
    color: #1e293b;
    font-weight: 700;
    min-width: 36px;
    text-align: right;
}
.sgf-size-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    border-radius: 2px;
    background: #e2e8f0;
    outline: none;
}
.sgf-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--sgf-accent);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* 配色预设 */
.sgf-theme-presets {
    display: flex;
    gap: 6px;
}
.sgf-theme-pill {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    padding: 0;
}
.sgf-theme-pill:hover {
    transform: scale(1.15);
}
.sgf-theme-pill.active {
    border-color: var(--sgf-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* 自定义颜色 */
.sgf-color-picker-wrap {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #e2e8f0;
    position: relative;
}
.sgf-color-picker-wrap input[type="color"] {
    position: absolute;
    inset: -4px;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    border: none;
    cursor: pointer;
    padding: 0;
}

/* ========== 预览区 ========== */
.sgf-preview-area {
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #fff;
}

.sgf-preview-img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    transition: opacity 0.3s;
}
.sgf-preview-img.loading {
    opacity: 0.3;
}

/* 加载动画 */
.sgf-loader {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--sgf-accent);
    border-radius: 50%;
    animation: sgf-spin 0.8s linear infinite;
    z-index: 2;
}
.sgf-loader.visible {
    display: block;
}

@keyframes sgf-spin {
    to { transform: rotate(360deg); }
}

/* 错误提示 */
.sgf-fallback-msg {
    display: none;
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #ef4444;
    background: #fef2f2;
    padding: 4px 12px;
    border-radius: 6px;
    white-space: nowrap;
}
.sgf-fallback-msg.visible {
    display: block;
}

.sgf-error {
    padding: 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-size: 14px;
    text-align: center;
    margin: 16px 0;
}

/* ========== 响应式 ========== */
@media (max-width: 640px) {
    .sgf-widget-header {
        padding: 12px 16px;
    }
    .sgf-control-panel {
        padding: 12px 16px;
    }
    .sgf-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .sgf-size-slider {
        width: 80px;
    }
}
