@import "../../theme.css";

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 16px;
    background-color: var(--bg-main);
    -webkit-font-smoothing: antialiased;
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
    overflow: hidden;
    letter-spacing: -0.01em; 
    width: 100%; max-width: 100%; overflow-x: hidden;
}

*:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
input:focus, select:focus, button:focus { outline: none !important; }

.tool-wrapper { display: flex; flex-direction: column; height: 100%; gap: 12px; animation: fadeIn 0.3s ease; width: 100%; max-width: 100%; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }

.tool-header { display: flex; justify-content: space-between; align-items: center; }
.header-main h2 { font-size: 16px; font-weight: 600; margin: 0 0 4px 0; display: flex; align-items: center; gap: 8px;}
.header-main p { margin: 0; font-size: 12px; color: var(--text-secondary); }

.workspace-grid { flex: 1; display: grid; grid-template-columns: 360px 1fr; gap: 14px; min-height: 0; width: 100%; }

.pane { 
    background-color: var(--bg-card) !important; 
    border: 1px solid var(--border-color); 
    border-radius: 12px; 
    padding: 16px; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    position: relative; 
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth); 
    min-height: 0; 
    width: 100%; box-sizing: border-box;
}
.pane:focus-within { border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-tint); }
.pane-header { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.pane-title { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1; }
.pane-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.config-pane { overflow-y: auto; padding-right: 8px; background-color: #F8FAFC !important;}
.config-pane::-webkit-scrollbar { width: 6px; }
.config-pane::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.1); border-radius: 3px; }

.config-form { display: flex; flex-direction: column; gap: 12px; flex: 1; width: 100%; }

.config-block { 
    background-color: #FFF; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    padding: 14px; 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.01); 
    width: 100%; box-sizing: border-box;
}
.block-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }

.form-row { display: flex; gap: 10px; width: 100%; }
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.form-group label { font-size: 11px; font-weight: 500; color: var(--text-secondary); }

.warning-alert-badge {
    background-color: #FFFBEB;
    border: 1px solid #FDE68A;
    color: #B45309;
    font-size: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    line-height: 1.5;
    margin-top: 4px;
}

.slider-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.slider-header label { font-size: 11px !important; font-weight: 500 !important; color: var(--text-secondary) !important; }

.slider-val { font-size: 11px; font-variant-numeric: tabular-nums; font-family: ui-monospace, monospace; color: var(--accent-color); font-weight: 600; background: var(--accent-tint); padding: 2px 6px; border-radius: 4px; }

input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; margin: 4px 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 16px; width: 16px; border-radius: 50%; background: var(--accent-color); cursor: pointer; margin-top: -6px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: transform 0.1s; }
input[type=range]::-webkit-slider-thumb:active { transform: scale(1.25); }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; cursor: pointer; background: var(--border-color); border-radius: 2px; }

.toggle-switch-label input { accent-color: var(--accent-color); cursor: pointer; width: 14px; height: 14px; margin: 0; }
.warning-text { font-size: 10px; color: var(--text-secondary); line-height: 1.4; display: block; margin-top: 4px; }

.custom-input { 
    background-color: #F8FAFC; 
    border: 1px solid var(--border-color); 
    border-radius: 6px; 
    padding: 0 12px; 
    font-size: 12px; 
    color: var(--text-primary); 
    height: 34px; 
    transition: all var(--transition-smooth); 
    width: 100%; 
    box-sizing: border-box; 
    font-family: inherit !important;
}
.custom-input:focus { background-color: #FFF; border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-tint); }

/* 💡 修复：强制设置 SVG 图标的 viewBox 与宽高属性，防止下拉箭头爆炸 */
select.custom-input { 
    cursor: pointer; 
    -webkit-appearance: none; appearance: none; 
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='14' height='14' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); 
    background-repeat: no-repeat; background-position: right 12px center; 
    padding-right: 36px !important; 
}

.sub-options { margin-top: 4px; border-top: 1px dashed var(--border-color); padding-top: 10px; animation: slideDown 0.2s ease-out; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.btn { box-sizing: border-box; border: 1px solid var(--border-color); border-radius: 6px; cursor: pointer; font-weight: 500; transition: all var(--transition-smooth); background-color: #FFF; color: var(--text-primary); display: inline-flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; font-family: inherit !important; overflow: hidden; text-overflow: ellipsis; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 11px; }
.btn-md { height: 32px; padding: 0 14px; font-size: 12px; }
.btn-muted { border-color: var(--border-color); color: var(--text-secondary); }
.btn-muted:hover { background-color: var(--bg-active-hover); color: var(--text-primary); }
.btn-primary { background-color: var(--accent-color); color: #FFF; border-color: var(--accent-color); }
.btn-primary:hover { opacity: 0.95; transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }

.btn-generate-action {
    width: 100%; height: 46px; font-size: 14px; font-weight: 600;
    border-radius: 8px; border: none; background-color: var(--accent-color);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.18); margin-top: 10px;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    font-family: inherit !important; transition: all 0.2s;
}
.btn-generate-action:hover { box-shadow: 0 6px 20px rgba(79, 70, 229, 0.3); transform: translateY(-1px); background-color: #4338CA; }
.btn-generate-action:disabled { background-color: var(--text-muted); box-shadow: none; cursor: not-allowed; opacity: 0.6; transform: none; }

.badge { font-size: 10px; font-weight: 700; padding: 2px 5px; border-radius: 4px; letter-spacing: 0.05em; }
.badge-slate { background-color: var(--bg-active); color: var(--text-secondary); }
.badge-indigo { background-color: var(--accent-tint); color: var(--accent-color); }

.table-wrapper { flex: 1; overflow-y: auto; overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; padding: 0; border: 2px dashed transparent; border-radius: 8px; transition: border-color var(--transition-smooth), background-color var(--transition-smooth); width: 100%; }
.table-wrapper.drag-over { border-color: var(--accent-color); background-color: var(--accent-tint); }
.table-wrapper::-webkit-scrollbar { width: 6px; height: 6px; }
.table-wrapper::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.1); border-radius: 3px; }

.empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 20px; pointer-events: none; }
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.8; }
.empty-state h3 { margin: 0 0 6px 0; font-size: 14px; color: var(--text-primary); font-weight: 600; }
.empty-state p { margin: 0; font-size: 12px; color: var(--text-muted); max-width: 320px; line-height: 1.6; }

.preview-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; min-width: 650px; }
.preview-table th { position: sticky; top: 0; background: #F1F5F9; padding: 10px 14px; color: var(--text-secondary); border-bottom: 1px solid var(--border-color); font-weight: 600; z-index: 2; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.preview-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-color); color: var(--text-primary); word-break: break-all; vertical-align: middle; }
.preview-table tr:last-child td { border-bottom: none; }
.preview-table tr:hover td { background-color: rgba(15,23,42,0.02); }

.table-btn-group { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: nowrap; }

.summary-bar { background-color: #F8FAFC; border-top: 1px solid var(--border-color); padding: 10px 16px; display: flex; align-items: center; font-size: 12px; color: var(--text-secondary); border-radius: 0 0 12px 12px; flex-shrink: 0; flex-wrap: wrap; gap: 8px; }
.summary-bar strong { color: var(--text-primary); }

.modal-overlay { position: fixed; inset: 0; background-color: rgba(15, 23, 42, 0.45); backdrop-filter: blur(4px); z-index: 9999; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.2s ease; padding: 16px; box-sizing: border-box; }
.modal-container { width: 100%; max-width: 900px; background-color: #FFFFFF; border-radius: 16px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.04); border: 1px solid var(--border-color); display: flex; flex-direction: column; overflow: hidden; animation: slideUp 0.25s cubic-bezier(0.25, 1, 0.5, 1); }

@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.modal-header { padding: 14px 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 13px; font-weight: 700; color: var(--text-primary); }
.modal-close-btn { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--text-muted); width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all var(--transition-smooth); }
.modal-close-btn:hover { background-color: var(--bg-active-hover); color: var(--text-primary); }

.modal-body { padding: 0; overflow: hidden; }

.compare-slider-container {
    position: relative; width: 100%; height: 520px; background-color: #0F172A; 
    overflow: hidden; user-select: none; cursor: ew-resize;
}

.slider-img {
    position: absolute; left: 0; top: 0; width: 100%; height: 100%;
    object-fit: contain; pointer-events: none;
}
.slider-img.compressed { z-index: 2; clip-path: polygon(0 0, var(--clip-pos, 50%) 0, var(--clip-pos, 50%) 100%, 0 100%); }

.slider-handle {
    position: absolute; top: 0; bottom: 0; left: var(--clip-pos, 50%); width: 2px;
    background-color: #FFFFFF; z-index: 5; pointer-events: none; transform: translateX(-50%);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
}

.slider-handle::after {
    content: '↔'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 32px; height: 32px; background-color: var(--accent-color); color: #FFFFFF;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: bold; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.compare-statistics-row {
    background-color: #F8FAFC; border-top: 1px solid var(--border-color); padding: 12px 20px;
    display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; color: var(--text-secondary);
}

.loading-pulse { animation: pulse 1.4s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }

.toast-notification { 
    position: fixed; top: -50px; left: 50%; transform: translateX(-50%); 
    background-color: rgba(15, 23, 42, 0.95); color: #FFF; padding: 10px 20px; 
    border-radius: 8px; font-size: 13px; font-weight: 500; 
    box-shadow: 0 6px 20px rgba(0,0,0,0.15); z-index: 9999; display: flex; 
    align-items: center; gap: 8px; opacity: 0; transition: top 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.4s ease; 
    pointer-events: none; max-width: 85vw; white-space: normal; word-break: break-all; line-height: 1.5;
}
.toast-notification.show { top: 20px; opacity: 1; }

@media (max-width: 850px) {
    body { padding: 8px; overflow-y: auto; height: auto; overflow-x: hidden; }
    /* 彻底锁定字体防缩放 */
    input, textarea, select { font-size: 16px !important; }
    
    .tool-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .header-main h2 { font-size: 15px; }

    .header-actions { flex-direction: row; flex-wrap: wrap; width: 100%; gap: 8px; margin-top: 4px; }
    .header-actions .btn { flex: 1; min-width: calc(50% - 8px); height: 38px; padding: 0 6px; }

    .workspace-grid { grid-template-columns: 1fr; height: auto; gap: 10px; }
    .config-pane { min-height: auto; padding: 12px; }
    .preview-pane { min-height: 480px; height: 60vh; border-radius: 12px; }
    
    .pane-header { flex-direction: column; align-items: flex-start; gap: 10px; height: auto; }
    .pane-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
    .pane-actions .btn { flex: 1; height: 38px; font-size: 12px; min-width: calc(33.33% - 6px); white-space: nowrap; padding: 0 4px; }

    /* 移动端控件增高重排 */
    .custom-input { height: 44px; padding: 0 14px; font-size: 15px !important; }
    .form-group label { font-size: 12px; margin-bottom: 2px; }
    .compare-slider-container { height: 320px; }
}