/* =========================================================
 * Smart Import - Unified Workbench Styles
 * Design System: Dark-Mode-OLED variant, Fira typography,
 * Professional Data Platform aesthetic
 * Colors: Primary #1E40AF | Accent #F59E0B | BG #F8FAFC
 * ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&family=Atkinson+Hyperlegible:wght@400;700&family=Crimson+Pro:wght@400;500;600;700&display=swap');

/* ---- 根变量 ---- */
:root {
    --wb-left-width: 240px;
    --wb-right-width: 340px;
    --wb-border-color: #e2e8f0;
    --wb-bg-color: #ffffff;
    --wb-header-height: 52px;

    /* Animation & UI Tokens from Design System */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --ds-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --ds-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --ds-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Design System tokens */
    --ds-primary:     #1E40AF;
    --ds-primary-light: #3B82F6;
    --ds-accent:      #F59E0B;
    --ds-accent-dark: #D97706;
    --ds-surface:     #F8FAFC;
    --ds-surface-2:   #F1F5F9;
    --ds-border:      #E2E8F0;
    --ds-text:        #0F172A;
    --ds-text-muted:  #475569;
    --ds-text-soft:   #94A3B8;

    /* Workbench sidebar gradient */
    --wb-sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e2a40 100%);
}

/* =========================================================
 * 容器
 * ========================================================= */
#smart-import-container {
    height: calc(100vh - 180px);
    display: flex;
    flex-direction: column;
    font-family: 'Atkinson Hyperlegible', 'Fira Sans', system-ui, sans-serif;
}

/* =========================================================
 * Phase 1: Upload Zone
 * ========================================================= */
.smart-upload-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed #CBD5E1;
    border-radius: 16px;
    background: #ffffff;
    transition: all var(--transition-normal);
    margin: 10px 0;
    min-height: 300px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

/* 炫光背景纹理 (纯CSS，无图片) */
.smart-upload-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 60% 30%, rgba(30,64,175,0.04) 0%, transparent 60%);
    pointer-events: none;
}

.smart-upload-zone:hover {
    border-color: var(--ds-primary);
    background: rgba(30, 64, 175, 0.025);
    box-shadow: 0 0 0 4px rgba(30, 64, 175, 0.08), var(--ds-shadow-lg);
    transform: translateY(-2px);
}

.upload-icon-large {
    font-size: 3.5rem;
    margin-bottom: 20px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.12));
    transition: transform 0.3s ease;
}

.smart-upload-zone:hover .upload-icon-large {
    transform: translateY(-4px);
}

/* =========================================================
 * Phase 2: Workbench (3-column layout)
 * ========================================================= */
.smart-workbench {
    display: grid;
    grid-template-columns: var(--wb-left-width) 1fr 0px; 
    height: 100%;
    border: 1px solid var(--ds-border);
    background: var(--wb-bg-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--ds-shadow-md);
}

/* ---- 1. Left Sidebar ---- */
.wb-left {
    width: var(--wb-left-width);
    border-right: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    background: var(--wb-sidebar-bg);
    flex-shrink: 0;
    min-height: 0;
    overflow: hidden;
}

.wb-header {
    height: var(--wb-header-height);
    padding: 0 18px;
    display: flex;
    align-items: center;
    font-family: 'Fira Code', monospace;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    background: rgba(0,0,0,0.2);
    color: #94A3B8;
}

.wb-tree {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.wb-tree::-webkit-scrollbar {
    width: 4px;
}
.wb-tree::-webkit-scrollbar-track {
    background: transparent;
}
.wb-tree::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.tree-node {
    padding: 10px 16px 10px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #94A3B8;
    font-size: 0.95rem;
    font-family: 'Atkinson Hyperlegible', sans-serif;
    font-weight: 400;
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
    user-select: none;
}

.tree-node:hover {
    background: rgba(255,255,255,0.07);
    color: #E2E8F0;
}

.tree-node.active {
    background: rgba(59, 130, 246, 0.15);
    color: #93C5FD;
    border-left-color: #3B82F6;
    font-weight: 600;
}

.tree-node .count-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.1);
    color: #64748B;
    padding: 2px 7px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-family: 'Fira Code', monospace;
    transition: background 0.18s ease, color 0.18s ease;
}

.tree-node.active .count-badge {
    background: rgba(59, 130, 246, 0.3);
    color: #93C5FD;
}

.tree-node:hover .count-badge {
    background: rgba(255,255,255,0.15);
    color: #CBD5E1;
}

/* ---- 2. Center Stage ---- */
.wb-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #FFFFFF;
    min-width: 0;
    min-height: 0; /* Important for flex/grid children to allow scrolling */
    overflow: hidden;
}

.wb-toolbar {
    height: var(--wb-header-height);
    border-bottom: 1px solid var(--ds-border);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FAFBFC;
    box-shadow: 0 1px 0 var(--ds-border);
}

.wb-toolbar span#centerTitle {
    font-family: 'Fira Sans', sans-serif;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ds-text);
    letter-spacing: 0.01em;
}

.editor-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto; /* Enable horizontal scrolling for wide grids */
    padding: 20px 24px;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}

.editor-container::-webkit-scrollbar {
    width: 5px;
}
.editor-container::-webkit-scrollbar-track {
    background: transparent;
}
.editor-container::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 3px;
}

/* ---- Grid Table ---- */
.smart-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto; /* Allow columns to adapt to content and min-widths */
    min-width: 1200px; /* Ensure enough horizontal space for many columns */
    font-size: 0.88rem;
}

.smart-grid thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.smart-grid th {
    background: var(--ds-surface-2);
    padding: 10px 10px; /* Unified horizontal padding */
    font-family: 'Fira Code', monospace;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ds-text-muted);
    border-bottom: 2px solid var(--ds-border);
    text-align: left;
}

.smart-grid td {
    border: 1px solid #F1F5F9;
    padding: 0;
    transition: background var(--transition-fast);
}

.smart-grid tr:hover td {
    background: rgba(30, 64, 175, 0.04);
}

.smart-grid tr.selected-row td {
    background: rgba(59, 130, 246, 0.06);
}

.grid-input {
    width: 100%;
    border: none;
    padding: 8px 10px; /* Unified horizontal padding with TH */
    font-family: 'Atkinson Hyperlegible', 'Fira Sans', sans-serif;
    font-size: 0.85rem;
    color: var(--ds-text);
    background: transparent;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    resize: none;
    height: auto;
    min-height: 32px;
    max-height: none;
    line-height: 1.4;
    transition: background 0.15s ease;
}

.grid-input:focus {
    outline: 2px solid var(--ds-primary);
    outline-offset: -2px;
    background: rgba(30, 64, 175, 0.03);
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

/* ---- Rich Text view ---- */
.rich-editor-box {
    border: 1px solid var(--ds-border);
    min-height: 400px;
    padding: 24px 28px;
    border-radius: 10px;
    max-width: 800px;
    margin: 0 auto;
    box-shadow:
        0 1px 3px rgba(15,23,42,0.04),
        0 4px 16px -4px rgba(15,23,42,0.08);
    font-family: 'Fira Sans', sans-serif;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--ds-text);
}

/* ---- 3. Right Inspector ---- */
.wb-right {
    width: var(--wb-right-width);
    border-left: 1px solid var(--ds-border);
    display: flex;
    flex-direction: column;
    background: var(--ds-surface);
    flex-shrink: 0;
}

.wb-right .wb-header {
    background: rgba(248, 250, 252, 0.9);
    color: var(--ds-text-muted);
    border-bottom: 1px solid var(--ds-border);
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.inspector-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}

.inspector-content::-webkit-scrollbar {
    width: 4px;
}
.inspector-content::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 2px;
}

.field-group {
    margin-bottom: 20px;
}

.field-label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ds-text-muted);
    font-family: 'Fira Code', monospace;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.inspector-hint {
    font-size: 0.84rem;
    color: var(--ds-text-soft);
    margin-bottom: 16px;
    background: var(--ds-surface-2);
    border: 1px solid var(--ds-border);
    padding: 10px 12px;
    border-radius: 8px;
    line-height: 1.6;
}

/* ---- Inspector form controls ---- */
.inspector-content .form-control,
.inspector-content select,
.inspector-content input[type="text"],
.inspector-content textarea {
    border: 1px solid var(--ds-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.88rem;
    font-family: 'Fira Sans', sans-serif;
    color: var(--ds-text);
    background: #FFFFFF;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.inspector-content .form-control:focus,
.inspector-content select:focus,
.inspector-content input[type="text"]:focus,
.inspector-content textarea:focus {
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
}

/* ---- Mini Dropzone ---- */
.mini-dropzone {
    border: 2px dashed var(--ds-border);
    border-radius: 8px;
    padding: 16px 14px;
    text-align: center;
    cursor: pointer;
    background: #FFFFFF;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    font-size: 0.85rem;
    color: var(--ds-text-soft);
}

.mini-dropzone:hover {
    border-color: var(--ds-primary);
    background: rgba(30, 64, 175, 0.03);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.06);
    color: var(--ds-primary);
}

/* ---- Media chips ---- */
.media-preview-list {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.media-chip {
    background: var(--ds-surface-2);
    border: 1px solid var(--ds-border);
    color: var(--ds-text-muted);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-family: 'Fira Code', monospace;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s ease;
}

.media-chip:hover {
    background: #E2E8F0;
}

/* =========================================================
 * Footer Action Bar
 * ========================================================= */
.wb-footer {
    height: 64px;
    border-top: 1px solid var(--ds-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 24px;
    background: #FAFBFC;
    gap: 10px;
}

/* =========================================================
 * Loading State Override
 * ========================================================= */
#smart-import-container [style*="text-align:center"][style*="padding:50px"],
#smart-import-container [style*="text-align: center"][style*="padding: 50px"] {
    padding: 60px 40px !important;
    background: #ffffff;
    border-radius: 12px;
    color: var(--ds-text-muted);
    font-family: 'Fira Sans', sans-serif;
    font-size: 0.95rem;
}