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

*, *::before, *::after { box-sizing: border-box; }
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; letter-spacing: -0.01em;
}

*:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
input:focus, button:focus, textarea:focus, select: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: translate3d(0, 4px, 0); } to { opacity: 1; transform: translate3d(0, 0, 0); } }

/* 头部样式 */
.tool-header { display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.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); }
.header-actions { display: flex; align-items: center; gap: 16px; }

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

/* 开关与按钮 */
.toggle-switch-label { font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-primary); display: flex; align-items: center; gap: 6px; transition: opacity 0.2s; }
.toggle-switch-label:hover { opacity: 0.8; }
.toggle-switch-label input { accent-color: var(--accent-color); width: 15px; height: 15px; cursor: pointer; margin: 0; }

.btn { 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: 6px; }
.btn-md { height: 32px; padding: 0 14px; font-size: 12px; }
.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 4px 12px rgba(79, 70, 229, 0.2); transform: translate3d(0, -1px, 0); }
.btn-primary:active { transform: scale(0.98); }

/* --- 统一流线型 URL 输入条 --- */
.url-bar-container { 
    display: flex; align-items: center; gap: 12px; 
    background-color: var(--bg-card); padding: 12px; 
    border-radius: 12px; border: 1px solid var(--border-color); 
    box-shadow: 0 2px 6px rgba(15,23,42,0.02); flex-shrink: 0; 
}
.url-input-group { 
    display: flex; flex: 1; align-items: center; 
    background-color: #F8FAFC; border: 1px solid var(--border-color); 
    border-radius: 8px; height: 42px; transition: all var(--transition-smooth); 
    overflow: hidden; 
}
.url-input-group:focus-within { border-color: var(--accent-color); background-color: #FFF; box-shadow: 0 0 0 3px var(--accent-tint); }

/* 注入 SVG 下拉箭头 */
.method-select { 
    border: none; background-color: transparent; height: 100%; padding: 0 26px 0 16px; 
    font-weight: 700; font-size: 13px; color: var(--text-primary); 
    cursor: pointer; outline: none; -webkit-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; 
}
.method-divider { width: 1px; height: 20px; background-color: var(--border-color); margin: 0 4px; }
.url-input { flex: 1; border: none; background: transparent; height: 100%; padding: 0 12px; font-size: 14px; font-family: ui-monospace, monospace; color: var(--text-primary); outline: none; }
.url-input::placeholder { color: #94A3B8; }

.code-btn-action { height: 42px !important; padding: 0 16px; font-size: 13px !important; border-radius: 8px !important; }
.btn-generate-action { height: 42px !important; padding: 0 24px; font-size: 14px !important; font-weight: 600 !important; border-radius: 8px !important; flex-shrink: 0; }
.btn-generate-action.loading { background-color: #4338CA; cursor: wait; opacity: 0.9; }

/* --- 经典四宫格网格 --- */
.workspace-layout { display: flex; gap: 14px; flex: 1; min-height: 0; }
.layout-column { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; width: 50%; }

.pane { background-color: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; display: flex; flex-direction: column; position: relative; min-height: 0; overflow: hidden; box-shadow: 0 2px 6px rgba(15,23,42,0.02); transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth); }
.pane:focus-within { border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-tint); }
.req-pane-top, .resp-pane-top { flex: 4; }
.req-pane-bottom, .resp-pane-bottom { flex: 6; }

/* 头部工具条 */
.pane-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border-color); background-color: #FFF; flex-shrink: 0; min-height: 38px; }
.pane-toolbar.bg-muted { background-color: #F8FAFC; }
.toolbar-title { font-size: 12px; font-weight: 700; color: var(--text-primary); flex-shrink: 0; }

.toolbar-tabs { display: flex; background: rgba(15,23,42,0.04); padding: 2px; border-radius: 6px; border: 1px solid var(--border-color); }
.tab-pill { background: transparent; border: none; padding: 4px 10px; font-size: 11px; font-weight: 600; color: var(--text-secondary); border-radius: 4px; cursor: pointer; transition: all 0.2s; }
.tab-pill:hover { color: var(--text-primary); }
.tab-pill.active { background: #FFF; color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

.toolbar-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.action-divider { width: 1px; height: 14px; background-color: var(--border-color); margin: 0 4px; }

/* 划词加解密控件 */
.crypto-toolbar { gap: 6px; }
.mini-select, .mini-input { border: 1px solid var(--border-color); border-radius: 4px; height: 26px; padding: 0 6px; font-size: 11px; background-color: #F8FAFC; color: var(--text-primary); outline: none; transition: border-color 0.2s; font-family: inherit; }
.mini-select:focus, .mini-input:focus { border-color: var(--accent-color); background-color: #FFF; }
.mini-input { width: 75px; font-family: ui-monospace, monospace; }

/* 注入专属的小箭头 */
.arrow-select { -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='2 4 5 7 8 4'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 6px center; padding-right: 20px; cursor: pointer; }

.action-btn { background: none; border: 1px solid var(--border-color); color: var(--text-secondary); height: 26px; padding: 0 10px; border-radius: 4px; cursor: pointer; font-size: 11px; font-weight: 500; transition: all var(--transition-smooth); display: inline-flex; align-items: center; justify-content: center; }
.action-btn:hover { background-color: var(--bg-active-hover); color: var(--text-primary); border-color: var(--text-secondary); }
.text-accent { color: var(--accent-color); }
.font-bold { font-weight: 600; }

/* 原生编辑器区 */
.raw-editor { flex: 1; border: none; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; line-height: 1.55; color: var(--text-primary); background-color: transparent; resize: none; outline: none; word-break: break-all; white-space: pre-wrap; }
.raw-editor::-webkit-scrollbar { width: 6px; height: 6px; }
.raw-editor::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.1); border-radius: 3px; }
.raw-editor::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.2); }
.raw-editor::placeholder { color: #94A3B8; }
.readonly-editor { background-color: #FAFAFA; color: #334155; }

/* 响应高亮展示与网页沙盒 */
.code-viewer-container { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; background-color: #FAFAFA; }
.code-viewer { margin: 0; position: absolute; inset: 0; overflow: auto; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; line-height: 1.5; color: #334155; white-space: pre-wrap; word-wrap: break-word; }
.code-viewer::-webkit-scrollbar { width: 8px; height: 8px; }
.code-viewer::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.15); border-radius: 4px; }
.preview-iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; background: #FFF; }

.json-key { color: #4338CA; font-weight: 600; }
.json-string { color: #059669; }
.json-number { color: #D97706; }
.json-boolean { color: #2563EB; font-weight: 600; }
.json-null { color: #94A3B8; font-style: italic; }

/* 响应统计 */
.resp-stats { display: flex; gap: 8px; font-size: 11px; }
.stat-badge { font-weight: 600; font-family: ui-monospace, monospace; padding: 2px 6px; border-radius: 4px; background: rgba(15,23,42,0.04); color: var(--text-secondary); }
.stat-badge .val.status-green { color: #10B981; }
.stat-badge .val.status-yellow { color: #F59E0B; }
.stat-badge .val.status-red { color: #EF4444; }

/* --- 🌟 GPU 级全高侧边大抽屉 (Side Drawer) --- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.3); backdrop-filter: blur(2px); z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); will-change: opacity; }
.drawer-overlay.show { opacity: 1; pointer-events: auto; }

.side-drawer { position: fixed; top: 0; bottom: 0; width: 480px; max-width: 90vw; background: var(--bg-main); box-shadow: 0 0 40px rgba(0,0,0,0.15); z-index: 1001; display: flex; flex-direction: column; will-change: transform; transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
/* 右抽屉：代码与正则 */
.side-drawer.right-drawer { right: 0; transform: translate3d(100%, 0, 0); }
.side-drawer.right-drawer.show { transform: translate3d(0, 0, 0); }
/* 左抽屉：历史记录 */
.side-drawer.left-drawer { left: 0; width: 340px; transform: translate3d(-100%, 0, 0); border-right: 1px solid var(--border-color); }
.side-drawer.left-drawer.show { transform: translate3d(0, 0, 0); }

.drawer-content { display: flex; flex-direction: column; height: 100%; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; background: #FFF; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.code-lang-tabs { display: flex; gap: 8px; }
.lang-tab { background: none; border: none; font-size: 13px; font-weight: 600; color: var(--text-secondary); cursor: pointer; padding: 6px 12px; border-radius: 6px; transition: background 0.2s, color 0.2s; }
.lang-tab:hover { background-color: var(--bg-active-hover); }
.lang-tab.active { background-color: var(--accent-tint); color: var(--accent-color); }

.btn-drawer-close { background: #F1F5F9; border: none; font-size: 16px; color: var(--text-secondary); cursor: pointer; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.btn-drawer-close:hover { background: #FEE2E2; color: #EF4444; }

.drawer-body { padding: 20px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.drawer-desc { font-size: 12px; color: var(--text-secondary); margin: 0 0 16px 0; line-height: 1.6; }
.drawer-textarea { border: 1px solid var(--border-color); border-radius: 8px; background: #FFF; flex: 1; padding: 16px; font-size: 12.5px; transition: border-color 0.2s, box-shadow 0.2s; }
.drawer-textarea:focus { border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-tint); }
.custom-input { border: 1px solid var(--border-color); border-radius: 8px; padding: 0 12px; font-size: 13px; outline: none; background: #FFF; transition: border-color 0.2s, box-shadow 0.2s; }
.custom-input:focus { border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-tint); }

/* 历史记录卡片 */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item { background: #FFF; border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; cursor: pointer; transition: all 0.2s; display: flex; flex-direction: column; gap: 6px; }
.history-item:hover { border-color: var(--accent-color); box-shadow: 0 2px 10px var(--accent-tint); transform: translate3d(0, -1px, 0); }
.hist-top { display: flex; justify-content: space-between; align-items: center; }
.hist-method { font-size: 11px; font-weight: 700; color: var(--accent-color); padding: 2px 6px; background: var(--accent-tint); border-radius: 4px; }
.hist-time { font-size: 10px; color: var(--text-muted); }
.hist-url { font-size: 12px; color: var(--text-primary); word-break: break-all; font-family: ui-monospace, monospace; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* --- 🌟 Apple 质感胶囊 Toast (Pill) --- */
.toast-pill {
    position: fixed; top: 24px; left: 50%; transform: translate3d(-50%, -20px, 0);
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(15,23,42,0.06); border-radius: 40px;
    color: var(--text-primary); font-size: 13px; font-weight: 600;
    padding: 8px 20px 8px 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    display: flex; align-items: center; gap: 10px; z-index: 9999;
    opacity: 0; pointer-events: none; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: transform, opacity;
}
.toast-pill.show { transform: translate3d(-50%, 0, 0); opacity: 1; }
.toast-icon { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: #FFF; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.toast-icon.success { background: linear-gradient(135deg, #34D399, #059669); }
.toast-icon.error { background: linear-gradient(135deg, #F87171, #DC2626); }
.toast-icon.info { background: linear-gradient(135deg, #60A5FA, #2563EB); }
.toast-msg { letter-spacing: 0.2px; }

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

@media (max-width: 850px) {
    body { padding: 8px; height: auto; overflow-y: auto; }
    .workspace-layout { flex-direction: column; }
    .layout-column { width: 100%; }
    .url-bar-container { flex-direction: column; height: auto; gap: 10px; align-items: stretch; padding: 10px; }
    .url-input-group { width: 100%; flex-direction: column; border: none; height: auto; }
    .method-select { width: 100%; border: 1px solid var(--border-color); border-bottom: none; border-radius: 6px 6px 0 0; height: 40px; }
    .method-divider { display: none; }
    .url-input { width: 100%; border: 1px solid var(--border-color); border-radius: 0 0 6px 6px; height: 40px; }
    .btn-generate-action, .code-btn-action { width: 100%; height: 42px !important; }
    .pane { min-height: 280px; }
    .pane-toolbar { flex-wrap: wrap; height: auto; padding: 8px; }
    .side-drawer { width: 100%; max-width: 100%; }
}