:root {
    --bg-main: #FFFFFF;
    --bg-sidebar: #F7F7F8;
    --bg-hover: #F0F2F5;
    --bg-canvas: #FAFAFA;
    --text-primary: #1F1F1F;
    --text-secondary: #444746;
    --text-hint: #9B9B9B;
    --accent-primary: #6C5CE7;
    --accent-hover: #5B4BD6;
    --accent-light: #EFEEFF;
    --border-light: #E5E5E5;
    --border-main: #D0D0D0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --bg-secondary: #F0F2F5;
    --bg-overlay: rgba(255, 255, 255, 0.95);
    --bg-success-light: #f0fff4;
    --bg-danger-light: #fff0f0;
    --bg-warning-light: #fff3cd;
    --bg-info-light: #e6fffa;
    --text-warning: #856404;
    --sidebar-width: 260px;
    --canvas-width: 900px;
    --header-height: 60px;
}

[data-theme="dark"] {
    --bg-main: #1a1a2e;
    --bg-sidebar: #16213e;
    --bg-hover: #1f2b47;
    --bg-canvas: #0f0f23;
    --text-primary: #e0e0e0;
    --text-secondary: #c8c8d8;
    --text-hint: #6b6b80;
    --accent-primary: #7c6cf0;
    --accent-hover: #6b5ce7;
    --accent-light: #2a2450;
    --border-light: #2a2a4a;
    --border-main: #3a3a5a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --bg-secondary: #1f2b47;
    --bg-overlay: rgba(26, 26, 46, 0.95);
    --bg-success-light: #1a2e1a;
    --bg-danger-light: #2e1a1a;
    --bg-warning-light: #2e2a1a;
    --bg-info-light: #1a2e2e;
    --text-warning: #f0c040;
    color-scheme: dark;
}

/* ───── Settings Page ───── */

.settings-card {
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.settings-card:hover {
    box-shadow: var(--shadow-md);
}

.settings-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-light);
}

.settings-card-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

.settings-card-desc {
    font-size: 12px;
    color: var(--text-hint);
    margin-top: 1px;
}

.settings-card-body {
    padding: 16px 20px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 40px;
}

.settings-row-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.settings-divider {
    height: 1px;
    background: var(--border-light);
    margin: 12px 0;
}

.settings-select {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    min-width: 140px;
    cursor: pointer;
    transition: border-color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239B9B9B' 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 10px center;
    padding-right: 32px;
}

.settings-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.12);
}

.settings-theme-btn {
    padding: 8px 18px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: var(--bg-secondary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.settings-theme-btn:hover {
    border-color: var(--accent-primary);
    background: var(--accent-light);
}

.settings-theme-btn.active {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}

.settings-toggle-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-toggle-desc {
    font-size: 12px;
    color: var(--text-hint);
    margin-top: 2px;
    line-height: 1.4;
}

/* Toggle switch */
.settings-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.settings-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.settings-switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-main);
    transition: 0.25s ease;
    border-radius: 24px;
}

.settings-switch-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.25s ease;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.settings-switch input:checked + .settings-switch-slider {
    background-color: var(--accent-primary);
}

.settings-switch input:checked + .settings-switch-slider:before {
    transform: translateX(20px);
}

.settings-switch input:disabled + .settings-switch-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ───── End Settings Page ───── */

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .form-control {
    background-color: var(--bg-main) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-light) !important;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: var(--text-hint) !important;
}

[data-theme="dark"] option {
    background-color: var(--bg-main);
    color: var(--text-primary);
}

[data-theme="dark"] .btn-light {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-light) !important;
}

[data-theme="dark"] table,
[data-theme="dark"] th,
[data-theme="dark"] td {
    border-color: var(--border-light) !important;
}

[data-theme="dark"] th {
    background-color: var(--bg-sidebar) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] td {
    background-color: var(--bg-main) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: var(--bg-canvas) !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-main);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    font-size: 15px;
    line-height: 1.5;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    cursor: pointer;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 1001;
    flex-shrink: 0;
    box-shadow: var(--shadow-lg);
}

.app-sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    position: relative;
}

.sidebar-close-btn {
    flex-shrink: 0;
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.sidebar-close-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-close-btn i {
    font-size: 18px;
}

.syncfusion-action-message {
    padding: 12px 16px;
    margin: 8px 0;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #991b1b;
    font-size: 14px;
    line-height: 1.4;
}

.btn-new-chat-full {
    flex: 1;
    padding: 10px;
    background-color: var(--bg-hover);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-new-chat-full:hover {
    background-color: var(--border-main);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.history-group-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-hint);
    margin: 20px 10px 10px;
}

.history-item {
    padding: 0;
    border-radius: 20px;
    color: var(--text-secondary);
    cursor: default;
    overflow: visible;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    margin-bottom: 2px;
}

.history-item-main {
    all: unset;
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    overflow: hidden;
    min-width: 0;
}

.history-item-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.history-item-title {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    line-height: 1.3;
}

.history-item-title > span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-subtitle {
    font-size: 11px;
    color: var(--text-hint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
    line-height: 1.3;
}

.history-item-main:disabled {
    cursor: default;
}

.history-item-actions {
    margin-left: auto;
    position: relative;
    display: flex;
    align-items: center;
}

.history-kebab {
    background: transparent;
    border: none;
    color: var(--text-hint);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.history-item:hover .history-kebab,
.history-item.active .history-kebab {
    opacity: 1;
}

.history-kebab:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

.history-menu {
    position: absolute;
    right: 0;
    top: 28px;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    min-width: 140px;
    z-index: 1000;
}

.history-menu-item {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
}

.history-menu-item:hover {
    background: var(--bg-hover);
}

.history-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.history-item.active {
    background-color: var(--accent-light);
    color: var(--text-primary);
    font-weight: 500;
}

.sidebar-footer {
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: var(--accent-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
}

.btn-settings {
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-settings:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-main);
    min-width: 0;
}

.chat-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
}

.sidebar-toggle-btn {
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    transition: background-color 0.2s ease;
}

.sidebar-toggle-btn:hover {
    background-color: var(--bg-hover);
}

.canvas-sidebar-toggle {
    margin-right: 12px;
    flex-shrink: 0;
}

.collapsed-dock {
    position: absolute;
    top: 70px;
    left: 20px;
    display: none;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
}

.collapsed-dock.show {
    display: flex;
}

.btn-dock-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-hover);
    color: var(--text-secondary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.btn-dock-icon:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.model-selector {
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.model-selector:hover {
    background-color: var(--bg-hover);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-container::-webkit-scrollbar {
    display: none;
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-primary);
    text-align: center;
}

.pdf-dropzone {
    width: min(720px, calc(100% - 40px));
    border: 2px dashed var(--border-light);
    border-radius: 14px;
    padding: 18px;
    background: var(--bg-secondary);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.pdf-dropzone.pdf-drop-over {
    border-color: var(--accent-primary);
    background: rgba(108, 92, 231, 0.06);
}

.pdf-dropzone-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pdf-dropzone-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pdf-dropzone-title .subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.pdf-file-row {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--bg-main);
}

.pdf-file-name {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.pdf-file-name span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid #c00;
    color: #c00;
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 13px;
}

.btn-danger-outline:hover {
    background: var(--bg-danger-light);
}

.brand-logo {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #6C5CE7 0%, #a29bfe 100%);
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 800px;
    width: 100%;
    padding: 20px;
}

.suggestion-card {
    padding: 16px;
    background-color: var(--bg-hover);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.suggestion-card:hover {
    background-color: var(--bg-hover);
}

.message-wrapper {
    width: 100%;
    max-width: 800px;
    padding: 0 20px;
    display: flex;
    gap: 16px;
}

.message-wrapper.user {
    justify-content: flex-end;
}

.message-avatar.ai {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--bg-main);
    border: 1px solid var(--border-light);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 90%;
    width: 100%;
}

.message-bubble {
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.6;
}

.message-wrapper.user .message-bubble {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 20px 20px 4px 20px;
}

.extraction-card {
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 20px;
    margin-top: 20px;
    background-color: var(--bg-main);
    box-shadow: var(--shadow-sm);
    width: 100%;
    position: relative;
}

.extraction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.btn-open-icon-only {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: transparent;
    color: var(--text-hint);
    font-size: 16px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-open-icon-only:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.extraction-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.object-container {
    position: relative;
    border: 1px solid transparent;
    border-radius: 8px;
    transition: border-color 0.2s;
}

.object-container:hover {
    border-color: var(--border-main);
}

.mock-image-container {
    width: 100%;
    border-radius: 8px;
    overflow: visible !important;
    cursor: grab;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

.mock-image-container img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 250px;
    object-fit: contain;
    background: var(--bg-canvas);
    border: 1px solid var(--border-light);
    border-radius: 8px;
}

.mock-label {
    font-size: 11px;
    padding: 6px;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-top: none;
    border-radius: 0 0 8px 8px;
    color: var(--text-secondary);
    font-weight: 500;
}

.object-toolbar {
    position: absolute;
    bottom: -15px;
    right: 0;
    background: var(--bg-main);
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateY(5px);
    transition: all 0.2s;
    z-index: 20;
}

.object-container:hover .object-toolbar {
    opacity: 1;
    transform: translateY(0);
}

.tool-icon {
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
}

.tool-icon:hover {
    color: var(--text-primary);
}

.grounding-box {
    display: none;
    background-color: var(--bg-canvas);
    border: 1px solid var(--border-light);
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.grounding-box.show {
    display: block;
}

.mock-table-wrapper {
    padding-bottom: 20px;
}

.mock-table-container {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    cursor: grab;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mini-table {
    border-collapse: collapse;
    font-size: 12px;
    width: 100%;
}

.mini-table td,
.mini-table th {
    border: 1px solid var(--border-light);
    padding: 8px 12px;
    text-align: left;
}

.mini-table th {
    background: var(--bg-canvas);
    font-weight: 600;
    color: var(--text-secondary);
}

.long-text-block {
    background-color: var(--bg-hover);
    padding: 16px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    border-left: 3px solid var(--accent-primary);
    cursor: pointer;
    line-height: 1.6;
    position: relative;
}

.input-area-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 24px;
    background: transparent;
}

.input-container {
    width: 100%;
    max-width: 800px;
    background-color: var(--bg-main);
    border-radius: 24px;
    padding: 16px 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: all 0.2s;
    border: 1px solid var(--border-light);
}

.input-container:focus-within {
    border-color: var(--border-main);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.file-preview-area {
    display: none;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: var(--bg-canvas);
    max-height: 120px;
    overflow-y: auto;
}

.file-preview-area.show {
    display: flex;
}

.file-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.file-chip i.icon-file {
    color: #E91E63;
}

.file-chip i.icon-close {
    color: var(--text-hint);
    cursor: pointer;
    margin-left: 4px;
    font-size: 12px;
}

.chat-input {
    width: 100%;
    background: transparent;
    border: none;
    resize: none;
    min-height: 56px;
    max-height: 200px;
    font-family: inherit;
    font-size: 16px;
    outline: none;
    color: var(--text-primary);
    margin-bottom: 40px;
    overflow-y: hidden;
}

.input-actions {
    position: absolute;
    bottom: 12px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.input-tools-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-plus {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-plus:hover {
    background-color: var(--border-main);
}

.template-wrapper {
    position: relative;
}

.btn-template-pill {
    height: 32px;
    padding: 0 14px;
    border-radius: 16px;
    background-color: var(--bg-secondary);
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-template-pill:hover {
    background-color: var(--border-main);
    color: var(--text-primary);
}

.btn-template-pill.has-template {
    background-color: var(--accent-light);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    font-weight: 500;
}

.btn-template-pill.has-template:hover {
    background-color: var(--accent-light);
}

.btn-send-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-send-icon:hover {
    background-color: var(--bg-secondary);
}

.btn-send-icon.active {
    background-color: var(--text-primary);
    color: white;
}

.template-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 200px;
    display: none;
    overflow: hidden;
    z-index: 100;
}

.template-dropdown.show {
    display: block;
}

.template-option {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.template-option:hover {
    background-color: var(--bg-hover);
}

.template-option.active {
    background-color: var(--accent-light);
    color: var(--accent-primary);
    font-weight: 500;
}

.template-divider {
    height: 1px;
    background-color: var(--border-light);
    margin: 4px 0;
}

.template-section-title {
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.app-canvas {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-color: var(--bg-canvas);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.app-canvas.open {
    transform: translateX(0);
}

.save-notification {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: #4CAF50;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    z-index: 1001;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.canvas-header {
    height: var(--header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-light);
}

.excel-editor-header {
    gap: 16px;
}

.excel-editor-header-left {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
}

.excel-editor-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.excel-editor-title-icon {
    color: var(--accent-primary);
}

.excel-editor-title-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.excel-editor-title {
    font-size: 15px;
    font-weight: 650;
    color: var(--text-primary);
    line-height: 1.1;
}

.excel-editor-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.1;
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-name-container {
    margin-bottom: 4px;
}

.session-name-display {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 400px;
}

.session-name-display:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.session-name-display i:first-child {
    color: var(--accent-primary, #667eea);
    font-size: 14px;
}

.session-name-display span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-name-input {
    padding: 6px 12px;
    border: 2px solid var(--accent-primary, #667eea);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-main);
    outline: none;
    min-width: 250px;
    max-width: 400px;
    transition: all 0.2s ease;
}

.session-name-input:focus {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.excel-editor-header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.excel-editor-docs-label {
    font-size: 12px;
    color: var(--text-hint);
    white-space: nowrap;
}

.excel-editor-docs-select {
    max-width: 520px;
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.excel-editor-header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.btn-template-dropdown {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-template-dropdown:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
}

.btn-approve {
    background: linear-gradient(135deg, #4caf50 0%, #43a047 100%);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
    margin-right: 8px;
}

.btn-approve:hover {
    background: linear-gradient(135deg, #43a047 0%, #388e3c 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.btn-approve i {
    font-size: 12px;
}

.btn-export {
    background: linear-gradient(135deg, #1a237e 0%, #303f9f 100%);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 8px;
}

.btn-export:hover {
    background: linear-gradient(135deg, #303f9f 0%, #3949ab 100%);
    box-shadow: 0 2px 8px rgba(26, 35, 126, 0.3);
}

.btn-export i {
    font-size: 12px;
}

@media (max-width: 900px) {
    .excel-editor-header {
        padding: 0 16px;
    }

    .excel-editor-header-center {
        display: none;
    }

    .excel-editor-subtitle {
        max-width: 240px;
    }
}

.canvas-tabs-bar {
    display: flex;
    align-items: flex-end;
    padding: 8px 24px 0 24px;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-light);
    gap: 6px;
}

.canvas-tab {
    padding: 8px 16px;
    border: 1px solid transparent;
    border-bottom: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s;
}

.canvas-tab:hover {
    background-color: var(--bg-hover);
}

.canvas-tab.active {
    background-color: var(--bg-canvas);
    border-color: var(--border-light);
    color: var(--accent-primary);
    font-weight: 600;
    margin-bottom: -1px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--bg-canvas);
}

.canvas-tab-add {
    padding: 8px 10px;
    cursor: pointer;
    color: var(--text-hint);
    font-size: 14px;
    border-radius: 6px;
    margin-bottom: 2px;
}

.canvas-tab-add:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.canvas-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.action-dropdown {
    position: relative;
}

.btn-upload-template {
    background-color: var(--bg-success-light);
    color: #217346;
    border: 1px solid #217346;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-upload-template:hover {
    background-color: var(--bg-success-light);
}

.btn-change-template {
    background-color: var(--bg-warning-light);
    color: #e65100;
    border: 1px solid #e65100;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-change-template:hover {
    background-color: var(--bg-warning-light);
}

.btn-save-session {
    background-color: var(--accent-light);
    color: #6C5CE7;
    border: 1px solid #6C5CE7;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-save-session:hover {
    background-color: var(--accent-light);
}

.btn-save-dropdown {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-save-dropdown:hover {
    background-color: var(--accent-hover);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background-color: var(--bg-main);
    min-width: 160px;
    box-shadow: var(--shadow-lg);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    z-index: 100;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 10px 16px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-item:hover {
    background-color: var(--bg-hover);
}

.dropdown-item.active {
    background-color: var(--accent-light);
    color: var(--accent-primary);
    font-weight: 500;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-light);
    margin: 4px 0;
}

.dropdown-section-title {
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-close-canvas {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 300;
}

.btn-close-canvas:hover {
    color: var(--text-primary);
}

.canvas-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.canvas-content::-webkit-scrollbar {
    display: none;
}

.template-info {
    background-color: var(--accent-light);
    border: 1px solid var(--accent-light);
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--accent-primary);
    font-size: 13px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.field-row {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
}

.field-group {
    flex: 1;
    margin-bottom: 20px;
}

.field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.field-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    background-color: var(--bg-main);
    transition: all 0.2s;
}

.field-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.field-input.mapped {
    border-color: #2ECC71;
    background-color: var(--bg-success-light);
    padding-right: 30px;
}

.field-input-wrapper {
    position: relative;
}

.check-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #2ECC71;
    display: none;
}

.field-input.mapped+.check-icon {
    display: block;
}

.confidence-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 6px;
    font-weight: 500;
}

.conf-high {
    background-color: var(--bg-info-light);
    color: #00B8D9;
}

.image-drop-zone {
    width: 100%;
    height: 180px;
    border: 2px dashed var(--border-light);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-hint);
    font-size: 13px;
    background-color: var(--bg-canvas);
    transition: all 0.2s;
}

.image-drop-zone.drag-over {
    border-color: var(--accent-primary);
    background-color: var(--accent-light);
}

.dropped-table-view {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid #2ECC71;
    border-radius: 8px;
    padding: 10px;
    overflow-x: auto;
    position: relative;
}

.dropped-table-view .mini-table th {
    background: var(--bg-info-light);
}

.canvas-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-light);
    background-color: var(--bg-main);
}

.template-control-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.custom-select-wrapper {
    position: relative;
    flex: 1;
}

.custom-select-trigger {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-select-trigger:hover {
    background-color: var(--bg-hover);
}

.custom-options {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 6px;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 101;
    display: none;
    overflow: hidden;
}

.custom-options.show {
    display: block;
}

.custom-option {
    padding: 10px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-option:hover {
    background-color: var(--bg-hover);
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-window {
    background: var(--bg-main);
    width: 500px;
    max-width: 90%;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
}

.modal-body {
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-row {
    margin-bottom: 12px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
}

.btn-modal {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    border: none;
    font-weight: 500;
}

.btn-cancel {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.btn-save {
    background: var(--accent-primary);
    color: white;
}

.builder-layout {
    display: flex;
    gap: 20px;
    height: 400px;
    border-top: 1px solid var(--border-light);
    padding-top: 20px;
    margin-top: 10px;
}

.builder-toolbox {
    width: 140px;
    border-right: 1px solid var(--border-light);
    padding-right: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.builder-tool-item {
    padding: 10px;
    background: var(--bg-hover);
    border-radius: 6px;
    font-size: 13px;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
}

.builder-tool-item:hover {
    border-color: var(--border-main);
}

.builder-canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.builder-canvas {
    flex: 1;
    background: var(--bg-canvas);
    border: 2px dashed var(--border-light);
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.builder-canvas.drag-over {
    border-color: var(--accent-primary);
    background-color: var(--accent-light);
}

.builder-field {
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    padding: 10px;
    border-radius: 6px;
    position: relative;
}

.builder-field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
    outline: none;
    border-bottom: 1px dashed transparent;
    width: fit-content;
}

.builder-field-label:focus {
    border-bottom-color: var(--accent-primary);
    color: var(--text-primary);
}

.builder-field-placeholder {
    height: 30px;
    background: var(--bg-hover);
    border-radius: 4px;
}

.builder-field-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    cursor: pointer;
    color: var(--text-hint);
    font-size: 12px;
}

.modal-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0;
}

.modal-tab {
    padding: 6px 12px;
    border-radius: 6px 6px 0 0;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
}

.modal-tab.active {
    background: var(--bg-main);
    border-color: var(--border-light);
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: -1px;
    border-bottom: 1px solid var(--bg-main);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

.loading-dots:after {
    content: ' .';
    animation: dots 1s steps(5, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: ' .';
    }

    40% {
        content: ' ..';
    }

    60% {
        content: ' ...';
    }

    80%,
    100% {
        content: '';
    }
}

/* ========== Split-View Spreadsheet Editor ========== */
.canvas-split-view {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: 100%;
    min-height: 0;
    position: relative;
}

/* Source Items Panel (Left Column) */
.source-items-panel {
    position: relative;
    width: 30%;
    min-width: 240px;
    max-width: none;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 0 0 auto;
    min-width: 240px;
    max-width: 45vw;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 0 0 auto;
}

.canvas-split-view>.syncfusion-spreadsheet-wrapper {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 0;
    margin: 0;
    border-radius: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.syncfusion-spreadsheet-host {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
    background: transparent;
}

.syncfusion-spreadsheet-scale-wrapper {
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    padding: 0;
    margin: 0;
    background: transparent;
}

#spreadsheetHost .e-spreadsheet {
    width: 100% !important;
    height: 100% !important;
    min-height: 0;
}

#spreadsheetHost .e-spreadsheet .e-main-panel,
#spreadsheetHost .e-spreadsheet .e-sheet-panel {
    height: 100% !important;
    min-height: 0;
}

/* Old zoom bar - DEPRECATED, now using bottom bar */
.syncfusion-zoom-bar {
    display: none !important;
}

/* Bottom bar responsive adjustments */
@media (max-width: 768px) {
    .syncfusion-bottom-bar {
        padding: 6px 10px;
        gap: 8px;
    }

    .bottom-bar-zoom-slider {
        width: 60px;
    }

    .bottom-bar-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

.canvas-split-view>.spreadsheet-editor-container {
    min-width: 0;
}

.e-spinner-inner {
    display: none !important;
}

.resizer {
    width: 8px;
    margin-left: 0;
    margin-right: 0;
    cursor: col-resize;
    flex: 0 0 auto;
    position: relative;
    z-index: 5;
    align-self: stretch;
    height: 100%;
    background: transparent;
    pointer-events: auto;
    touch-action: none;
}

.canvas-split-resizer::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: transparent;
}

.canvas-split-resizer:hover::before {
    background: var(--border-main);
}

body.is-resizing,
body.is-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

.source-header {
    padding: 16px 20px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--bg-main);
}

.source-items-list {
    position: relative;
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.source-item {
    background-color: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 12px;
    cursor: grab;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: all 0.2s;
    user-select: none;
}

.source-item:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.source-item:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.source-item.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary);
    background-color: var(--accent-light);
}

.source-copied-toast {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2e7d32;
    color: #fff;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    z-index: 100;
    pointer-events: none;
    animation: source-toast-fade 1.5s ease-in-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 6px;
}

@keyframes source-toast-fade {
    0% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    75% { opacity: 1; }
    100% { opacity: 0; }
}

.source-item.source-item-table {
    grid-column: 1 / -1;
}

.source-item.field .source-item-icon {
    color: #3498db;
}

.source-item.table .source-item-icon {
    color: #27ae60;
}

.source-item.image .source-item-icon {
    color: #e74c3c;
}

.source-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.source-item-content {
    flex: 1;
    min-width: 0;
    overflow: visible;
}

.source-item-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: normal;
    overflow: visible;
    word-break: break-word;
}

.source-item-preview {
    font-size: 11px;
    color: var(--text-hint);
    margin-top: 4px;
    white-space: normal;
    overflow: visible;
    word-break: break-word;
}

.source-item-thumb {
    max-width: 100%;
    max-height: 60px;
    border-radius: 4px;
    margin-top: 8px;
    object-fit: cover;
}

.source-item-drag-handle {
    color: var(--text-hint);
    font-size: 12px;
    opacity: 0.5;
}

.btn-toggle-source-panel {
    position: relative;
    flex-shrink: 0;
    width: 20px;
    min-width: 20px;
    height: 100%;
    background: linear-gradient(90deg, var(--bg-hover) 0%, var(--border-light) 100%);
    border: none;
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    z-index: 10;
    transition: all 0.2s;
}

.btn-toggle-source-panel:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
    width: 24px;
    min-width: 24px;
}

.btn-toggle-source-panel.collapsed {
    background: var(--accent-primary);
    color: #fff;
    border-radius: 0 4px 4px 0;
    border-left: none;
    cursor: pointer;
}

.btn-toggle-source-panel.collapsed:hover {
    background: var(--accent-hover);
    color: #fff;
    width: 28px;
    min-width: 28px;
}

.btn-toggle-source-panel i {
    font-size: 12px;
    transition: transform 0.2s;
}

.btn-toggle-source-panel:hover i {
    transform: scale(1.2);
}

/* Template Configuration takes full width when source panel is collapsed */
.canvas-split-view > .template-configuration-container {
    flex: 1;
    min-width: 0;
    width: 100%;
}

.source-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-hint);
    text-align: center;
    padding: 20px;
}

/* Spreadsheet Editor (Right Column) */
.spreadsheet-editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background-color: transparent;
    padding: 0;
    margin: 0;
    border-radius: 0;
}

.spreadsheet-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-light);
    gap: 16px;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    border: none;
    background-color: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.toolbar-btn.primary {
    width: auto;
    padding: 0 16px;
    background-color: var(--accent-primary);
    color: white;
    font-size: 13px;
    font-weight: 500;
    gap: 8px;
}

.toolbar-btn.primary:hover {
    background-color: var(--accent-hover);
}

.toolbar-info {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.spreadsheet-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(108, 92, 231, 0.1);
    border: 3px dashed var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.drop-overlay.visible {
    opacity: 1;
}

.drop-overlay-content {
    background-color: var(--bg-main);
    padding: 20px 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--accent-primary);
    font-weight: 600;
}

.drop-overlay-content i {
    font-size: 32px;
}

/* Mappings List */
.mappings-panel {
    width: 240px;
    min-width: 240px;
    background-color: var(--bg-main);
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mappings-header {
    padding: 16px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mappings-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.mapping-item {
    padding: 10px 12px;
    background-color: var(--bg-hover);
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.mapping-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.mapping-item-type {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    color: var(--accent-primary);
}

.mapping-item-cell {
    color: var(--text-hint);
    font-family: monospace;
}

.mapping-item-value {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Spreadsheet Placeholder */
.spreadsheet-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    text-align: center;
    padding: 40px;
}

/* Manual Mapping Grid */
.mapping-grid-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: var(--bg-canvas);
}

.mapping-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    max-width: 800px;
    margin: 0 auto;
}

.mapping-field {
    background-color: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 14px;
    transition: all 0.2s;
}

.mapping-field.required .mapping-field-label::after {
    content: " *";
    color: #e74c3c;
}

.mapping-field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.mapping-field-value {
    min-height: 44px;
    padding: 10px 12px;
    border: 2px dashed var(--border-light);
    border-radius: 8px;
    background-color: var(--bg-canvas);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
    font-size: 14px;
}

.mapping-field-value.drag-over {
    border-color: var(--accent-primary);
    background-color: var(--accent-light);
}

.mapping-field-value.mapped {
    border-style: solid;
    border-color: #27ae60;
    background-color: var(--bg-success-light);
}

.mapping-field-value .placeholder-text {
    color: var(--text-hint);
    font-style: italic;
}

.mapping-field-value .mapped-value {
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mapping-field-cell {
    font-size: 11px;
    color: var(--text-hint);
    margin-top: 6px;
    font-family: monospace;
}

.btn-clear-mapping {
    width: 24px;
    height: 24px;
    border: none;
    background-color: transparent;
    color: var(--text-hint);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 8px;
}

.btn-clear-mapping:hover {
    background-color: var(--bg-danger-light);
    color: #e74c3c;
}

/* Mapped Tables Section */
.mapped-tables-section,
.mapped-images-section {
    margin-top: 24px;
    padding: 16px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.mapped-tables-section h4,
.mapped-images-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mapped-table-item,
.mapped-image-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background-color: var(--bg-hover);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.mapped-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
}

/* ============================================
   EXCEL SPREADSHEET STYLES
   ============================================ */

.excel-spreadsheet-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--bg-hover);
    overflow: hidden;
}

.excel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(180deg, var(--bg-canvas) 0%, var(--border-light) 100%);
    border-bottom: 1px solid var(--border-main);
}

.excel-tabs {
    display: flex;
    gap: 2px;
}

.excel-tab {
    padding: 6px 16px;
    border: 1px solid var(--border-main);
    border-bottom: none;
    background: var(--border-light);
    border-radius: 4px 4px 0 0;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-primary);
}

.excel-tab.active {
    background: var(--bg-main);
    border-bottom: 1px solid var(--bg-main);
    margin-bottom: -1px;
    font-weight: 600;
}

.excel-tab:hover:not(.active) {
    background: var(--bg-hover);
}

.btn-export-excel {
    padding: 8px 16px;
    background: #217346;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-export-excel:hover {
    background: #1a5c38;
}

.excel-grid-wrapper {
    flex: 1;
    overflow: auto;
    background: var(--bg-main);
    position: relative;
}

.excel-grid {
    border-collapse: collapse;
    font-size: 12px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-width: 100%;
}

.excel-header-row {
    position: sticky;
    top: 0;
    z-index: 10;
}

.excel-col-header {
    background: linear-gradient(180deg, var(--bg-canvas) 0%, var(--border-light) 100%);
    border: 1px solid var(--border-main);
    padding: 4px 8px;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 80px;
    position: sticky;
    top: 0;
}

.excel-row-header {
    background: linear-gradient(90deg, var(--bg-canvas) 0%, var(--border-light) 100%);
    border: 1px solid var(--border-main);
    padding: 4px 8px;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 40px;
    position: sticky;
    left: 0;
    z-index: 5;
}

.excel-cell {
    border: 1px solid var(--border-main);
    padding: 4px 6px;
    min-width: 80px;
    height: 24px;
    vertical-align: middle;
    position: relative;
    transition: background-color 0.15s;
}

.excel-image-overlay {
    z-index: 200000;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    background: rgba(255, 255, 255, 0);
    /* Transparent background to see image */
    cursor: grab;
    pointer-events: none;
    /* Let clicks pass through to image for native drag */
}

.excel-image-overlay.selected {
    outline: 2px solid #6C5CE7;
    outline-offset: 2px;
}

.excel-image-viewport {
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 6px;
    position: relative;
    background: transparent;
}

.excel-image-viewport img {
    display: none;
    /* Don't show our duplicate image */
}

.excel-image-resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-main);
    border: 2px solid #6C5CE7;
    z-index: 200010;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
    /* Re-enable pointer events for handles */
}

.excel-image-resize-handle-nw {
    left: 0px;
    top: 0px;
    cursor: nwse-resize;
    transform: translate(-50%, -50%);
}

.excel-image-resize-handle-ne {
    right: 0px;
    top: 0px;
    cursor: nesw-resize;
    transform: translate(50%, -50%);
}

.excel-image-resize-handle-sw {
    left: 0px;
    bottom: 0px;
    cursor: nesw-resize;
    transform: translate(-50%, 50%);
}

.excel-image-resize-handle-se {
    right: 0px;
    bottom: 0px;
    cursor: nwse-resize;
    transform: translate(50%, 50%);
}

/* Hide native Syncfusion handles */
.e-spreadsheet .e-ss-overlay .e-resize-handle,
.e-spreadsheet .e-ss-overlay .e-ss-resize-handle,
.e-spreadsheet .e-ss-overlay .e-handler,
.e-spreadsheet .e-ss-overlay [class*="resize"],
.e-spreadsheet .e-ss-overlay [class*="handler"],
.e-spreadsheet .e-drawing .e-resize-handle,
.e-spreadsheet .e-drawing .e-ss-resize-handle,
.e-spreadsheet [class*="e-resize-handle"],
.e-spreadsheet [class*="e-ss-resize-handle"],
.e-spreadsheet [class*="e-handler"],
.e-ss-overlay-t,
.e-ss-overlay-r,
.e-ss-overlay-b,
.e-ss-overlay-l,
.e-ss-resizer,
.e-resizer-handle {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
}

.sf-corner-handle {
    display: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--bg-main);
    border: 3px solid #6C5CE7;
    border-radius: 50%;
    z-index: 2147483647 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform 0.1s ease;
}

/* Show our corner handles when overlay is active */
.e-ss-overlay-active > .sf-corner-handle {
    display: block !important;
}

/* Rotation handle - hidden by default */
.sf-rotation-handle {
    display: none !important;
}

/* Show rotation handle when overlay is active */
.e-ss-overlay-active > .sf-rotation-handle {
    display: flex !important;
}

.sf-corner-handle:hover {
    transform: scale(1.2);
    border-color: #5B4CD6;
}

.sf-rotation-handle:hover {
    transform: translateX(-50%) scale(1.15);
    border-color: #5B4CD6;
    background: var(--accent-light);
}

.sf-corner-handle:active {
    transform: scale(1.1);
    background: #6C5CE7;
    border-color: white;
}

/* Ensure only our corner handles are visible */
.excel-image-overlay.selected .excel-image-resize-handle {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Zoom controls visibility */
.excel-image-zoom-controls {
    display: none;
}

.excel-image-zoom-controls.visible {
    display: flex;
}

.excel-image-toolbar {
    position: absolute;
    top: -40px;
    right: 0;
    display: flex;
    gap: 4px;
    background: var(--bg-overlay);
    padding: 6px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 80;
}

.btn-image-action {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.15s;
    position: relative;
}

.btn-image-action.btn-zoom {
    background: #3498db;
    color: white;
}

.btn-image-action.btn-zoom:hover {
    background: #2980b9;
}

.btn-image-action.btn-crop {
    background: #e74c3c;
    color: white;
}

.btn-image-action.btn-crop:hover {
    background: #c0392b;
}

.btn-image-action.btn-crop.active {
    background: #27ae60;
    color: white;
}

.btn-image-action.btn-check {
    background: #27ae60;
    color: white;
}

.btn-image-action.btn-check:hover {
    background: #229954;
}

.btn-image-action.btn-check:disabled {
    background: #bdc3c7;
    color: #7f8c8d;
    cursor: not-allowed;
}

.btn-image-action.btn-done {
    background: #00b894;
    color: white;
}

.btn-image-action.btn-done:hover {
    background: #00a381;
}

/* Crop overlay styles */
.excel-image-crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 75;
    pointer-events: none;
}

.excel-image-crop-area {
    position: absolute;
    border: 2px dashed #fff;
    background: rgba(255, 255, 255, 0.1);
    cursor: move;
    z-index: 76;
}

.excel-image-crop-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--bg-main);
    border: 1px solid #3498db;
    border-radius: 50%;
    z-index: 77;
}

.excel-image-crop-handle.nw {
    top: -4px;
    left: -4px;
    cursor: nwse-resize;
}

.excel-image-crop-handle.ne {
    top: -4px;
    right: -4px;
    cursor: nesw-resize;
}

.excel-image-crop-handle.sw {
    bottom: -4px;
    left: -4px;
    cursor: nesw-resize;
}

.excel-image-crop-handle.se {
    bottom: -4px;
    right: -4px;
    cursor: nwse-resize;
}

/* Zoom controls */
.excel-image-zoom-controls {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 8px;
    background: var(--bg-overlay);
    padding: 6px 10px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 80;
}

.excel-image-zoom-controls.visible {
    display: flex;
    align-items: center;
}

.excel-image-zoom-slider {
    width: 120px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-light);
    border-radius: 2px;
    outline: none;
}

.excel-image-zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
}

.excel-image-zoom-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.excel-image-zoom-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 40px;
    text-align: center;
}

.btn-image-action.btn-delete {
    background: #d63031;
    color: white;
}

.btn-image-action.btn-delete:hover {
    background: #c0292a;
}

.btn-image-action.btn-crop {
    background: #6C5CE7;
    color: white;
}

.btn-image-action.btn-crop:hover {
    background: #5a4bd1;
}

.excel-image-overlay.cropping {
    outline: 3px solid #00b894;
    outline-offset: 0;
}

.excel-image-overlay.cropping .excel-image-viewport {
    cursor: move;
    overflow: hidden;
}

.excel-image-overlay.cropping .excel-image-viewport img {
    pointer-events: auto;
    cursor: move;
}

.excel-cell:hover {
    background-color: var(--bg-hover) !important;
}

.excel-cell.header-cell {
    font-weight: 600;
    font-size: 11px;
}

.excel-cell.drag-over {
    background-color: var(--bg-success-light) !important;
    border: 2px dashed #28a745 !important;
}

.excel-cell.mapped-cell {
    background-color: var(--bg-warning-light) !important;
    border: 1px solid #ffc107;
}

.cell-mapped-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.cell-mapped-content .mapped-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-warning);
    font-weight: 500;
    font-size: 11px;
}

.btn-clear-cell {
    width: 16px;
    height: 16px;
    border: none;
    background: #dc3545;
    color: white;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    opacity: 0.7;
    flex-shrink: 0;
}

.btn-clear-cell:hover {
    opacity: 1;
}

/* ============================================
   EXPANDED SOURCE ITEMS PANEL
   ============================================ */

.source-items-panel {
    width: 30%;
    min-width: 240px;
    max-width: none;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.source-items-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-canvas);
}

.source-items-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.source-items-header p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

.source-items-tabs {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.source-items-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border-light);
    background: var(--bg-main);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

.source-items-tab:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.source-items-tab.active {
    background: var(--accent-light);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.source-items-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
}

.source-items-tab.active .source-items-tab-count {
    background: rgba(108, 92, 231, 0.18);
    color: var(--accent-primary);
}

.source-items-search {
    position: relative;
    margin-top: 10px;
}

.source-items-search input {
    width: 100%;
    padding: 9px 34px 9px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background: var(--bg-main);
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
}

.source-items-search input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.source-items-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-hint);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
}

.source-items-search-clear:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.source-items-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.source-items-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-content: start;
    align-items: start;
    padding: 20px;
}

.source-page-header {
    width: 100%;
    padding: 4px 20px;
    background: rgba(108, 92, 231, 0.05);
    border-top: none;
    border-bottom: 1px solid var(--border-light);
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 0;
    z-index: 5;
}

.source-item {
    padding: 12px;
    background: var(--bg-canvas);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    cursor: grab;
    transition: all 0.2s;
    min-width: 0;
    min-height: auto;
    height: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: visible;
}

.source-item:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.source-item:active {
    cursor: grabbing;
}

.source-item-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.source-item-header-row .source-item-type {
    margin-bottom: 0;
}

.source-item-type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.source-item-type.table {
    background: var(--bg-success-light);
    color: #2e7d32;
}

.source-item-type.image {
    background: var(--bg-danger-light);
    color: #c2185b;
}

.source-item-label {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: anywhere;
    flex: 1;
    min-width: 0;
    display: block;
    overflow: visible;
    text-overflow: clip;
}

.source-item-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

.source-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-2px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    background-color: var(--bg-overlay);
    padding: 4px;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-light);
}

.source-item:hover .source-item-actions,
.source-item:focus-within .source-item-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.source-item-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-main);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.source-item-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-main);
}

.source-item-action-btn.selected {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.source-item-action-btn.selected:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.source-item-action-btn:active {
    transform: scale(0.98);
}

.source-item-preview {
    margin-top: 8px;
    padding: 8px;
    background: var(--bg-main);
    border-radius: 4px;
    font-size: 11px;
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
}

.source-item-preview.table-preview {
    overflow-x: auto;
    overflow-y: auto;
    width: 100%;
    max-height: 350px;
    min-height: 200px;
    margin-top: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-main);
    display: block;
}

.source-item-preview.image-preview {
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: 180px;
    min-height: 150px;
    overflow: hidden;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    margin-top: 8px;
    border-radius: 4px;
    width: auto;
    margin-left: auto;
    margin-right: auto;
}

.source-item-preview img {
    max-width: 100%;
    max-height: 170px;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}

.source-item-preview .mini-table {
    font-size: 10px;
    border-collapse: collapse;
    table-layout: auto;
    min-width: max-content;
}

.source-item-preview .mini-table th,
.source-item-preview .mini-table td {
    border: 1px solid var(--border-light);
    padding: 6px 8px;
    text-align: left;
    word-break: break-word;
    white-space: normal;
    overflow-wrap: anywhere;
}

.source-item-preview .mini-table th {
    background: var(--bg-sidebar);
    font-weight: 600;
}

.source-item.source-item-table {
    grid-column: 1 / -1;
}

.source-item.source-item-image {
    width: fit-content;
}

/* Button to open canvas */
.btn-open-canvas {
    padding: 14px 28px;
    background: linear-gradient(135deg, #6C5CE7 0%, #a29bfe 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.btn-open-canvas:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.btn-open-canvas i {
    font-size: 16px;
}




.excel-cell.selected {
    border: 2px solid var(--accent-primary) !important;
    position: relative;
    z-index: 20;
}

.excel-cell.range-selected {
    background-color: rgba(108, 92, 231, 0.1) !important;
    border: 1px double var(--accent-primary);
}

.formatting-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-main);
    flex-wrap: wrap;
}

.format-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-right: 8px;
    margin-right: 8px;
    border-right: 1px solid var(--border-light);
}

.format-group:last-child {
    border-right: none;
}

.format-btn {
    width: 28px;
    height: 28px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.format-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-main);
}

.format-btn.active {
    background-color: var(--accent-light);
    color: var(--accent-primary);
    border-color: var(--accent-light);
}

.format-input {
    height: 28px;
    border: 1px solid var(--border-main);
    border-radius: 4px;
    padding: 0 6px;
    font-size: 13px;
}

.format-color-picker {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

.cell-editor-input {
    flex: 1;
    min-width: 200px;
}

.inline-cell-editor {
    width: 100%;
    height: 100%;
    border: none;
    outline: 2px solid var(--accent-primary);
    padding: 0 4px;
    font-family: inherit;
    font-size: inherit;
    background-color: var(--bg-main);
    color: inherit;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 50;
}

/* Anchor loading overlay to the bottom of .chat-container (flex column) */
#loadingMsg {
    margin-top: auto;
}

/* Stepper Loading Indicator */
.loading-stepper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    margin-top: 12px;
    padding: 4px 0;
}

.stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 72px;
}

.stepper-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.stepper-icon.pending {
    border: 2px solid var(--border-light);
    color: var(--text-hint);
    background: var(--bg-main);
}

.stepper-icon.active {
    border: 2px solid var(--accent-primary);
    color: var(--accent-primary);
    background: var(--bg-main);
}

.stepper-icon.done {
    border: 2px solid var(--accent-primary);
    background-color: var(--accent-primary);
    color: #fff;
}

.stepper-label {
    font-size: 11px;
    margin-top: 6px;
    text-align: center;
    color: var(--text-hint);
    letter-spacing: 0.2px;
    transition: color 0.3s ease, font-weight 0.3s ease;
    white-space: nowrap;
}

.stepper-label.active {
    color: var(--text-primary);
    font-weight: 600;
}

.stepper-label.done {
    color: var(--accent-primary);
    font-weight: 500;
}

.stepper-connector {
    width: 32px;
    height: 2px;
    margin-top: 14px; /* vertically centers with 28px icon */
    background-color: var(--border-light);
    flex-shrink: 0;
    transition: background-color 0.3s ease;
}

.stepper-connector.done {
    background-color: var(--accent-primary);
}

.stepper-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: stepper-spin 0.6s linear infinite;
}

@keyframes stepper-spin {
    to { transform: rotate(360deg); }
}

/* Language Selector Dropdown */
.language-selector-wrapper {
    position: relative;
    margin-right: 12px;
}

.language-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: var(--bg-main);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 80px;
    justify-content: space-between;
}

.language-btn:hover {
    background-color: var(--bg-hover);
}

.language-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.language-flag {
    width: 20px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 2px;
    box-shadow: 0 0 1px rgba(0, 0, 0, 0.2);
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    width: 140px;
    display: none;
    overflow: hidden;
    z-index: 100;
}

.language-dropdown.show {
    display: block;
}

.language-option {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.language-option:hover {
    background-color: var(--bg-hover);
}

.language-option.active {
    background-color: var(--accent-light);
    color: var(--accent-primary);
    font-weight: 600;
}

/* Excel Image Overlay & Manipulation */
.excel-image-overlay {
    position: absolute;
    border: 2px solid #6C5CE7;
    background: transparent;
    pointer-events: none;
    z-index: 2147483647 !important;
    box-sizing: border-box;
    display: none;
}

/* Hide Syncfusion Native Text/Image Selection/Resize Handles */
.e-spreadsheet .e-ss-overlay .e-ss-resize-handler,
.e-spreadsheet .e-ss-overlay .e-ss-rotate-handler,
.e-spreadsheet .e-drawing .e-ss-resize-handler,
.e-spreadsheet .e-drawing-content .e-ss-resize-handler,
.e-spreadsheet .e-acc-resize-handler {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Hide the native border/outline but KEEP the content visible */
.e-spreadsheet .e-ss-overlay.e-ss-overlay-active,
.e-spreadsheet .e-drawing.e-ss-drawing-active {
    border-color: transparent !important;
    outline: none !important;
    background-color: transparent !important;
    /* Ensure background doesn't obscure if any */
}

/* Hide fallback resize handles if they aren't caught above */
.e-ss-resize-handler {
    display: none !important;
    pointer-events: none !important;
}

.excel-image-overlay * {
    pointer-events: auto;
}

/* Resize Handles */
.excel-image-resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: var(--bg-main);
    border: 2px solid #6C5CE7;
    border-radius: 50%;
    z-index: 2147483647 !important;
    transform: translate(-50%, -50%);
    cursor: nwse-resize;
}

.excel-image-resize-handle-nw {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

.excel-image-resize-handle-ne {
    top: 0;
    right: 0;
    transform: translate(50%, -50%);
    cursor: nesw-resize;
}

.excel-image-resize-handle-sw {
    bottom: 0;
    left: 0;
    transform: translate(-50%, 50%);
    cursor: nesw-resize;
}

.excel-image-resize-handle-se {
    bottom: 0;
    right: 0;
    transform: translate(50%, 50%);
    cursor: nwse-resize;
}

.excel-image-resize-handle-n {
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
    cursor: ns-resize;
}

.excel-image-resize-handle-s {
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 50%);
    cursor: ns-resize;
}

.excel-image-resize-handle-w {
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
    cursor: ew-resize;
}

.excel-image-resize-handle-e {
    top: 50%;
    right: 0;
    transform: translate(50%, -50%);
    cursor: ew-resize;
}

/* Rotate Handle */
.excel-image-rotate-handle {
    position: absolute;
    top: -40px;
    left: 50%;
    width: 24px;
    height: 24px;
    background-color: var(--bg-main);
    border: 1px solid #6C5CE7;
    border-radius: 50%;
    transform: translateX(-50%);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483647 !important;
    color: #6C5CE7;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.excel-image-rotate-handle:active {
    cursor: grabbing;
    background-color: #6C5CE7;
    color: #fff;
}

.excel-image-rotate-handle::after {
    content: '';
    position: absolute;
    top: 22px;
    left: 50%;
    width: 1px;
    height: 18px;
    background-color: #6C5CE7;
    transform: translateX(-50%);
    z-index: -1;
}

/* Toolbar */
.excel-image-toolbar {
    position: absolute;
    top: -50px;
    right: 0;
    display: flex;
    gap: 4px;
    background: var(--bg-main);
    padding: 4px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 2147483647 !important;
}

.btn-image-action {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-light);
    background: var(--bg-main);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.2s;
}

.btn-image-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-image-action.btn-delete:hover {
    background: var(--bg-danger-light);
    color: #d32f2f;
    border-color: #ffcdd2;
}

@media (max-width: 768px) {
    .responsive-two-column {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        margin-bottom: 10px !important;
    }

    .chat-header {
        padding: 0 12px;
    }

    .chat-container {
        padding: 12px 0;
        align-items: stretch;
        gap: 12px;
        height: 100dvh;
    }

    .welcome-screen {
        justify-content: flex-start;
        height: auto;
        padding: 28px 14px 10px;
    }

    .brand-logo {
        width: 42px;
        height: 42px;
        border-radius: 10px;
        font-size: 20px;
        margin-bottom: 14px;
    }

    .input-area-wrapper {
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .sidebar-footer {
        position: sticky;
        bottom: 0;
        background-color: var(--bg-sidebar);
    }

    .input-container {
        max-width: none;
        border-radius: 16px;
        padding: 12px;
    }

    .pdf-dropzone {
        width: 100%;
        border-radius: 12px;
        padding: 14px;
    }

    .message-wrapper {
        padding: 0 12px;
    }
}

/* Added for Download Button in Canvas Header */
.btn-canvas-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 8px;
    height: 32px;
}

.btn-canvas-action:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-main);
    color: var(--text-primary);
}

.btn-canvas-action i {
    color: var(--accent-primary);
    font-size: 14px;
}

/* ========== Request Approval Button & Modal ========== */

.btn-request-approval {
    background: linear-gradient(135deg, #6C5CE7 0%, #5B4BD6 100%);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
    margin-right: 8px;
}

.btn-request-approval:hover {
    background: linear-gradient(135deg, #5B4BD6 0%, #4a3dc5 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.btn-request-approval i {
    font-size: 12px;
}

.btn-save-session {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
    margin-right: 8px;
}

.btn-save-session:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-save-session i {
    font-size: 12px;
}

.save-status-message {
    display: inline-flex;
    align-items: center;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Approval Modal */
.approval-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999 !important;
}

.approval-modal-content {
    background-color: var(--bg-main);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 520px;
    max-width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.approval-modal-content .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.modal-header h3 i {
    color: var(--accent-primary);
}

.btn-close-modal {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.btn-close-modal:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background-color: var(--bg-canvas);
}

/* Form Styles for Modal */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--bg-main);
    transition: all 0.15s ease;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Template List in Modal */
.template-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
}

.template-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.template-item:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-main);
}

.template-item.selected {
    background-color: var(--accent-light);
    border-color: var(--accent-primary);
}

.template-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    font-size: 18px;
    flex-shrink: 0;
}

.template-item.selected .template-icon {
    background-color: var(--accent-primary);
    color: #fff;
}

.template-info {
    flex: 1;
    min-width: 0;
}

.template-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.template-description {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-check {
    color: var(--accent-primary);
    font-size: 16px;
}

/* No Templates Message */
.no-templates-message {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-secondary);
}

.no-templates-message i {
    font-size: 48px;
    color: var(--text-hint);
    margin-bottom: 16px;
    display: block;
}

.no-templates-message p {
    font-size: 14px;
    margin-bottom: 16px;
}

/* Buttons for Modal */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-hover) 100%);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-secondary:hover {
    background-color: var(--border-main);
    border-color: var(--border-main);
}

.btn-create-template {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-hover) 100%);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.btn-create-template:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.template-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.btn-create-template-small {
    background: none;
    color: var(--accent-primary);
    border: 1px dashed var(--accent-primary);
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
    width: 100%;
    justify-content: center;
}

.btn-create-template-small:hover {
    background-color: var(--accent-light);
}

/* Create Template Form */
.create-template-form {
    margin-top: 20px;
}

.form-divider {
    height: 1px;
    background-color: var(--border-light);
    margin-bottom: 20px;
}

.create-template-form h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
}

/* ========== Sidebar Responsive ========== */
@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 85vw;
        max-width: 320px;
        z-index: 10000;
        box-shadow: var(--shadow-lg);
    }

    .app-sidebar.collapsed {
        margin-left: -85vw;
    }

    .sidebar-header {
        padding: 16px;
    }

    .history-list {
        padding: 6px;
    }

    .history-item-main {
        padding: 8px;
        gap: 8px;
    }

    .history-group-title {
        margin: 14px 8px 6px;
    }

    .history-menu {
        position: fixed;
        right: auto;
        left: 50%;
        top: auto;
        bottom: 20%;
        transform: translateX(-50%);
        min-width: 200px;
    }

    .sidebar-footer {
        padding: 14px;
        padding-bottom: calc(14px + env(safe-area-inset-bottom));
    }
}

/* ═══════════════════════════════════════════════════════════════════
   AI Q&A Bubble Button
   ═══════════════════════════════════════════════════════════════════ */
.ai-qna-bubble {
    position: absolute;
    bottom: 16px;
    right: 16px;
    height: 36px;
    padding: 0 14px;
    border-radius: 18px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    z-index: 10;
    transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.ai-qna-bubble:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.ai-qna-bubble:active {
    background: #f3f4f6;
}

/* ═══════════════════════════════════════════════════════════════════
   Document Q&A Modal
   ═══════════════════════════════════════════════════════════════════ */
.qna-modal-window {
    width: 600px;
    max-width: 95%;
    height: 70vh;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.qna-modal-window .modal-header {
    padding: 16px 20px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}

.qna-chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qna-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-hint, #9ca3af);
    text-align: center;
    font-size: 13px;
}

.qna-message {
    display: flex;
}

.qna-message-user {
    justify-content: flex-end;
}

.qna-message-assistant {
    justify-content: flex-start;
}

.qna-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.qna-bubble-user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.qna-bubble-assistant {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-primary, #1f2937);
    border-bottom-left-radius: 4px;
}

.qna-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.qna-typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-hint, #9ca3af);
    border-radius: 50%;
    animation: qna-typing 1.4s ease-in-out infinite;
}

.qna-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.qna-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes qna-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.qna-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}

.qna-input {
    flex: 1;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    background: var(--bg-main, #fff);
    color: var(--text-primary, #1f2937);
    outline: none;
    transition: border-color 0.2s;
}

.qna-input:focus {
    border-color: #667eea;
}

.qna-input:disabled {
    opacity: 0.6;
}

.qna-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.qna-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.qna-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

