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

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

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; 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.4s cubic-bezier(0.2, 0.8, 0.2, 1); width: 100%; max-width: 100%; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } 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: 3px; border-radius: 8px; gap: 2px; box-shadow: inset 0 1px 2px rgba(0,0,0,0.02); }
.tab-btn { background: none; border: none; padding: 6px 16px; 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 4px rgba(0,0,0,0.06); }

.tab-content { display: none; flex-direction: column; flex: 1; gap: 12px; min-height: 0; width: 100%; animation: fadeTab 0.3s ease; }
.tab-content.active { display: flex; }
@keyframes fadeTab { from { opacity: 0; transform: translateX(4px); } to { opacity: 1; transform: translateX(0); } }

.workspace-grid { flex: 1; display: grid; grid-template-columns: 330px 1fr; gap: 16px; 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;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.02);
}
.pane:focus-within { border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-tint); }

.pane-header { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; border-bottom: 1px dashed var(--border-color); padding-bottom: 10px; margin-bottom: 0px; }
.pane-title { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1 1 auto; }
.pane-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.config-pane { overflow-y: auto; padding-right: 6px; 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 12px; 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.02); 
    transition: opacity 0.2s; 
    width: 100%;
    box-sizing: border-box;
}
.block-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.param-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 2px; display: block; }

.warning-alert-badge { 
    background: linear-gradient(to right, #FFFBEB, #FFFFFF); 
    border: 1px solid #FDE68A; 
    border-left: 4px solid #F59E0B;
    color: #92400E; 
    font-size: 11px; 
    padding: 10px 12px; 
    border-radius: 6px; 
    line-height: 1.6; 
    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: ui-monospace, monospace !important; letter-spacing: 0.5px; }
.custom-input:focus { background-color: #FFF; border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-tint); }
.custom-input::placeholder { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: normal; color: #94A3B8; }

.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: 6px; 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); border-color: var(--text-secondary); }
.btn-primary { background-color: var(--accent-color); color: #FFF; border-color: var(--accent-color); }
.btn-primary:hover { opacity: 0.95; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2); transform: translateY(-1px); }
.btn-primary:disabled { background-color: var(--text-muted); border-color: var(--border-color); box-shadow: none; cursor: not-allowed; transform: none; }
.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: auto !important;
    margin-bottom: 4px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; 
    font-family: inherit !important;
}
.btn-generate-action:hover { box-shadow: 0 6px 20px rgba(79, 70, 229, 0.3) !important; transform: translateY(-2px); background-color: #4338CA !important; }
.btn-generate-action:active { transform: scale(0.985); }
.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; display: inline-block; }
.badge-slate { background-color: var(--bg-active); color: var(--text-secondary); }
.badge-indigo { background-color: var(--accent-tint); color: var(--accent-color); }

.preview-pane { padding: 16px; border: 2px dashed transparent; transition: border-color var(--transition-smooth), background-color var(--transition-smooth); width: 100%; box-sizing: border-box; }
.preview-pane.drag-over { border-color: var(--accent-color); background-color: var(--accent-tint); }

.table-wrapper { flex: 1; overflow-y: auto; overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; padding: 0; border: 2px dashed rgba(15, 23, 42, 0.12); border-radius: 10px; width: 100%; transition: border-color 0.2s; background: #FFF; }
.preview-pane.drag-over .table-wrapper { border-color: var(--accent-color); background-color: rgba(79, 70, 229, 0.02); }
.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: relative; width: 100%; min-height: 240px; height: 100%;
    display: flex; flex-direction: column; justify-content: center; align-items: center; 
    text-align: center; padding: 24px 16px; transition: all 0.3s; box-sizing: border-box;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0) 0%, rgba(248, 250, 252, 0.6) 100%);
}
.click-to-upload { pointer-events: auto; cursor: pointer; }
.click-to-upload:hover { background-color: rgba(15, 23, 42, 0.02); }
.click-to-upload:active { transform: scale(0.99); }
.empty-icon { margin-bottom: 14px; opacity: 0.5; color: var(--text-secondary); transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.preview-pane.drag-over .empty-icon, .click-to-upload:hover .empty-icon { color: var(--accent-color); opacity: 1; transform: scale(1.1) translateY(-4px); }
.empty-state h3 { margin: 0 0 6px 0; font-size: 14px; color: var(--text-primary); font-weight: 600; line-height: 1.4; }
.empty-state p { margin: 0; font-size: 12px; color: var(--text-secondary); max-width: 100%; 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: #F8FAFC; 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; transition: background-color 0.2s; }
.preview-table tr { transition: opacity 0.2s, box-shadow 0.2s, background-color 0.2s; }
.preview-table tr:nth-child(even) { background-color: rgba(248, 250, 252, 0.5); }
.preview-table tr:last-child td { border-bottom: none; }
.preview-table tr:hover td { background-color: rgba(15,23,42,0.03); }
.preview-table tr.dragging { opacity: 0.5; box-shadow: 0 4px 12px rgba(0,0,0,0.1); background-color: var(--bg-active-hover); z-index: 10; position: relative; }

.sort-btn { display: none !important; }
.drag-column { display: table-cell; }
.drag-handle { display: table-cell; color: var(--text-muted); cursor: grab; text-align: center; vertical-align: middle; padding: 10px 16px !important; opacity: 0.4; transition: opacity 0.2s, color 0.2s, background-color 0.2s; }
.preview-table tr:hover .drag-handle { opacity: 1; }
.drag-handle:hover { color: var(--text-primary); background-color: rgba(15, 23, 42, 0.04); }
.preview-table tr:active .drag-handle { cursor: grabbing; color: var(--accent-color); opacity: 1; }

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

.extract-file-area { 
    flex: 1; display: flex; justify-content: center; align-items: center; 
    position: relative; width: 100%; padding: 20px; box-sizing: border-box;
    border: 2px dashed rgba(15, 23, 42, 0.15); border-radius: 10px; 
    transition: all 0.3s ease; background: rgba(248, 250, 252, 0.4); 
}
.preview-pane.drag-over .extract-file-area { border-color: var(--accent-color); background-color: rgba(79, 70, 229, 0.03); }

.file-loaded-info { 
    display: flex; align-items: center; gap: 14px; 
    width: 100%; max-width: 420px; 
    padding: 20px 24px; 
    background-color: #FFFFFF; 
    border: 1px solid var(--border-color); 
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.06), 0 2px 6px rgba(15, 23, 42, 0.03); 
    border-radius: 16px; 
    box-sizing: border-box; 
    animation: cardPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: transform 0.2s, box-shadow 0.2s;
}
.file-loaded-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08), 0 4px 10px rgba(15, 23, 42, 0.04);
}
@keyframes cardPop {
    0% { opacity: 0; transform: scale(0.92) translateY(12px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.file-icon-box { font-size: 36px; flex-shrink: 0; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.08)); }
.file-meta-details { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.loaded-file-name { font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.2px; }
.loaded-file-size { font-size: 10px; color: var(--text-secondary); font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.processing-overlay { position: absolute; inset: 0; background-color: rgba(255,255,255,0.9); backdrop-filter: blur(4px); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 200; gap: 14px; border-radius: 10px; }
.spinner { width: 32px; height: 32px; 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: 12px 24px; 
    border-radius: 30px; font-size: 13.5px; font-weight: 500; 
    box-shadow: 0 8px 30px rgba(0,0,0,0.15); z-index: 9999; display: flex; 
    align-items: center; gap: 10px; 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: 24px; 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: 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; font-size: 12px; }
    
    .workspace-grid { display: flex; flex-direction: column-reverse; height: auto; gap: 10px; }
    
    .config-pane { min-height: auto; padding: 12px; border-radius: 12px; }
    
    .preview-pane { min-height: auto; height: auto; padding-bottom: 16px; border-radius: 12px; padding: 12px;}
    
    .empty-state { min-height: 200px; padding: 16px; }

    .pane-header { flex-direction: column; align-items: flex-start; gap: 8px; height: auto; }
    .pane-title { flex: 1 1 auto; }
    .pane-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; margin-top: 4px; }
    .pane-actions .btn { flex: 1; height: 38px; font-size: 12px; min-width: calc(50% - 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; }

    .btn-generate-action { height: 46px !important; font-size: 14px !important; margin-top: 16px !important; }

    .drag-column { display: none !important; }
    .drag-handle { display: none !important; }
    .sort-btn { 
        display: inline-flex !important; 
        font-family: ui-monospace, SFMono-Regular, monospace !important; 
        font-weight: bold; width: 28px; padding: 0 !important; font-size: 13px !important; 
    }
    .sort-btn:disabled { opacity: 0.3; cursor: not-allowed; background-color: transparent !important; color: var(--text-muted) !important; border-color: var(--border-color) !important; }
}