/* =====================================================
   写检讨书 - 样式文件
   参考: intelligent_reply.css / short_video_script.css
   ===================================================== */

/* ── 容器布局 ── */
.srw-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    min-height: 500px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.srw-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    border-radius: 0;
    border: none;
}

/* ── 顶部工具栏 ── */
.srw-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(to bottom, #ffffff 0%, #f8fafc 100%);
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-group + .toolbar-group {
    margin-left: 2px;
    padding-left: 8px;
    border-left: 1px solid #e2e8f0;
}

.srw-toolbar-title {
    flex: 1;
    justify-content: center;
}

.toolbar-title-text {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    letter-spacing: 0.5px;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.toolbar-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
}

.toolbar-btn:active {
    background: #e2e8f0;
    transform: translateY(1px);
}

.toolbar-btn-primary {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    border-color: #d97706;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
    font-weight: 600;
}

.toolbar-btn-primary:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    border-color: #f59e0b;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.5);
}

/* ── 主内容区（三栏布局）── */
.srw-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── 左侧历史面板 ── */
.srw-history-panel {
    width: 220px;
    min-width: 180px;
    max-width: 260px;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-left: 4px solid #8b5cf6;
    border-right: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.srw-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.srw-history-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.srw-history-clear-btn {
    background: #fff0f0;
    border: none;
    color: #ef4444;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 7px;
    border-radius: 3px;
    transition: background 0.2s;
}

.srw-history-clear-btn:hover {
    background: #fde8e8;
}

.srw-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.srw-history-item {
    padding: 9px 10px;
    margin-bottom: 4px;
    background: #f8fafc;
    border: 1px solid #e8edf3;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.18s;
    position: relative;
}

.srw-history-item:hover {
    background: #eef2f7;
    border-color: #94a3b8;
    box-shadow: inset 3px 0 0 #a78bfa;
}

.srw-history-item.active {
    background: #eef2ff;
    border-color: #a5b4fc;
    box-shadow: inset 3px 0 0 #6366f1;
}

.srw-history-item.active .srw-history-item-title {
    color: #4f46e5;
}

.srw-history-item-title {
    font-size: 12px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.srw-history-item-meta {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.srw-history-item-del {
    visibility: hidden;
    background: none;
    border: none;
    color: #f87171;
    font-size: 12px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.srw-history-item:hover .srw-history-item-del {
    visibility: visible;
}

.srw-history-empty {
    text-align: center;
    padding: 32px 12px;
    color: #94a3b8;
}

.srw-history-empty-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.srw-history-empty-text {
    font-size: 12px;
}

/* ── 中间配置面板 ── */
.srw-config-panel {
    width: 320px;
    min-width: 280px;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    flex-shrink: 0;
    overflow-y: auto;
}

.srw-config-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 2;
}

.srw-config-header h3 {
    margin: 0 0 3px;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.srw-panel-tip {
    font-size: 11px;
    color: #94a3b8;
}

.srw-config-body {
    padding: 12px 16px 20px;
}

/* ── 表单元素 ── */
.srw-form-group {
    margin-bottom: 14px;
}

.srw-form-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.srw-form-label.required::after {
    content: '*';
    color: #ef4444;
    font-size: 11px;
}

.srw-optional-tag {
    font-size: 10px;
    font-weight: 400;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 3px;
}

.srw-char-count {
    margin-left: auto;
    font-size: 10px;
    font-weight: 400;
    color: #94a3b8;
    transition: color 0.2s;
}

.srw-char-count.char-count-warn {
    color: #d97706;
}

.srw-char-count.char-count-limit {
    color: #ef4444;
    font-weight: 600;
}

.srw-form-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    color: #1e293b;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.srw-form-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.srw-form-input.is-error {
    border-color: #ef4444;
    background: #fff5f5;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

.srw-form-textarea {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    color: #1e293b;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    line-height: 1.5;
    font-family: inherit;
}

.srw-form-textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.srw-form-textarea.is-error {
    border-color: #ef4444;
    background: #fff5f5;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

.srw-form-textarea-sm {
    min-height: 60px;
}

.srw-section-hint {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

/* ── 选择按钮组 ── */
.srw-btn-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.srw-sel-btn {
    padding: 5px 10px;
    font-size: 12px;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.18s;
    white-space: nowrap;
}

.srw-sel-btn:hover {
    background: #eef2f7;
    border-color: #6366f1;
    color: #4f46e5;
}

.srw-sel-btn.active {
    background: #eef2ff;
    border-color: #6366f1;
    color: #4f46e5;
    font-weight: 600;
}

/* ── 生成操作按钮 ── */
.srw-form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    position: sticky;
    bottom: 0;
    background: #ffffff;
    padding: 12px 16px 10px;
    margin-left: -16px;
    margin-right: -16px;
    border-top: 1px solid #f1f5f9;
    box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.05);
    z-index: 1;
}

.srw-generate-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

.srw-generate-btn:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.5);
    transform: translateY(-1px);
}

.srw-generate-btn:active {
    transform: translateY(0);
}

.srw-generate-btn:disabled {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.srw-btn-shortcut-hint {
    font-size: 10px;
    opacity: 0.75;
    font-weight: 400;
}

.srw-cancel-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.18s;
}

.srw-cancel-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.srw-draft-hint {
    font-size: 11px;
    color: #22c55e;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s;
}

/* ── 右侧输出面板 ── */
.srw-output-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-left: 4px solid #3b82f6;
    overflow: hidden;
}

.srw-output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 2px solid #dbeafe;
    flex-shrink: 0;
}

.srw-output-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.srw-output-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.srw-scene-badge {
    font-size: 11px;
    padding: 2px 8px;
    background: #eef2ff;
    color: #4f46e5;
    border-radius: 10px;
    font-weight: 500;
}

.srw-regen-btn {
    font-size: 12px;
    padding: 4px 10px;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.18s;
}

.srw-regen-btn:hover {
    background: #eef2f7;
    border-color: #6366f1;
    color: #4f46e5;
}

/* ── 空状态 ── */
.srw-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.srw-empty-icon {
    font-size: 52px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.srw-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
}

.srw-empty-desc {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.6;
    margin-bottom: 20px;
}

.srw-empty-features {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    max-width: 380px;
}

.srw-feature-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #64748b;
    padding: 7px 10px;
    background: #f8fafc;
    border: 1px solid #e8edf3;
    border-radius: 6px;
}

.srw-feature-icon {
    font-size: 14px;
}

/* ── 加载状态 ── */
.srw-loading-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.srw-loading-rings {
    position: relative;
    width: 54px;
    height: 54px;
    margin-bottom: 20px;
}

.srw-loading-ring {
    position: absolute;
    border-radius: 50%;
    border: 3px solid transparent;
    animation: srwRingRotate 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.srw-loading-ring:nth-child(1) {
    width: 54px;
    height: 54px;
    border-top-color: #6366f1;
    animation-delay: -0.45s;
}

.srw-loading-ring:nth-child(2) {
    width: 40px;
    height: 40px;
    top: 7px;
    left: 7px;
    border-top-color: #f59e0b;
    animation-delay: -0.3s;
}

.srw-loading-ring:nth-child(3) {
    width: 26px;
    height: 26px;
    top: 14px;
    left: 14px;
    border-top-color: #22c55e;
    animation-delay: -0.15s;
}

@keyframes srwRingRotate {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.srw-loading-text {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.srw-loading-sub {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 12px;
}

.srw-loading-dots {
    display: flex;
    gap: 5px;
}

.srw-loading-dots span {
    width: 6px;
    height: 6px;
    background: #6366f1;
    border-radius: 50%;
    animation: srwDotBounce 1.4s infinite ease-in-out;
}

.srw-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.srw-loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes srwDotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40%            { transform: scale(1.0); opacity: 1;   }
}

/* ── 结果内容区 ── */
.srw-result-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 20px;
}

/* ── 检讨书章节卡片 ── */
.srw-section {
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    border-left: 4px solid #6366f1;
    transition: box-shadow 0.18s;
}

.srw-section:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.srw-section.sec-title-block   { border-left-color: #1e293b; }
.srw-section.sec-salutation    { border-left-color: #6366f1; }
.srw-section.sec-admit         { border-left-color: #ef4444; }
.srw-section.sec-reason        { border-left-color: #f59e0b; }
.srw-section.sec-attitude      { border-left-color: #3b82f6; }
.srw-section.sec-measures      { border-left-color: #22c55e; }
.srw-section.sec-promise       { border-left-color: #8b5cf6; }
.srw-section.sec-signature     { border-left-color: #94a3b8; }

.srw-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
}

.srw-sec-title-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.srw-sec-icon {
    font-size: 14px;
}

.srw-sec-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.srw-sec-tip {
    font-size: 11px;
    color: #94a3b8;
}

.srw-sec-copy-btn {
    font-size: 11px;
    padding: 3px 8px;
    color: #64748b;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.18s;
}

.srw-sec-copy-btn:hover {
    background: #eef2f7;
    border-color: #6366f1;
    color: #4f46e5;
}

.srw-section-body {
    padding: 10px 14px;
    font-size: 13px;
    color: #1e293b;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 标题区块特殊样式 */
.srw-section.sec-title-block .srw-section-body {
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    color: #1e293b;
    padding: 14px;
}

/* 落款区块特殊样式 */
.srw-section.sec-signature .srw-section-body {
    font-size: 13px;
    color: #475569;
    text-align: right;
}

/* 字数徽章 */
.srw-word-count-badge {
    display: inline-block;
    font-size: 10px;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 6px;
    font-weight: 400;
}

/* 复制全文按钮区域 */
.srw-copy-all-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 0 4px;
    border-top: 1px solid #f1f5f9;
    margin-top: 4px;
}

.srw-copy-all-btn {
    font-size: 12px;
    padding: 6px 14px;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.18s;
}

.srw-copy-all-btn:hover {
    background: #eef2f7;
    border-color: #6366f1;
    color: #4f46e5;
}

.srw-export-btn {
    font-size: 12px;
    padding: 6px 14px;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.18s;
}

.srw-export-btn:hover {
    background: #eef2f7;
    border-color: #22c55e;
    color: #16a34a;
}

/* ── 错误状态 ── */
.srw-error-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.srw-error-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.srw-error-text {
    font-size: 14px;
    color: #ef4444;
    margin-bottom: 14px;
}

.srw-retry-btn {
    font-size: 13px;
    padding: 8px 18px;
    color: #ffffff;
    background: #6366f1;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.18s;
}

.srw-retry-btn:hover {
    background: #4f46e5;
}

/* ── 示例导入抽屉 ── */
.srw-drawer {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: #ffffff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.srw-drawer.open {
    right: 0;
}

.srw-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.srw-drawer-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.srw-drawer-close-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.18s;
}

.srw-drawer-close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

.srw-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.srw-example-card {
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.18s;
    border-left: 3px solid #6366f1;
}

.srw-example-card:hover {
    background: #f8faff;
    border-color: #6366f1;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.srw-example-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 6px;
}

.srw-example-meta {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.srw-example-tag {
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 8px;
    font-weight: 500;
}

.srw-example-tag.scene {
    background: #eef2ff;
    color: #4f46e5;
}

.srw-example-tag.severity {
    background: #fef3c7;
    color: #d97706;
}

.srw-example-tag.tone {
    background: #f0fdf4;
    color: #16a34a;
}

.srw-example-desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.srw-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 10000;
    display: none;
}

.srw-drawer-overlay.show {
    display: block;
}

/* ── 滚动条 ── */
.srw-history-list::-webkit-scrollbar,
.srw-config-panel::-webkit-scrollbar,
.srw-result-content::-webkit-scrollbar,
.srw-drawer-body::-webkit-scrollbar {
    width: 5px;
}

.srw-history-list::-webkit-scrollbar-track,
.srw-config-panel::-webkit-scrollbar-track,
.srw-result-content::-webkit-scrollbar-track,
.srw-drawer-body::-webkit-scrollbar-track {
    background: transparent;
}

.srw-history-list::-webkit-scrollbar-thumb,
.srw-config-panel::-webkit-scrollbar-thumb,
.srw-result-content::-webkit-scrollbar-thumb,
.srw-drawer-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.srw-history-list::-webkit-scrollbar-thumb:hover,
.srw-config-panel::-webkit-scrollbar-thumb:hover,
.srw-result-content::-webkit-scrollbar-thumb:hover,
.srw-drawer-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── 响应式 ── */
@media (max-width: 900px) {
    .srw-history-panel {
        display: none;
    }
    .srw-config-panel {
        min-width: 260px;
        width: 280px;
    }
}

@media (max-width: 640px) {
    .srw-container {
        height: calc(100vh - 80px);
    }
    .srw-main-content {
        flex-direction: column;
    }
    .srw-config-panel {
        width: 100%;
        max-width: 100%;
        height: 50%;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    .srw-output-panel {
        height: 50%;
    }
}
