:root {
    /* Light Theme - Qlik Colors */
    --primary-100: #e6f7ef;
    --primary-200: #b3e0cc;
    --primary-300: #009845;
    --accent-100: #00c96b;
    --accent-200: #007a38;
    --text-100: #333333;
    --text-200: #5c5c5c;
    --bg-100: #FFFFFF;
    --bg-200: #f5f5f5;
    --bg-300: #cccccc;
    
    --primary: var(--primary-300);
    --primary-hover: #007a38;
    --accent: var(--accent-200);
    --bg-main: var(--bg-200);
    --bg-card: var(--bg-100);
    --bg-sidebar: var(--bg-100);
    --bg-input: var(--bg-200);
    --text-main: var(--text-100);
    --text-muted: var(--text-200);
    --text-on-primary: #ffffff;
    --border: var(--bg-300);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 16px;
    --radius-lg: 24px;
    --font-mono: 'Fira Code', 'Courier New', monospace;
}

[data-theme="dark"] {
    /* Dark Theme - Qlik Colors */
    --primary-100: #0d2e1a;
    --primary-200: #1a4d2e;
    --primary-300: #4ade80;
    --accent-100: #22c55e;
    --accent-200: #86efac;
    --text-100: #ffffff;
    --text-200: #e0e0e0;
    --bg-100: #1a1a1a;
    --bg-200: #262626;
    --bg-300: #404040;
    
    --primary: var(--primary-300);
    --primary-hover: var(--primary-200);
    --accent: var(--accent-200);
    --bg-main: var(--bg-200);
    --bg-card: var(--bg-100);
    --bg-sidebar: var(--bg-100);
    --bg-input: var(--bg-200);
    --text-main: var(--text-100);
    --text-muted: var(--text-200);
    --text-on-primary: #1a1a1a;
    --border: var(--bg-300);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* Sidebar */
.sidebar {
    width: 300px;
    height: 100vh;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: background-color 0.3s, border-color 0.3s;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.logo svg {
    background: linear-gradient(135deg, var(--accent-200), var(--primary-100));
    padding: 6px;
    border-radius: 10px;
    color: white;
}

.logo-text {
    color: var(--primary-300);
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section {
    margin-bottom: 4px;
}

.sidebar .section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 8px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: pointer;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 24px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
    transition: width 0.2s ease;
    opacity: 0;
}

.nav-item:hover {
    background-color: var(--primary-100);
    color: var(--text-main);
}

.nav-item:hover::before {
    opacity: 0.3;
    width: 3px;
}

.nav-item.active {
    background: var(--primary-300);
    color: var(--bg-100);
    box-shadow: 0 2px 8px rgba(59, 60, 61, 0.25);
}

.nav-item.active::before {
    opacity: 0;
    width: 0;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.nav-item.active svg {
    opacity: 1;
}

.nav-item .badge {
    margin-left: auto;
    background: #009845;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
}

.sidebar-inputs {
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-inputs .input-group {
    background: var(--bg-main);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.sidebar-inputs .input-group:hover {
    border-color: var(--border);
}

.sidebar-inputs .input-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-inputs .input-group label::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent-200);
    border-radius: 2px;
}

.sidebar-inputs textarea {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    resize: vertical;
    min-height: 40px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sidebar-inputs textarea:focus {
    outline: none;
    border-color: var(--primary-300);
    box-shadow: 0 0 0 3px rgba(0, 102, 140, 0.1);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: linear-gradient(to top, var(--bg-sidebar) 0%, transparent 100%);
}

.btn-lg {
    padding: 14px 20px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(0, 102, 140, 0.3);
    transition: all 0.3s ease;
}

.btn-lg:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 102, 140, 0.4);
}

/* Main Content */
.main-content {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.search-wrapper {
    position: relative;
    width: 400px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

#searchInput {
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 16px 10px 40px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

#searchInput:focus {
    border-color: var(--primary-300);
}

.search-shortcut {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-main);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.2s;
}

#searchInput:focus + .search-shortcut {
    opacity: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 16px;
    border-left: 1px solid var(--border);
}

.user-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.user-link {
    font-size: 0.75rem;
    color: var(--primary-300);
    text-decoration: none;
    font-weight: 700;
    transition: all 0.2s;
}

.user-link:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

.avatar-container {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background-color: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border);
    transition: all 0.2s;
    cursor: pointer;
}

.avatar-container:hover {
    background-color: var(--border);
    transform: translateY(-2px);
}

/* Page Header */
.page-header {
    width: 100%;
    padding: 24px 32px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-group h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.title-group p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.header-context-actions {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 32px 16px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    height: 38px;
    width: auto !important;
}

.page-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Content Area */
.content-scrollable {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    padding: 0 32px 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Cards & Grid */
.model-view-container {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.table-card {
    width: 300px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.table-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-300);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: var(--primary-100);
    border-bottom: 1px solid var(--border);
}

.table-info {
    flex: 1;
    min-width: 0;
    margin-right: 12px;
}

.table-title {
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
}

.table-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.copy-table-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.copy-table-btn:hover {
    background-color: var(--bg-main);
    color: var(--primary-300);
    border-color: var(--primary-300);
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.table-fields {
    max-height: 250px;
    overflow-y: auto;
    padding: 0 20px 20px;
}

.field-item {
    padding: 8px 0;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-item:last-child {
    border-bottom: none;
}

.field-item.is-key {
    color: var(--primary-300);
    font-weight: 600;
}

/* Inputs & Toggles */
.input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

textarea {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    resize: vertical;
    min-height: 40px;
}

.btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: transparent;
    color: var(--primary-300);
    border: 1px solid var(--accent-200);
    box-shadow: none;
}

.btn-primary:hover {
    background-color: var(--primary-100);
    box-shadow: none;
    border-color: var(--primary-300);
}

.btn-secondary {
    background-color: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.w-full { width: 100%; }

.sidebar-inputs .toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-main);
    border-radius: 10px;
    margin-top: 4px;
}

.sidebar-inputs .toggle-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-inputs .toggle-label::before {
    content: '⚡';
    font-size: 0.75rem;
}

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

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

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

.slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* File Input Wrapper */
.file-input-wrapper {
    position: relative;
    overflow: hidden;
}

.file-input-wrapper .btn-secondary {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    color: var(--text-muted);
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.file-input-wrapper .btn-secondary:hover {
    border-color: var(--primary-300);
    color: var(--primary-300);
    background: rgba(0, 102, 140, 0.05);
}

.file-input-wrapper .btn-secondary svg {
    width: 20px;
    height: 20px;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    left: 0; top: 0; opacity: 0;
    width: 100%; height: 100%;
    cursor: pointer;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
}

.sidebar-footer .promo-card {
    background: var(--primary-100);
    padding: 16px;
    border-radius: 14px;
    text-align: center;
}

.sidebar-footer .promo-card p {
    color: var(--text-200);
    font-size: 0.85rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.sidebar-footer .btn-primary {
    width: 100%;
    background: var(--primary-300);
    color: #ffffff;
    font-weight: 700;
    padding: 14px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 152, 69, 0.3);
    font-size: 1rem;
}

.sidebar-footer .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 152, 69, 0.4);
    background: var(--primary-300);
}

.sidebar-footer .btn-primary svg {
    width: 20px;
    height: 20px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Customizations for different views */
.visualizer-container, .used-fields-view {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

/* JSON Tree Styles */
.json-node {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
}

.json-line {
    display: flex;
    align-items: center;
    padding: 1px 0;
    white-space: nowrap;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.json-line:hover {
    background-color: var(--primary-100);
}

.json-collapsible {
    margin-left: 1.5rem;
    padding-left: 0.5rem;
    border-left: 1px dashed var(--border);
}

.json-collapsible.collapsed {
    display: none;
}

.json-toggle {
    cursor: pointer;
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s;
    user-select: none;
}

.json-toggle.collapsed {
    transform: rotate(-90deg);
}

.json-key {
    color: var(--primary-300);
    font-weight: 500;
    margin-right: 4px;
}

.json-value-string { color: var(--accent); }
.json-value-number { color: #f59e0b; }
.json-value-boolean { color: #8b5cf6; }
.json-value-null { color: #94a3b8; font-style: italic; }

.json-label {
    margin-left: 8px;
    font-size: 0.7rem;
    background: var(--primary-100);
    color: var(--primary-300);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.json-edit-input {
    background: var(--bg-input);
    border: 1px solid var(--primary);
    border-radius: 4px;
    color: var(--text-main);
    padding: 0 4px;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    outline: none;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0; right: 0;
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 320px;
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    z-index: 1100;
    overflow: hidden;
    animation: fadeIn 0.2s ease-out;
}

.notif-dropdown.visible {
    display: block;
}

.notif-header {
    padding: 16px 20px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    background-color: var(--primary-100);
}

.notif-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-muted);
    transition: background-color 0.2s;
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item:hover {
    background-color: rgba(99, 102, 241, 0.03);
}

.notif-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    background-color: #ef4444;
    border: 2px solid var(--bg-card);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    pointer-events: none;
}

.search-dropdown.visible { display: block; }

.search-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.search-dropdown-item:last-child { border-bottom: none; }
.search-dropdown-item:hover { background-color: var(--bg-main); }

.match-type {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 6px;
    min-width: 60px;
    text-align: center;
    letter-spacing: 0.02em;
}

.match-type.table { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.match-type.field { background: rgba(6, 182, 212, 0.15); color: #06b6d4; }
.match-type.key   { background: rgba(99, 102, 241, 0.15); color: #6366f1; }
.match-type.value { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

.match-text {
    display: flex;
    align-items: center;
    width: 100%;
    font-size: 0.875rem;
}

.match-section {
    font-size: 0.6rem;
    margin-left: auto;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
    opacity: 0.8;
    white-space: nowrap;
}

.match-section.model { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.match-section.used  { background: rgba(52, 211, 153, 0.1); color: var(--accent); }
.match-section.tree  { background: rgba(168, 85, 247, 0.1); color: #a855f7; }

/* Glow Effects */
.glow-green {
    box-shadow: 0 0 10px rgba(0, 152, 69, 0.4) !important;
    border-color: var(--primary-300) !important;
    transform: translateY(-4px) scale(1.02);
}

.glow-text-green {
    color: var(--primary-300) !important;
    text-shadow: 0 0 4px rgba(0, 152, 69, 0.5);
    font-weight: 700 !important;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 220px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.profile-dropdown.visible {
    display: flex;
}

.profile-header {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-main);
}

.profile-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.profile-item:hover {
    background-color: var(--bg-main);
    color: var(--primary-300);
}

.profile-item svg {
    color: var(--text-muted);
}

.profile-item:hover svg {
    color: var(--primary-300);
}