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

input, textarea, button, select { font-family: inherit; }
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; 
    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, textarea: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); }

.navigation-bar { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; width: 100%; }
.tab-switcher { display: flex; background-color: rgba(15, 23, 42, 0.03); border: 1px solid var(--border-color); padding: 2px; border-radius: 8px; gap: 2px; }
.tab-btn { background: none; border: none; padding: 6px 14px; font-size: 12px; font-weight: 600; color: var(--text-secondary); border-radius: 6px; cursor: pointer; transition: all var(--transition-smooth); white-space: nowrap; }
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { background-color: #FFFFFF; color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

.tab-content { display: none; flex-direction: column; flex: 1; gap: 12px; min-height: 0; width: 100%; }
.tab-content.active { display: flex; }

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

.pane { background-color: var(--bg-card); 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 { display: flex; flex-direction: column; overflow: hidden; padding: 16px; background-color: #F8FAFC; box-sizing: border-box; height: 100%; }
.config-form { display: flex; flex-direction: column; gap: 12px; flex: 1; overflow-y: auto; padding-right: 8px; width: 100%; }
.config-form::-webkit-scrollbar { width: 6px; }
.config-form::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.1); border-radius: 3px; }
.config-form::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.2); }

.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(0,0,0,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); }

.mode-selector { display: grid; grid-template-columns: repeat(2, 1fr); background-color: rgba(15, 23, 42, 0.03); border: 1px solid var(--border-color); padding: 2px; border-radius: 8px; gap: 2px; margin-bottom: 4px; width: 100%; }
.mode-btn { background: none; border: none; padding: 6px; font-size: 12px; font-weight: 600; color: var(--text-secondary); border-radius: 6px; cursor: pointer; transition: all var(--transition-smooth); text-align: center; white-space: nowrap; }
.mode-btn:hover { color: var(--text-primary); }
.mode-btn.active { background-color: #FFFFFF; color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

.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，永不变形拉伸 */
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; 
}

.custom-textarea { background-color: rgba(15, 23, 42, 0.02); border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; font-size: 13px; line-height: 1.6; color: var(--text-primary); transition: all var(--transition-smooth); font-family: inherit; width: 100%; box-sizing: border-box; }
.custom-textarea:focus { background-color: #FFF; border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-tint); }

#articleInputWrapper { display: none; flex-direction: column; gap: 10px; width: 100%; box-sizing: border-box; }
#articleTitleInput { font-weight: 600; }
#articleContentInput { min-height: 120px; resize: vertical; }

.color-picker-wrap { display: flex; align-items: center; gap: 8px; background-color: #F8FAFC; border: 1px solid var(--border-color); border-radius: 6px; padding: 0 8px; height: 34px; box-sizing: border-box; width: 100%; }
.color-picker-wrap input[type="color"] { -webkit-appearance: none; border: none; width: 18px; height: 18px; border-radius: 4px; cursor: pointer; padding: 0; background: none; flex-shrink: 0; }
.color-picker-wrap input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-wrap input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(0,0,0,0.15); border-radius: 4px; }
.color-val { font-size: 11px; color: var(--text-secondary); font-family: ui-monospace, monospace; text-transform: uppercase; font-weight: 500; }

.quick-swatches { display: flex; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: none; cursor: pointer; padding: 0; transition: transform 0.1s; box-shadow: 0 1px 2px rgba(0,0,0,0.15); position: relative; }
.swatch:hover { transform: scale(1.15); }
.swatch.active { outline: 2px solid var(--accent-color); outline-offset: 2px; }

.logo-upload-wrap { border: 2px dashed var(--border-color); border-radius: 8px; background-color: #F8FAFC; height: 80px; display: flex; justify-content: center; align-items: center; position: relative; cursor: pointer; overflow: hidden; transition: all var(--transition-smooth); width: 100%; box-sizing: border-box; }
.logo-upload-wrap:hover, .logo-upload-wrap.drag-over { border-color: var(--accent-color); background-color: var(--accent-tint); }
.logo-upload-hint { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-secondary); pointer-events: none; text-align: center; padding: 8px; }
.logo-upload-hint span { font-size: 11px; }
.upload-icon { width: 20px; height: 20px; color: var(--text-muted); }
.logo-preview-img { height: 48px; width: 48px; object-fit: contain; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); border: 2px solid #FFF; }

.slider-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.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: 6px 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; }

.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-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-outline { background-color: #FFF; border: 1px solid var(--border-color); color: var(--text-primary); font-size: 12px; height: 34px; padding: 0 16px; }
.btn-outline:hover { background-color: var(--bg-active-hover); }
.btn:active { transform: scale(0.97); }

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

.preview-pane { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow-y: auto; padding: 16px; box-sizing: border-box; width: 100%; }
.result-placeholder { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 20px; color: var(--text-secondary); }
.placeholder-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.8; }
.result-placeholder h3 { margin: 0 0 6px 0; font-size: 14px; color: var(--text-primary); font-weight: 600; }
.result-placeholder p { margin: 0; font-size: 12px; max-width: 280px; line-height: 1.6; color: var(--text-muted); }

.result-area { flex: 1; display: flex; flex-direction: column; gap: 14px; justify-content: center; align-items: center; animation: slideUp 0.3s cubic-bezier(0.25, 1, 0.5, 1); width: 100%; }
@keyframes slideUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.short-link-box { display: flex; align-items: center; justify-content: space-between; background-color: #F0FDF4; border: 1px solid #BBF7D0; border-radius: 8px; padding: 12px 14px; width: 100%; max-width: 480px; box-sizing: border-box; gap: 10px; }
.short-link-details { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.short-link-text { font-size: 14px; font-weight: 700; color: #166534; user-select: all; word-break: break-all; }

.qr-section { display: flex; flex-direction: column; align-items: center; gap: 10px; background-color: #F8FAFC; padding: 16px; border-radius: 12px; border: 1px dashed var(--border-color); width: 100%; max-width: 480px; box-sizing: border-box; }
.qr-label { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.qrcode-border-wrap { background: #FFF; padding: 12px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.06); display: flex; justify-content: center; align-items: center; }

/* 批量表格（重点防御横向溢出） */
.table-wrapper { flex: 1; overflow-y: auto; overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; padding: 0; min-height: 0; width: 100%; }
.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: 36px; margin-bottom: 12px; opacity: 0.6; }
.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-secondary); max-width: 300px; line-height: 1.6; }

.preview-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; min-width: 500px; }
.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; }
.table-btn-group .btn { flex-shrink: 0; }

.processing-overlay { position: absolute; inset: 0; background-color: rgba(255,255,255,0.85); backdrop-filter: blur(2px); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 200; gap: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border-color); border-top-color: var(--accent-color); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-text { font-size: 13px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.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; }
    /* 防 iOS 自动放大 */
    input, textarea, select { font-size: 16px !important; }
    
    .tool-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .header-main h2 { font-size: 15px; }

    .navigation-bar { border-bottom: none; padding-bottom: 0; width: 100%; }
    .tab-switcher { width: 100%; }
    .tab-btn { flex: 1; text-align: center; padding: 8px 10px; }
    
    .workspace-grid { grid-template-columns: 1fr; height: auto; gap: 10px; }
    .config-pane { min-height: auto; padding: 12px; }
    .preview-pane { min-height: 480px; height: auto; padding-bottom: 20px; }
    
    .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; }

    .short-link-box { flex-direction: column; align-items: stretch; gap: 12px; }
    .short-link-box .btn { width: 100%; margin-top: 0; height: 42px; font-size: 13px; }
    .short-link-text { word-break: break-all; white-space: normal; line-height: 1.4; }
}