/**
 * Frontend CSS
 */
.sgf-widget-container {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 24px;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
    max-width: 100%;
}
.sgf-widget-container.sgf-widget-style-seamless { border-color: transparent; border-radius: 0; padding: 0; background: transparent; box-shadow: none; }

.sgf-widget-header { margin-bottom: 20px; border-bottom: 1px solid #f3f4f6; padding-bottom: 12px; }
.sgf-title { font-size: 24px; font-weight: 700; color: #111827; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

/* 前台高颜值标签模块 */
.sgf-frontend-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.sgf-tag {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px; /* 胶囊圆角 */
    line-height: 1.2;
}

/* 语言标签 - 蓝色系 */
.sgf-tag-lang { background-color: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
/* 授权标签 - 绿色系 */
.sgf-tag-license { background-color: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.sgf-tag-license[href] { color: #166534; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.sgf-author-note-tag { cursor: pointer; }
.sgf-author-note-content { white-space: normal; line-height: 1.8; word-break: break-word; }
.sgf-agpl-exception-tag { font-family: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.sgf-agpl-exception-modal blockquote { margin: 0; padding: 12px 14px; line-height: 1.8; }
.sgf-agpl-exception-modal code { white-space: normal; overflow-wrap: anywhere; }
/* 格式标签 - 紫色系 */
.sgf-tag-fmt { background-color: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.sgf-live-input {
    width: 100%;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 16px;
    min-height: 90px;
    margin-bottom: 10px; /* 减小间距给提示框腾出空间 */
    resize: vertical;
    transition: border-color 0.2s;
    outline: none;
    box-sizing: border-box;
}
.sgf-live-input:focus { border-color: #3b82f6; }

/* 核心修改：输入提示框样式 */
.sgf-input-notice {
    display: none; /* 默认隐藏 */
    font-size: 13px;
    margin-bottom: 20px;
    padding: 8px 12px;
    border-radius: 6px;
    line-height: 1.4;
}
.sgf-input-notice[data-type="warn"] {
    background-color: #fff7ed;
    color: #c2410c;
    border: 1px solid #ffedd5;
}
.sgf-input-notice[data-type="info"] {
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
}

.sgf-toolbar { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-end; margin-bottom: 24px; }
.sgf-preview-action-row { display: flex; justify-content: center; clear: both; width: 100%; margin: 4px 0 20px; }
.sgf-preview-action-row .but { float: none !important; display: inline-flex; align-items: center; justify-content: center; width: min(100%, 680px); min-height: 40px; margin: 0 !important; }
.sgf-tool-group label { display: block; font-size: 13px; font-weight: 600; color: #4b5563; margin-bottom: 8px; }

/* 自定义滑块 UI */
.sgf-slider-group { flex: 1; min-width: 150px; }
.sgf-size-slider {
    -webkit-appearance: none; width: 100%; height: 6px; background: #e5e7eb; border-radius: 5px; outline: none; margin: 10px 0;
}
.sgf-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #3b82f6; cursor: pointer; border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: transform 0.1s;
}
.sgf-size-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.sgf-size-val { float: right; color: #3b82f6; }

/* 配色 */
.sgf-theme-presets { display: flex; align-items: center; flex-wrap: nowrap; gap: 10px; min-height: 40px; }
.sgf-theme-pill {
    display: block; flex: 0 0 36px; width: 36px !important; min-width: 36px; max-width: 36px; height: 36px !important; min-height: 36px; max-height: 36px; line-height: 0; border-radius: 50% !important; border: 2px solid #e5e7eb; cursor: pointer; transition: transform 0.1s; padding: 0 !important; margin: 0 !important; overflow: hidden; background-size: 112% 112% !important; background-position: center !important; background-repeat: no-repeat !important; appearance: none; -webkit-appearance: none;
}
.sgf-theme-pill:hover { transform: scale(1.1); border-color: #9ca3af; }

.sgf-color-picker-wrap {
    position: relative; flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; border: 2px solid #e5e7eb; overflow: hidden; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.sgf-color-picker-wrap input[type="color"] {
    position: absolute; top: -60%; left: -60%; width: 220%; height: 220%; padding: 0; margin: 0; border: none; cursor: pointer; background: transparent;
}

/* 预览区域 */
.sgf-preview-area {
    position: relative;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    min-height: 240px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: hidden;
    padding: 10px;
}
.sgf-preview-img { max-width: 100%; height: auto; display: block; opacity: 1; transition: opacity 0.2s; border-radius: 4px; }
.sgf-preview-area.is-loading .sgf-preview-img { opacity: 0.5; }

/* Loader */
.sgf-loader {
    position: absolute; top: 50%; left: 50%; margin-left: -18px; margin-top: -18px; width: 36px; height: 36px;
    border: 4px solid rgba(0,0,0,0.1); border-top-color: #3b82f6; border-radius: 50%; animation: sgf-spin 1s infinite linear; display: none; z-index: 10;
}
.sgf-preview-area.is-loading .sgf-loader { display: block; }
@keyframes sgf-spin { to { transform: rotate(360deg); } }

.sgf-fallback-msg { padding: 40px; color: #ef4444; font-weight: bold; display: none; text-align: center; width: 100%; }
.sgf-error { color: red; border: 1px solid red; padding: 10px; border-radius: 4px; background: #fff1f1; }

/* 跟随子比 body.dark-theme 变量即时切换，避免前台预览区保留亮色底板。 */
body.dark-theme .sgf-widget-container { background: var(--main-bg-color); border-color: var(--main-border-color); box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.22); }
body.dark-theme .sgf-widget-container.sgf-widget-style-seamless { background: transparent; border-color: transparent; box-shadow: none; }
body.dark-theme .sgf-widget-header { border-bottom-color: var(--main-border-color); }
body.dark-theme .sgf-title { color: var(--key-color); }
body.dark-theme .sgf-live-input { color: var(--main-color); background: var(--muted-bg-2-color); border-color: var(--main-border-color); }
body.dark-theme .sgf-live-input::placeholder { color: var(--muted-2-color); }
body.dark-theme .sgf-live-input:focus { border-color: var(--focus-color); }
body.dark-theme .sgf-tool-group label { color: var(--main-color); }
body.dark-theme .sgf-size-slider { background: var(--muted-bg-color); }
body.dark-theme .sgf-size-slider::-webkit-slider-thumb { border-color: var(--main-bg-color); }
body.dark-theme .sgf-size-slider::-moz-range-thumb { border-color: var(--main-bg-color); }
body.dark-theme .sgf-theme-pill,
body.dark-theme .sgf-color-picker-wrap { border-color: var(--main-border-color); }
body.dark-theme .sgf-preview-area { background: var(--muted-bg-2-color); border-color: var(--main-border-color); }
body.dark-theme .sgf-loader { border-color: rgba(255, 255, 255, 0.14); border-top-color: var(--focus-color); }
body.dark-theme .sgf-tag-lang { background-color: rgba(59, 130, 246, 0.16); color: #bfdbfe; border-color: rgba(96, 165, 250, 0.32); }
body.dark-theme .sgf-tag-license,
body.dark-theme .sgf-tag-license[href] { background-color: rgba(34, 197, 94, 0.14); color: #bbf7d0; border-color: rgba(74, 222, 128, 0.3); }
body.dark-theme .sgf-tag-fmt { background-color: rgba(168, 85, 247, 0.16); color: #e9d5ff; border-color: rgba(192, 132, 252, 0.32); }
body.dark-theme .sgf-input-notice[data-type="warn"] { background-color: rgba(194, 65, 12, 0.2); color: #fed7aa; border-color: rgba(251, 146, 60, 0.3); }
body.dark-theme .sgf-input-notice[data-type="info"] { background-color: rgba(29, 78, 216, 0.2); color: #bfdbfe; border-color: rgba(96, 165, 250, 0.3); }

/* 前台字体管理弹窗只定义布局，不覆盖子比主题的按钮、输入框和复选框样式。 */
.modal-dialog.sgf-font-modal-dialog { width: 900px; max-width: calc(100% - 20px); }
.sgf-front-modal-columns { margin-left: -10px; margin-right: -10px; }
.sgf-front-modal-columns > [class*="col-"] { padding-left: 10px; padding-right: 10px; }
.sgf-front-editor-column { border-right: 1px solid var(--muted-border-color, #eee); }
.sgf-front-list-column { min-width: 0; }
.sgf-front-check-options { display: flex; flex-wrap: wrap; gap: 8px 14px; line-height: 1.8; }
.sgf-front-check-options label { margin: 0; white-space: nowrap; }
.sgf-front-conditional[hidden] { display: none; }
.sgf-front-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin: 0 0 6px; }
.sgf-front-switch-label { flex: 1 1 auto; min-width: 0; line-height: 1.5; }
.sgf-front-switch-control { display: inline-flex; align-items: center; flex: 0 0 46px; width: 46px; height: 26px; }
.sgf-front-switch-control .form-switch { display: block; flex: 0 0 46px; margin: 0; }
.sgf-front-protocol-options { max-height: 150px; overflow-y: auto; padding-right: 6px; }
.sgf-front-file-button { display: inline-block; margin-bottom: 6px; }
.sgf-front-font-list { max-height: 480px; overflow-y: auto; padding-right: 6px; }
.sgf-front-font-item { border-bottom: 1px solid var(--muted-border-color, #eee); padding: 10px 0; }
.sgf-front-font-item:last-child { border-bottom: 0; }
.sgf-front-font-name { font-weight: 600; margin-bottom: 8px; overflow-wrap: anywhere; }
.sgf-front-font-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.sgf-front-font-actions .but { margin: 0; }

body.dark-theme .sgf-front-editor-column,
body.dark-theme .sgf-front-font-item { border-color: var(--main-border-color); }

@media (max-width: 767px) {
    .modal-dialog.sgf-font-modal-dialog { width: calc(100% - 20px); }
    .sgf-front-editor-column { border-right: 0; border-bottom: 1px solid var(--muted-border-color, #eee); padding-bottom: 14px; margin-bottom: 14px; }
    .sgf-front-font-list { max-height: 260px; }
    .sgf-front-switch-row { align-items: flex-start; }
}
