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

input, textarea, button, select { font-family: inherit; }
input::placeholder, textarea::placeholder { font-family: inherit; }

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

textarea:focus, input:focus, textarea:focus-visible, input:focus-visible, button:focus-visible { outline: none !important; }
*:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.btn, .action-btn, .code-btn, .tab-btn { touch-action: manipulation; }

.tool-wrapper { display: flex; flex-direction: column; height: 100%; gap: 12px; width: 100%; max-width: 100%; }
.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; color: var(--text-primary); 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: 1fr 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: 8px; transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth); position: relative; 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 dashed var(--border-color); padding-bottom: 10px; }
.pane-title { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1; display: flex; align-items: center; }

.pane-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: 10px; font-weight: 700; padding: 2px 5px; border-radius: 4px; letter-spacing: 0.05em; display: inline-block; }
.badge-indigo { background-color: var(--accent-tint); color: var(--accent-color); }
.badge-slate { background-color: var(--bg-active); color: var(--text-secondary); }

textarea { width: 100%; flex: 1; border: none; outline: none; resize: none; font-size: 13px; line-height: 1.55; color: var(--text-primary); background-color: transparent; min-height: 0; box-sizing: border-box; }
textarea::-webkit-scrollbar { width: 6px; height: 6px; }
textarea::-webkit-scrollbar-track { background: transparent; }
textarea::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.05); border-radius: 3px; transition: background var(--transition-smooth); }
textarea::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.16); }
textarea:hover::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.1); }
textarea.drag-over { background-color: var(--accent-tint); outline: 2px dashed var(--accent-color); outline-offset: -4px; border-radius: 6px; }
#codeSource, #codeResult { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace !important; }
textarea::placeholder { color: #CBD5E1; }

.stats-dashboard { border-top: 1px dashed var(--border-color); padding-top: 10px; display: flex; justify-content: space-around; text-align: center; flex-wrap: wrap; gap: 6px; }
.stat-item { display: flex; flex-direction: column; gap: 2px; }
.stat-val { font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.stat-label { font-size: 10px; color: var(--text-muted); font-weight: 500; }

.control-panel { background-color: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; width: 100%; box-sizing: border-box; }
.control-group { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.group-name { font-size: 11px; font-weight: 600; color: var(--text-secondary); width: 90px; flex-shrink: 0; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }

.btn { box-sizing: border-box; border: 1px solid var(--border-color); border-radius: 6px; cursor: pointer; font-weight: 500; transition: all var(--transition-smooth), transform 0.08s ease; background-color: #FFF; color: var(--text-primary); display: inline-flex; align-items: center; justify-content: center; padding: 0; margin: 0; line-height: 1; white-space: nowrap; }
.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); border-color: var(--text-secondary); }
.clear-pane-btn:hover { color: #DC2626; border-color: #FCA5A5; background-color: #FEF2F2; }
.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); }
.history-btn { border-color: var(--accent-color); color: var(--accent-color); background-color: var(--accent-tint); }
.history-btn:hover { background-color: var(--accent-color); color: #FFF; }

.action-btn, .code-btn { background: none; border: 1px solid var(--border-color); color: var(--text-secondary); height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer; font-size: 11px; font-weight: 500; transition: all var(--transition-smooth), transform 0.08s ease; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.action-btn:hover, .code-btn:hover { background-color: var(--bg-active-hover); color: var(--text-primary); border-color: var(--text-secondary); }
.btn:active, .action-btn:active, .code-btn:active { transform: scale(0.97); }

.search-replace-container { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 750px; flex-wrap: wrap; }
.custom-input { background-color: rgba(15, 23, 42, 0.02); border: 1px solid var(--border-color); border-radius: 6px; padding: 0 12px; font-size: 12px; color: var(--text-primary); outline: none; transition: all var(--transition-smooth); flex: 1; height: 34px; min-width: 120px; box-sizing: border-box; }
.custom-input:focus { background-color: #FFFFFF; border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-tint); }

.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; height: auto; overflow-y: auto; overflow-x: hidden; }
    input, textarea, select { font-size: 16px !important; }
    
    .tool-wrapper { gap: 8px; }
    .tool-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .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; }
    .pane { height: 280px; min-height: 280px; padding: 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; white-space: nowrap; padding: 0 4px; min-width: calc(50% - 6px); }
    
    .control-panel { padding: 12px; gap: 10px; }
    .control-group { flex-direction: column; align-items: flex-start; gap: 6px; width: 100%; }
    .group-name { width: auto; font-size: 11px; margin-bottom: 2px; }
    .btn-group { display: flex; flex-direction: row; flex-wrap: wrap; width: 100%; gap: 6px; }
    
    .action-btn, .code-btn { flex: 1; min-width: calc(33.33% - 6px); height: 38px; font-size: 12px; padding: 0 6px; }
    
    .search-replace-container { flex-direction: column; align-items: stretch; width: 100%; gap: 8px; }
    .custom-input { width: 100%; height: 44px; padding: 0 14px; font-size: 15px !important; }
    #btnCustomReplace, #btnFilterLines { height: 44px; font-size: 14px; font-weight: 600; width: 100%; }
}