@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; 
}

*: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; }
@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; }

.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; 
}
.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; }

.config-pane { overflow-y: auto; padding-right: 4px; }
.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; }

.config-block { 
    background-color: #FFF; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    padding: 12px; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.01); 
}
.block-title { font-size: 12px; 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: 6px 10px;
    border-radius: 6px;
    line-height: 1.4;
    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: 14px; width: 14px; border-radius: 50%; background: var(--accent-color); cursor: pointer; margin-top: -5px; 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; }

.custom-input { 
    background-color: #F8FAFC; 
    border: 1px solid var(--border-color); 
    border-radius: 6px; 
    padding: 0 10px; 
    font-size: 12px; 
    color: var(--text-primary); 
    height: 32px; 
    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); }
select.custom-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 5 6 8 9 5'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

.sub-options { margin-top: 4px; border-top: 1px dashed var(--border-color); padding-top: 8px; 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; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 11px; }
.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; box-shadow: 0 2px 6px rgba(79, 70, 229, 0.15); }
.btn:active { transform: scale(0.97); }

.btn-generate-action {
    width: 100%; height: 44px; font-size: 13px; 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;
}
.btn-generate-action:disabled { background-color: var(--text-muted); box-shadow: none; cursor: not-allowed; opacity: 0.6; }

.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; position: relative; padding: 0; border: 2px dashed transparent; border-radius: 8px; transition: border-color var(--transition-smooth), background-color var(--transition-smooth); }
.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; }
.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; }
.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; }

.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; }
.summary-bar strong { color: var(--text-primary); }

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

/* 💡 Toast 提示修复溢出问题，适应移动端多行显示 */
.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; }
    input, textarea, select { font-size: 16px !important; }
    .workspace-grid { grid-template-columns: 1fr; height: auto; }
    .config-pane { min-height: auto; }
    .preview-pane { min-height: 400px; height: auto; padding-bottom: 20px; }
}