/* GFX Hub - Dark Theme Styling */

:root {
    /* Color palette - Navy Dark Theme */
    --bg-primary: #060b18;    /* Deepest navy background */
    --bg-secondary: #0a1022;  /* Main content background */
    --bg-tertiary: #0f1629;   /* Sidebar/Card background */
    --bg-card: #111827;
    --bg-elevated: #1a2235;
    --bg-hover: #151d2e;
    
    --border-default: #1e293b;
    --border-muted: #1a2744;
    
    --text-primary: #f1f5f9;   /* White/Off-white */
    --text-secondary: #94a3b8; /* Muted slate */
    --text-muted: #64748b;
    
    --accent-blue: #6366f1;    /* Indigo-500 */
    --accent-blue-bright: #818cf8;
    --accent-green: #10b981;   /* Emerald-500 */
    --accent-green-bright: #34d399;
    --accent-purple: #8b5cf6;  /* Purple-500 */
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-cyan: #22d3ee;
    
    /* Gradients */
    --gradient-card: linear-gradient(135deg, #111827 0%, #0a1022 100%);
    --gradient-accent: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-green: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-blue: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
    
    --navbar-height: 64px;
    --sidebar-width: 260px;
    
    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding-top: var(--navbar-height);
}

body.no-navbar {
    padding-top: 0;
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: transparent;
    border-bottom: 1px solid transparent;
    z-index: 1000;
    display: flex;
    align-items: center;
}

.navbar-container {
    padding: 0 24px;
    width: 100%;
    display: flex;
    align-items: center;
}

.navbar-brand {
    position: absolute;
    left: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.navbar-brand svg {
    color: var(--accent-blue);
    width: 28px;
    height: 28px;
}

.navbar-links {
    display: flex;
    gap: 24px;
    margin-left: 284px; /* Sidebar width (260px) + 24px spacing */
    flex: 1;
}

.nav-link {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    border-right: 1px solid var(--border-default);
}

.user-name {
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
}

.logout-link {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.logout-link:hover {
    color: var(--accent-red);
}

/* Navbar User Section - Compact */
.navbar-user-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 16px;
    border-left: 1px solid var(--border-muted);
}

.navbar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: white;
    text-transform: uppercase;
}

.navbar-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.navbar-logout-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-red);
}

.nav-users {
    display: flex;
    gap: 8px;
    align-items: center;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-purple);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

/* Layout containers */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Projects Layout */
.projects-layout {
    display: flex;
    min-height: 100vh;
}

.projects-main {
    flex: 1;
    padding: 32px 40px;
    overflow-y: auto;
    background: var(--bg-primary);
}

.projects-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}

.projects-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0 0 8px;
}

.projects-subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 0;
}

.projects-content {
    /* Projects grid container */
}

.page-header {
    padding: 32px 0;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

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

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-accent);
    color: white !important;
    border: none;
}

.btn-primary:hover {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
    opacity: 0.9;
}

.btn-primary:visited,
.btn-primary:link,
.btn-primary:active {
    color: white !important;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-default);
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--accent-blue);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

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

.node-card .btn-ghost:hover {
    background: var(--node-lighter, rgba(255, 255, 255, 0.1));
    color: #ffffff;
}

/* URL Copy modal button - no purple hover */
.url-copy-btn:hover {
    color: #ffffff !important;
    background: var(--bg-hover);
}

.btn-ghost-danger:hover {
    color: var(--accent-red);
    background: rgba(248, 81, 73, 0.1);
}

.btn-danger {
    background: var(--accent-red);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
    position: relative;
    display: flex;
    flex-direction: column;
}

.card:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(88, 166, 255, 0.1);
    transform: translateY(-4px);
}

.card-thumbnail {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-bottom: 1px solid var(--border-muted);
}

.card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-thumbnail-placeholder {
    font-size: 3rem;
    color: var(--text-muted);
}

.card-settings-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.card:hover .card-settings-btn {
    opacity: 1;
}

.card-body {
    padding: 16px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.card-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border-muted);
}

.card-version {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-action {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-action:hover {
    color: var(--accent-blue);
}

/* Projects grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-success {
    background: rgba(35, 134, 54, 0.2);
    color: var(--accent-green-bright);
}

.badge-info {
    background: rgba(88, 166, 255, 0.2);
    color: var(--accent-blue);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.875rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

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

.form-select {
    cursor: pointer;
    /* Remove native styling across all browsers */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    /* Custom dropdown arrow */
    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='%238b949e' 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 12px center;
    padding-right: 36px;
    /* Ensure proper stacking and containment */
    position: relative;
    z-index: 1;
    /* Prevent native dropdown overlay issues */
}

/* Style select options consistently */
.form-select option {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 10px 14px;
    border: none;
}

/* Ensure select dropdown doesn't overlay page content */
.form-select:focus {
    z-index: 10;
    position: relative;
}

/* Webkit-specific fixes for Mac */
.form-select::-webkit-appearance {
    -webkit-appearance: none;
}

.form-select::-ms-expand {
    display: none; /* Hide IE11 native arrow */
}

/* Ensure field wrapper contains the select properly */
.field-wrapper {
    position: relative;
    z-index: 1;
    /* Prevent native dropdown from breaking layout */
    overflow: visible;
}

.field-wrapper:focus-within {
    z-index: 10;
}

/* Node field container - ensure proper containment */
.node-field {
    position: relative;
    z-index: 1;
    margin-bottom: 16px;
}

.node-field:last-child {
    margin-bottom: 0;
}

.node-field:has(.form-select:focus),
.node-field:has(.custom-dropdown.open),
.node-field.field-open {
    z-index: 100;
}

/* Custom Dropdown Component */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.custom-dropdown-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    font-size: 0.875rem;
    background: var(--node-darker, var(--bg-primary));
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--node-text, var(--text-primary));
    cursor: pointer;
    transition: border-color var(--transition-fast);
    user-select: none;
    min-height: 42px;
    box-sizing: border-box;
}

.custom-dropdown-selected:hover {
    border-color: rgba(255, 255, 255, 0.5);
}

.custom-dropdown:focus .custom-dropdown-selected,
.custom-dropdown.open .custom-dropdown-selected {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
    outline: none;
}

.custom-dropdown-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.dropdown-search-input {
    width: 100%;
    background: transparent;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    outline: none;
    padding: 0;
    margin: 0;
}

.dropdown-search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.custom-dropdown-arrow {
    flex-shrink: 0;
    margin-left: 8px;
    color: #ffffff;
    opacity: 0.7;
    transition: transform var(--transition-fast);
}

.custom-dropdown.open .custom-dropdown-arrow {
    transform: rotate(180deg);
}

.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: var(--node-darker, var(--bg-elevated));
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    max-height: 300px;
    overflow: hidden;
    display: none;
    visibility: hidden;
    opacity: 0;
    z-index: 10000;
    margin-top: 4px;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.custom-dropdown.open .custom-dropdown-menu {
    display: block;
    visibility: visible;
    opacity: 1;
}


.custom-dropdown-options {
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
}

.custom-dropdown-option {
    padding: 10px 14px;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}

.custom-dropdown-option:hover {
    background: var(--node-lighter, var(--bg-hover));
}

.custom-dropdown-option.selected {
    background: var(--node-lighter, var(--bg-elevated));
    color: var(--node-text, #ffffff);
    font-weight: 600;
}

.custom-dropdown-option.custom-option {
    color: var(--text-secondary);
    font-style: italic;
}

/* Scrollbar for dropdown options */
.custom-dropdown-options::-webkit-scrollbar {
    width: 6px;
}

.custom-dropdown-options::-webkit-scrollbar-track {
    background: transparent;
}

.custom-dropdown-options::-webkit-scrollbar-thumb {
    background: var(--node-lighter, var(--border-default));
    border-radius: 3px;
}

.custom-dropdown-options::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Input-only mode for subtitle fields */
.custom-dropdown.input-only .custom-dropdown-menu {
    display: none !important;
}

.custom-dropdown.input-only .custom-dropdown-arrow {
    display: none;
}

.custom-dropdown.input-only .custom-dropdown-selected {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 180px;
    padding: 4px 0;
    animation: contextMenuFade 0.15s ease;
}

@keyframes contextMenuFade {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
}

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

.context-menu-item.danger {
    color: var(--accent-red);
}

.context-menu-item.danger:hover {
    background: rgba(248, 81, 73, 0.1);
}

.context-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.context-menu-divider {
    height: 1px;
    background: var(--border-default);
    margin: 4px 0;
}

.context-menu-shortcut {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Row selection */
.data-table tbody tr.selected {
    background: rgba(88, 166, 255, 0.15) !important;
}

.data-table tbody tr.selected td {
    background: transparent;
}

/* Row dragging */
.data-table tbody tr {
    cursor: default;
}

.data-table tbody tr.drag-ready {
    cursor: grabbing;
    background: var(--bg-hover);
}

.data-table tbody tr.dragging {
    opacity: 0.5;
    background: var(--bg-hover);
}

.data-table tbody tr.drag-over {
    border-top: 2px solid var(--accent-blue);
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-blue);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, backdrop-filter 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(30px);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), 
                opacity 0.25s ease;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

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

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.modal-body {
    padding: 32px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 24px 32px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-muted);
}

/* Sidebar layout for manage page */
.manage-layout {
    display: flex;
    min-height: 100vh;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.manage-layout.ready {
    opacity: 1;
}

.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-default);
    padding: 0;
    flex-shrink: 0;
    position: sticky;
    display: flex;
    flex-direction: column;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

/* Sidebar Logo */
.sidebar-logo {
    padding: 20px;
    border-bottom: 1px solid var(--border-muted);
}

.sidebar-logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.sidebar-logo-link:hover {
    opacity: 0.8;
    color: var(--text-primary);
}

.sidebar-logo-link svg {
    color: var(--accent-blue);
}

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

.sidebar-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.sidebar-project-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-project-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green-bright);
    flex-shrink: 0;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav-item {
    margin-bottom: 2px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    margin: 0 12px 4px;
    transition: all var(--transition-fast);
}

.sidebar-nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav-icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    flex-shrink: 0;
    transition: opacity var(--transition-fast);
}

.sidebar-nav-link.active .sidebar-nav-icon,
.sidebar-nav-link:hover .sidebar-nav-icon {
    opacity: 1;
}

.sidebar-section {
    padding: 16px 0 8px;
}

.sidebar-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding: 0 20px;
}

/* Expandable nav items */
.sidebar-nav-group {
    margin-bottom: 4px;
}

.sidebar-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: calc(100% - 24px);
    padding: 10px 20px;
    margin: 0 12px 4px;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-nav-toggle:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav-toggle.active {
    color: var(--text-primary);
}

.sidebar-nav-toggle-icon {
    transition: transform var(--transition-fast);
}

.sidebar-nav-toggle.expanded .sidebar-nav-toggle-icon {
    transform: rotate(90deg);
}

.sidebar-nav-children {
    display: none;
    padding-left: 44px;
}

.sidebar-nav-group.expanded .sidebar-nav-children {
    display: block;
}

.sidebar-nav-child {
    display: block;
    padding: 8px 20px;
    color: var(--text-muted);
    font-size: 0.8125rem;
    transition: color var(--transition-fast);
}

.sidebar-nav-child:hover {
    color: var(--text-primary);
}

.sidebar-nav-child.active {
    color: var(--accent-blue);
}

.sidebar-add-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    margin: 0 12px 4px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.sidebar-add-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Sidebar User Profile - Bottom section */
.sidebar-user-section {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border-muted);
    flex-shrink: 0;
}

.sidebar-user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.sidebar-user-profile:hover {
    background: var(--bg-hover);
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-top: 8px;
    background: transparent;
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    width: 100%;
    justify-content: center;
}

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

.sidebar-logout-btn svg {
    opacity: 0.7;
}

/* Sidebar Version Footer */
.sidebar-version {
    padding: 12px 16px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-version-text {
    font-size: 0.6875rem;
    color: var(--text-muted);
    opacity: 0.6;
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Main content area */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* Node cards */
.nodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    align-items: start; /* Allow cards to have independent heights */
}

.node-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: visible !important;
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
    position: relative; /* Ensure z-index works */
}

.node-card:focus-within,
.node-card.has-open-dropdown {
    z-index: 100; /* Bring card to front when interacting with its fields */
}

.node-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-color: var(--border-default);
}

.node-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-default);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast), 
                border-bottom-color 0.3s ease,
                border-bottom-left-radius 0.3s ease,
                border-bottom-right-radius 0.3s ease;
    /* Add rounded corners since overflow: hidden is removed from parent */
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.node-card-header:hover {
    background: var(--bg-hover);
}

/* Dynamic header color - 20% darker than card background */
.node-card[data-bg-color] .node-card-header {
    background: var(--bg-tertiary); /* Fallback */
}

.node-card:hover[data-bg-color] .node-card-header {
    background: var(--bg-hover); /* Fallback */
}

.node-card-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.node-card-collapse-icon {
    width: 20px;
    height: 20px;
    color: #ffffff;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.node-card.collapsed .node-card-collapse-icon {
    transform: rotate(-90deg);
}

.node-card-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #ffffff;
}

.node-card-subtitle {
    font-size: 0.8125rem;
    color: #ffffff;
    margin-top: 6px;
}

.node-card-order {
    font-size: 0.75rem;
    font-weight: 600;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    margin-left: 8px;
}

.node-card-body {
    overflow: visible !important;
    box-sizing: border-box;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s ease,
                visibility 0.3s;
}

.node-card-body-inner {
    padding: 20px 24px;
    overflow: visible !important;
}

.node-card.collapsed .node-card-body,
.node-card[data-is-animating="true"] .node-card-body {
    overflow: hidden !important;
}

.node-card.collapsed .node-card-body {
    height: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.node-card.collapsed {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.node-card.collapsed .node-card-header {
    border-bottom-color: transparent;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.custom-input-active {
    border-color: var(--accent-blue) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
}

.node-field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #ffffff;
    margin-bottom: 8px;
    opacity: 0.9;
}

.node-nav-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.node-nav-button {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.node-nav-button:hover {
    background: var(--node-lighter, rgba(255, 255, 255, 0.1));
    color: var(--node-text, #ffffff);
}

.form-select, .form-input, .data-table-input {
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    transition: all var(--transition-fast);
}

.form-select:hover, .form-input:hover {
    border-color: var(--text-muted);
}

.form-select:focus, .form-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

/* Add node button */
.add-node-card {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-lg);
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    cursor: pointer;
    transition: all var(--transition-normal);
    min-height: 200px;
}

.add-node-card:hover {
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.05);
    transform: translateY(-2px);
}

.add-node-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--accent-blue);
    transition: all var(--transition-fast);
}

.add-node-card:hover .add-node-icon {
    background: var(--accent-blue);
    color: white;
}

.add-node-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Data table styles */
.table-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table-card-header {
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-muted);
}

.table-card-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.table-card-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

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

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

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

.search-input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.data-table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    border-bottom: 1px solid var(--border-default);
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-muted);
    transition: background var(--transition-fast);
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table-input {
    width: auto;
    min-width: 60px;
    max-width: 100%;
    field-sizing: content;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    min-height: 24px;
}

.data-table-input:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-default);
}

.data-table-input:focus {
    outline: none;
    background: var(--bg-primary);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.data-table-input.pasting {
    background: rgba(88, 166, 255, 0.1);
    border-color: var(--accent-blue);
}

.column-header-input {
    font-weight: 700;
    color: var(--text-primary);
    text-align: left;
    width: auto !important;
    min-width: 60px;
    field-sizing: content;
}

/* Prevent text selection on shift+click */
.data-table tbody tr {
    user-select: none;
    -webkit-user-select: none;
}

.data-table tbody tr input {
    user-select: text;
    -webkit-user-select: text;
}

/* Column resizing */
.data-table th {
    position: relative;
}

.data-table th.resizable {
    min-width: 80px;
}

.column-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
}

.column-resizer:hover,
.column-resizer.resizing {
    background: var(--accent-blue);
}

.data-table.resizing {
    cursor: col-resize;
    user-select: none;
}

.data-table.resizing * {
    cursor: col-resize !important;
}

.table-card-footer {
    padding: 16px;
    text-align: center;
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-muted);
    font-size: 0.8125rem;
    border-top: 1px solid var(--border-muted);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-default);
}

.tab {
    padding: 12px 20px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
}

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

.tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

/* Tab content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Settings panel */
.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    pointer-events: none;
}

.settings-panel.active {
    pointer-events: all;
}

.settings-panel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.settings-panel.active .settings-panel-overlay {
    opacity: 1;
}

.settings-panel-content {
    position: fixed;
    top: var(--navbar-height);
    right: -400px;
    width: 400px;
    height: calc(100vh - var(--navbar-height));
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-default);
    transition: right var(--transition-normal);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.settings-panel.active .settings-panel-content {
    right: 0;
}

.settings-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

/* Universal modal close button */
.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.modal-close svg {
    width: 16px;
    height: 16px;
}

.settings-panel-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

/* Project Settings Modal */
.project-settings-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.project-settings-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: grab;
    transition: all var(--transition-fast);
}

.project-settings-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.project-settings-item:active {
    cursor: grabbing;
}

.project-settings-item.dragging {
    opacity: 0.5;
    background: var(--bg-elevated);
}

.project-settings-item-drag {
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.project-settings-item-drag span {
    display: block;
    width: 16px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.project-settings-item-order {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    min-width: 36px;
    text-align: center;
}

.project-settings-item-info {
    flex: 1;
}

.project-settings-item-title {
    font-weight: 600;
    color: var(--text-primary);
}

.project-settings-item-type {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.project-settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-muted);
}

.project-settings-reset-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--accent-red);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.project-settings-reset-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.project-settings-nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.project-settings-nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state-description {
    font-size: 0.875rem;
    max-width: 300px;
    margin: 0 auto 20px;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.toast-success {
    border-left: 3px solid var(--accent-green);
}

.toast-error {
    border-left: 3px solid var(--accent-red);
}

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

/* Utility classes */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--accent-green-bright); }
.text-danger { color: var(--accent-red); }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 200;
        transition: left var(--transition-normal);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .nodes-grid {
        grid-template-columns: 1fr;
    }
}

/* User Profile Card - Matches reference dashboard */
.user-profile-box {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1100;
    min-width: 220px;
}

.user-avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name-display {
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email-display {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-link-new {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color var(--transition-fast);
}

.logout-link-new:hover {
    color: var(--accent-red);
}

.version-footer {
    position: fixed;
    bottom: 8px;
    right: 24px;
    font-size: 0.625rem;
    color: var(--text-muted);
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    pointer-events: none;
    z-index: 1099;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
