/* ======================================================================
   相声剧本生成工具 — crosstalk_script.css
   主色：中国传统红  #c0392b / #8e1010
   逗哏台词：暖金黄  |  捧哏台词：清冷蓝
   ====================================================================== */

/* ========== 容器 ========== */
.ct-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    background: #f8fafc;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

/* 全屏模式 */
.ct-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
}

/* ========== 工具栏 ========== */
.ct-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #c0392b 0%, #8e1010 100%);
    color: white;
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(192, 57, 43, 0.35);
    flex-shrink: 0;
}

.toolbar-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.ct-btn {
    padding: 6px 10px;
    background: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #c0392b;
    transition: all 0.2s;
    white-space: nowrap;
}

.ct-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
}

.ct-btn:active:not(:disabled) {
    transform: translateY(0);
}

.ct-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ========== 主内容区 ========== */
.ct-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ========== 左侧历史面板 ========== */
.ct-history-panel {
    width: 200px;
    background: white;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.ct-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 14px 13px 11px;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.ct-history-title {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ct-history-badge {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
    line-height: 1.6;
}

.ct-history-clear {
    background: #fff0f0;
    border: none;
    color: #ef4444;
    font-size: 12px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 3px;
    transition: background 0.2s;
}

.ct-history-clear:hover {
    background: #fde8e8;
}

.ct-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.ct-history-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
    padding: 24px 10px;
    line-height: 1.6;
}

.ct-history-item {
    padding: 9px 11px;
    margin: 3px 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.18s;
    position: relative;
    animation: ctFadeIn 0.2s ease;
}

.ct-history-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateX(2px);
}

.ct-history-item.active {
    background: #fff1f0;
    border-color: #c0392b;
    box-shadow: 0 1px 4px rgba(192, 57, 43, 0.15);
}

.ct-history-item-title {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
    padding-right: 16px;
}

.ct-history-item-meta {
    font-size: 10px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ct-history-item-del {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 15px;
    height: 15px;
    background: #fde8e8;
    color: #ef4444;
    border: none;
    border-radius: 3px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.ct-history-item:hover .ct-history-item-del {
    display: flex;
}

.ct-history-item-del:hover {
    background: #ef4444;
    color: white;
}

/* ========== 中间输入面板 ========== */
.ct-input-header {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 13px 14px 13px 11px;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.ct-input-panel {
    width: 360px;
    background: white;
    border-right: 1px solid #e2e8f0;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.ct-input-inner {
    padding: 16px 14px;
    flex: 1;
    overflow-y: auto;
}

.ct-form-item {
    margin-bottom: 14px;
}

.ct-form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.ct-form-row .ct-form-item {
    flex: 1;
    margin-bottom: 0;
}

.ct-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
}

.ct-required {
    color: #ef4444;
}

.ct-optional {
    font-weight: 400;
    color: #94a3b8;
    font-size: 11px;
}

.ct-role-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ct-lead-dot    { background: linear-gradient(135deg, #c0392b, #e74c3c); }
.ct-support-dot { background: linear-gradient(135deg, #2980b9, #3498db); }

.ct-textarea,
.ct-input,
.ct-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    background: #fafafa;
    box-sizing: border-box;
}

.ct-textarea {
    resize: vertical;
    line-height: 1.55;
    min-height: 72px;
}

.ct-textarea:focus,
.ct-input:focus,
.ct-select:focus {
    border-color: #c0392b;
    box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.12);
    background: #fff;
}

.ct-textarea:hover,
.ct-input:hover {
    border-color: #c0392b;
    background: #fff;
}

.ct-select:hover {
    border-color: #c0392b;
    background: #fff;
}

/* 校验错误态 */
.ct-textarea.is-error,
.ct-input.is-error {
    border-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
    background: #fff8f8;
}

.ct-char-count {
    text-align: right;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

.ct-char-count.warn {
    color: #ef4444;
}

/* 生成按钮 */
.ct-generate-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #c0392b 0%, #8e1010 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-top: 4px;
}

.ct-generate-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(192, 57, 43, 0.42);
}

.ct-generate-btn:active:not(:disabled) {
    transform: translateY(0);
}

.ct-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ct-generate-icon {
    font-size: 16px;
    line-height: 1;
}

.ct-shortcut-tip {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 10px;
    line-height: 1.6;
}

.ct-shortcut-tip kbd {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 10px;
    color: #475569;
    font-family: inherit;
}

/* ========== 右侧输出面板 ========== */
.ct-output-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
    min-width: 0;
}

.ct-output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 16px 13px 13px;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.ct-output-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.ct-output-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ct-script-badge {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: white;
    font-size: 11px;
    padding: 2px 9px;
    border-radius: 10px;
    font-weight: 500;
}

.ct-output-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
}

/* ========== 空状态 ========== */
.ct-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 70px 24px;
    color: #94a3b8;
}

.ct-empty-icon {
    font-size: 52px;
    margin-bottom: 18px;
    line-height: 1;
    animation: ctIconFloat 3s ease-in-out infinite;
}

@keyframes ctIconFloat {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-8px); }
}

.ct-empty-text {
    font-size: 15px;
    color: #64748b;
    margin: 0 0 8px;
    font-weight: 500;
}

.ct-empty-sub {
    font-size: 12px;
    color: #b0bec5;
    margin: 0;
    text-align: center;
    line-height: 1.6;
    max-width: 280px;
}

/* ========== 剧本渲染样式 ========== */
.ct-script-header {
    margin-bottom: 18px;
    padding: 14px;
    border-bottom: 2px solid #fce4e4;
    border-top: 3px solid #c0392b;
    background: linear-gradient(to right, #fff8f8 0%, #ffffff 60%);
    border-radius: 6px 6px 0 0;
}

.ct-script-title {
    font-size: 20px;
    font-weight: 700;
    color: #8e1010;
    margin-bottom: 10px;
    line-height: 1.3;
}

.ct-script-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 12px;
}

.ct-meta-tag {
    background: #fff1f0;
    border: 1px solid #ffccc7;
    color: #c0392b;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.ct-cast-info {
    display: flex;
    gap: 20px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #fff8f8 0%, #fff1f0 100%);
    border-radius: 6px;
    border: 1px solid #ffe0de;
    flex-wrap: wrap;
}

.ct-cast-role {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.ct-cast-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.ct-cast-avatar.lead-av    { background: linear-gradient(135deg, #c0392b, #e74c3c); }
.ct-cast-avatar.support-av { background: linear-gradient(135deg, #2980b9, #3498db); }

.ct-cast-label {
    font-weight: 600;
    font-size: 11px;
    color: #94a3b8;
}

.ct-cast-name {
    font-weight: 600;
    color: #1e293b;
}

/* 简介 */
.ct-script-summary {
    margin-bottom: 18px;
    padding: 11px 14px;
    background: #fffbe6;
    border-left: 3px solid #f39c12;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    color: #475569;
    line-height: 1.65;
}

/* 台词区域 */
.ct-script-dialog {
    margin-bottom: 20px;
}

.ct-dialog-line {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    animation: ctFadeIn 0.25s ease;
}

.ct-script-dialog .ct-dialog-line:last-child {
    margin-bottom: 0;
}

@keyframes ctFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ct-dialog-avatar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    margin-top: 2px;
}

.ct-dialog-line.is-lead    .ct-dialog-avatar { background: linear-gradient(135deg, #c0392b, #e74c3c); }
.ct-dialog-line.is-support .ct-dialog-avatar { background: linear-gradient(135deg, #2980b9, #3498db); }

.ct-dialog-body {
    flex: 1;
    padding: 9px 13px;
    border-radius: 0 8px 8px 8px;
    font-size: 13px;
    line-height: 1.65;
    min-width: 0;
}

.ct-dialog-line.is-lead    .ct-dialog-body {
    background: #fff8e1;
    border: 1px solid #ffe082;
    color: #424242;
}

.ct-dialog-line.is-support .ct-dialog-body {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    color: #1a237e;
}

.ct-dialog-role-name {
    font-weight: 700;
    margin-right: 3px;
}

.ct-dialog-action {
    font-size: 11px;
    color: #78909c;
    font-style: italic;
    margin-top: 4px;
}

/* 创作说明 */
.ct-script-notes {
    padding: 14px 16px;
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #9b59b6;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    color: #475569;
    line-height: 1.7;
    margin-bottom: 0;
}

.ct-script-notes-title {
    font-weight: 700;
    color: #1e293b;
    font-size: 13px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ========== 示例模态框 ========== */
.ct-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    z-index: 100000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.ct-modal.show {
    display: flex;
}

@keyframes ctModalIn {
    from { opacity: 0; transform: translateY(-18px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ct-modal-content {
    background: white;
    border-radius: 8px;
    max-width: 720px;
    width: 100%;
    max-height: 82vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
    animation: ctModalIn 0.22s ease-out;
}

.ct-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #fafafa;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.ct-modal-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #424242;
}

.ct-modal-close {
    background: #f5f5f5;
    border: none;
    color: #757575;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ct-modal-close:hover {
    background: #e8e8e8;
    color: #424242;
}

.ct-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.ct-modal-tip {
    font-size: 12px;
    color: #94a3b8;
    margin: 0 0 12px;
}

.ct-examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 12px;
}

.ct-example-card {
    padding: 14px;
    background: #fafafa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.18s;
}

.ct-example-card:hover {
    border-color: #c0392b;
    background: #fff8f8;
    box-shadow: 0 3px 10px rgba(192, 57, 43, 0.12);
    transform: translateY(-2px);
}

.ct-example-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 7px;
}

.ct-example-card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.ct-example-tag {
    background: #fff1f0;
    color: #c0392b;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    border: 1px solid #ffc4bf;
    font-weight: 500;
}

.ct-example-card-desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.55;
}

/* ========== 加载遮罩 ========== */
.ct-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.ct-loading-box {
    text-align: center;
    color: white;
    padding: 36px 48px;
    background: rgba(142, 16, 16, 0.35);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}

.ct-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ctSpin 0.9s linear infinite;
    margin: 0 auto 20px;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.15);
}

@keyframes ctSpin {
    to { transform: rotate(360deg); }
}

.ct-loading-text {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 8px;
    letter-spacing: 0.5px;
}

.ct-loading-sub {
    font-size: 13px;
    opacity: 0.75;
    margin: 0;
}

/* ========== Toast 通知 ========== */
.ct-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    padding: 10px 16px;
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    animation: ctFadeIn 0.2s ease;
    max-width: 320px;
    line-height: 1.5;
}

/* ========== 自定义滚动条 ========== */
.ct-history-list::-webkit-scrollbar,
.ct-output-content::-webkit-scrollbar,
.ct-input-inner::-webkit-scrollbar {
    width: 4px;
}

.ct-history-list::-webkit-scrollbar-track,
.ct-output-content::-webkit-scrollbar-track,
.ct-input-inner::-webkit-scrollbar-track {
    background: transparent;
}

.ct-history-list::-webkit-scrollbar-thumb,
.ct-output-content::-webkit-scrollbar-thumb,
.ct-input-inner::-webkit-scrollbar-thumb {
    background: #dde1e7;
    border-radius: 4px;
}

.ct-history-list::-webkit-scrollbar-thumb:hover,
.ct-output-content::-webkit-scrollbar-thumb:hover,
.ct-input-inner::-webkit-scrollbar-thumb:hover {
    background: #c0392b;
}

/* ========== 响应式 ========== */
@media (max-width: 900px) {
    .ct-history-panel { display: none; }
    .ct-input-panel   { width: 300px; }
}

@media (max-width: 640px) {
    .ct-input-panel { width: 100%; border-right: none; }
    .ct-output-panel { display: none; }
}
