/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

:root {
    --bg-color: #000040; /* Deeper than standard royal blue */
    --text-color: #7FFF00; /* Chartreuse */
    --line-color: #404040; /* Gray lines */
    --navbar-width: 200px; /* Fixed width instead of percentage */
    --navbar-bg: rgba(0, 0, 32, 0.95);
}

body {
    font-family: 'Courier Prime', 'Courier New', monospace;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Navbar */
.navbar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--navbar-width);
    background: var(--navbar-bg);
    border-right: 1px solid var(--line-color);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.navbar.hidden {
    transform: translateX(-100%);
}

.navbar-toggle {
    position: fixed;
    left: 10px;
    top: 20px;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 101;
    display: none;  /* Hidden by default */
    transition: opacity 0.3s ease;
}

/* Show hamburger only when navbar is hidden */
.navbar-toggle.show {
    display: block;
}

.navbar-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-color);
    margin-bottom: 5px;
    transition: all 0.3s ease;
}

.navbar-toggle span:last-child {
    margin-bottom: 0;
}

.navbar.hidden .navbar-toggle span:nth-child(1) {
    transform: rotate(0deg);
}

.navbar.hidden .navbar-toggle span:nth-child(2) {
    opacity: 1;
}

.navbar.hidden .navbar-toggle span:nth-child(3) {
    transform: rotate(0deg);
}

.navbar-close {
    position: absolute;
    right: 10px;
    top: 20px;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    z-index: 102;
}

.navbar-close:hover {
    transform: translateX(-3px);
}

.navbar-content {
    padding: 80px 20px 20px;
    height: 100%;
    overflow-y: auto;
}

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

.nav-label {
    color: var(--text-color);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    opacity: 0.6;
}

.nav-button {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--line-color);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    white-space: normal;  /* Allow text wrapping */
    word-wrap: break-word;  /* Break long words if needed */
    transition: all 0.2s ease;
}

.nav-button.example-btn {
    font-size: 13px;
}

.nav-button:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-color);
}

/* Login Container */
.login-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99;
}

/* Login Button */
.login-btn {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.login-btn:hover {
    background: rgba(127, 255, 0, 0.1);
    transform: scale(1.05);
}

.login-btn:active {
    transform: scale(0.98);
}

.login-btn.authenticated {
    border: 2px solid #FFFFFF;
}

.login-text {
    display: block;
}

.user-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: none;
}

.user-avatar:not(.hidden) {
    display: block;
}

.user-avatar:not(.hidden) + .login-text,
.login-text.hidden {
    display: none;
}

/* Profile Dropdown */
.profile-dropdown {
    position: absolute;
    top: 60px;
    right: 0;
    background: var(--navbar-bg);
    border: 1px solid var(--line-color);
    border-radius: 4px;
    overflow: hidden;
    min-width: 120px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.profile-dropdown:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease;
}

.dropdown-item:hover {
    background: rgba(127, 255, 0, 0.1);
}

.dropdown-item:not(:last-child) {
    border-bottom: 1px solid var(--line-color);
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    height: 100vh;
    margin-left: var(--navbar-width);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.navbar.hidden ~ .main-content {
    margin-left: 0;
}

/* Trees Container */
.trees-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    min-height: 0; /* Enable proper flex scrolling */
}

/* Input Wrapper - Fixed at bottom */
.input-wrapper {
    position: sticky;
    bottom: 0;
    background: var(--bg-color);
    border-top: 1px solid var(--line-color);
    padding: 20px;
    display: flex;
    justify-content: center;
    z-index: 50;
}

/* Command Input */
.input-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    align-items: center;
    border: 1px solid var(--line-color);
    padding: 12px 16px;
    background: rgba(0, 0, 32, 0.5);
    transition: all 0.3s ease;
}

.input-container.processing {
    border-color: var(--text-color);
    animation: pulse-border 1s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(127, 255, 0, 0.7);
    }
    50% {
        box-shadow: 0 0 20px 5px rgba(127, 255, 0, 0.3);
    }
}

.prompt {
    color: var(--text-color);
    font-size: 18px;
    margin-right: 10px;
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 50%, 100% {
        opacity: 1;
    }
    25%, 75% {
        opacity: 0.3;
    }
}

.command-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 18px;
    caret-color: var(--text-color);
}

.command-input::placeholder {
    color: #808080;  /* Light gray */
    opacity: 0.7;
}

/* Tree Visualization Styles */
.tree-wrapper {
    border: 1px solid var(--line-color);
    border-radius: 4px;
    padding: 20px;
    margin: 10px 0;
    background: rgba(0, 0, 32, 0.3);
    position: relative;
}

/* Original sentence text */
.tree-sentence {
    position: absolute;
    bottom: 10px;
    left: 10px;
    color: var(--text-color);
    font-size: 14px;
    font-style: italic;
    opacity: 0.7;
    max-width: 70%;
}

/* Debug button (top-right corner, only when ?debug=true) */
.debug-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    background: rgba(0, 0, 32, 0.8);
    color: var(--text-color);
    border: 1px solid var(--text-color);
    border-radius: 4px;
    font-family: 'Courier Prime', 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.debug-btn:hover {
    background: var(--text-color);
    color: var(--bg-color);
    border-color: var(--text-color);
}

.tree-svg {
    width: 100%;
    min-height: 300px;
    background: transparent;
}

.tree-node {
    cursor: pointer;
}

.tree-node rect {
    fill: #000000;  /* Black background for nodes */
    stroke-width: 2;
    transition: all 0.2s ease;
    pointer-events: all;  /* Ensure rect captures all mouse events */
}

.tree-node.verb rect { stroke: #FF0000; }
.tree-node.noun rect { stroke: #0080FF; }
.tree-node.modifier rect { stroke: #FFFF00; }
.tree-node.mark rect { stroke: #00FF00; }
.tree-node.other rect { stroke: #808080; }

.tree-node text {
    font-family: inherit;
    font-size: 18px;  /* Increased from 14px */
    text-anchor: middle;
    dominant-baseline: middle;
    transition: all 0.2s ease;
    pointer-events: none;  /* Allow hover events to pass through to rect */
}

.tree-node.verb text { fill: #FF0000; }
.tree-node.noun text { fill: #0080FF; }
.tree-node.modifier text { fill: #FFFF00; }
.tree-node.mark text { fill: #00FF00; }
.tree-node.other text { fill: #808080; }

.tree-node:hover rect {
    filter: drop-shadow(0 0 8px currentColor);
    stroke-width: 3;
}

/* Special styling for Wikipedia-linked nodes */
.tree-node[style*="cursor: pointer"] rect {
    stroke-dasharray: 3 2;
}

.tree-node[style*="cursor: pointer"]:hover rect {
    stroke-dasharray: none;
    fill: rgba(127, 255, 0, 0.1);
}

.tree-link {
    fill: none;
    stroke-width: 2;
    opacity: 0.8;
}

.tree-link.agent { stroke: #FFA500; }
.tree-link.patient { stroke: #87CEEB; }
.tree-link.combinator { stroke: #808080; }
.tree-link.theme { stroke: #90EE90; }
.tree-link.location { stroke: #DDA0DD; }
.tree-link.other { stroke: #606060; }

/* Loading Animation */
.loading-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    display: none; /* Hidden by default */
}

.loading-animation:not(.hidden) {
    display: flex; /* Only show when hidden class is removed */
}

.tree-loader {
    position: relative;
    width: 100px;
    height: 120px;
}

/* Tree trunk */
.tree-trunk {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 40px;
    background: var(--text-color);
    animation: grow-up 1s ease-out infinite;
}

/* Tree branches forming */
.tree-branch {
    position: absolute;
    background: var(--text-color);
    transform-origin: bottom center;
}

.tree-branch-1 {
    bottom: 30px;
    left: 50%;
    width: 3px;
    height: 25px;
    --rotation: -30deg;
    transform: translateX(-50%) rotate(-30deg);
    animation: branch-grow 1.5s ease-in-out infinite;
}

.tree-branch-2 {
    bottom: 30px;
    left: 50%;
    width: 3px;
    height: 25px;
    --rotation: 30deg;
    transform: translateX(-50%) rotate(30deg);
    animation: branch-grow 1.5s 0.2s ease-in-out infinite;
}

.tree-branch-3 {
    bottom: 50px;
    left: 50%;
    width: 3px;
    height: 20px;
    --rotation: -45deg;
    transform: translateX(-50%) rotate(-45deg);
    animation: branch-grow 1.5s 0.4s ease-in-out infinite;
}

.tree-branch-4 {
    bottom: 50px;
    left: 50%;
    width: 3px;
    height: 20px;
    --rotation: 45deg;
    transform: translateX(-50%) rotate(45deg);
    animation: branch-grow 1.5s 0.6s ease-in-out infinite;
}

.tree-branch-5 {
    bottom: 40px;
    left: 50%;
    width: 3px;
    height: 22px;
    --rotation: -20deg;
    transform: translateX(-50%) rotate(-20deg);
    animation: branch-grow 1.5s 0.3s ease-in-out infinite;
}

.tree-branch-6 {
    bottom: 40px;
    left: 50%;
    width: 3px;
    height: 22px;
    --rotation: 20deg;
    transform: translateX(-50%) rotate(20deg);
    animation: branch-grow 1.5s 0.5s ease-in-out infinite;
}

.tree-branch-7 {
    bottom: 60px;
    left: 50%;
    width: 3px;
    height: 18px;
    --rotation: -35deg;
    transform: translateX(-50%) rotate(-35deg);
    animation: branch-grow 1.5s 0.7s ease-in-out infinite;
}

.tree-branch-8 {
    bottom: 60px;
    left: 50%;
    width: 3px;
    height: 18px;
    --rotation: 35deg;
    transform: translateX(-50%) rotate(35deg);
    animation: branch-grow 1.5s 0.8s ease-in-out infinite;
}

/* Leaves appearing */
.tree-leaf {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--text-color);
    border-radius: 50%;
    opacity: 0;
}

.tree-leaf-1 {
    top: 35px;
    left: 20px;
    animation: leaf-appear 2s 0.8s ease-in-out infinite;
}

.tree-leaf-2 {
    top: 40px;
    right: 20px;
    animation: leaf-appear 2s 1s ease-in-out infinite;
}

.tree-leaf-3 {
    top: 50px;
    left: 15px;
    animation: leaf-appear 2s 1.2s ease-in-out infinite;
}

.tree-leaf-4 {
    top: 55px;
    right: 15px;
    animation: leaf-appear 2s 1.4s ease-in-out infinite;
}

.tree-leaf-5 {
    top: 30px;
    left: 25px;
    animation: leaf-appear 2s 0.9s ease-in-out infinite;
}

.tree-leaf-6 {
    top: 33px;
    right: 25px;
    animation: leaf-appear 2s 1.1s ease-in-out infinite;
}

.tree-leaf-7 {
    top: 43px;
    left: 10px;
    animation: leaf-appear 2s 1.3s ease-in-out infinite;
}

.tree-leaf-8 {
    top: 47px;
    right: 10px;
    animation: leaf-appear 2s 1.5s ease-in-out infinite;
}

.tree-leaf-9 {
    top: 37px;
    left: 30px;
    animation: leaf-appear 2s 1.0s ease-in-out infinite;
}

.tree-leaf-10 {
    top: 45px;
    right: 28px;
    animation: leaf-appear 2s 1.6s ease-in-out infinite;
}

/* Additional top middle leaves */
.tree-leaf-11 {
    top: 25px;
    left: 50%;
    margin-left: -4px;
    animation: leaf-appear 2s 0.7s ease-in-out infinite;
}

.tree-leaf-12 {
    top: 20px;
    left: 50%;
    margin-left: -12px;
    animation: leaf-appear 2s 1.0s ease-in-out infinite;
}

.tree-leaf-13 {
    top: 20px;
    left: 50%;
    margin-left: 4px;
    animation: leaf-appear 2s 1.2s ease-in-out infinite;
}

.tree-leaf-14 {
    top: 15px;
    left: 50%;
    margin-left: -4px;
    animation: leaf-appear 2s 1.4s ease-in-out infinite;
}

.tree-leaf-15 {
    top: 10px;
    left: 50%;
    margin-left: -4px;
    animation: leaf-appear 2s 0.8s ease-in-out infinite;
}

@keyframes grow-up {
    0%, 100% {
        height: 40px;
        opacity: 0.3;
    }
    50% {
        height: 45px;
        opacity: 1;
    }
}

@keyframes branch-grow {
    0%, 100% {
        transform: translateX(-50%) rotate(var(--rotation, -30deg)) scaleY(0.5);
        opacity: 0.3;
    }
    50% {
        transform: translateX(-50%) rotate(var(--rotation, -30deg)) scaleY(1);
        opacity: 1;
    }
}

@keyframes leaf-appear {
    0%, 100% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    75% {
        transform: scale(1);
        opacity: 0.8;
    }
}

/* Node Tooltip */
.node-tooltip {
    position: absolute;
    background: var(--navbar-bg);
    border: 1px solid var(--line-color);
    border-radius: 4px;
    padding: 10px;
    font-size: 12px;
    color: var(--text-color);
    pointer-events: auto;  /* Allow clicking links */
    display: none;  /* Hidden by default for better performance */
    z-index: 200;
    min-width: 150px;
    max-width: 400px;
    width: fit-content;  /* Changed from max-content to fit-content */
}

.node-tooltip.visible {
    display: block;  /* Show instantly without animation */
}

.tooltip-field {
    display: flex;
    margin-bottom: 8px;
    gap: 12px;  /* Reduced gap */
    align-items: flex-start;  /* Align items at the start */
}

.field-name {
    font-weight: bold;
    color: #FFFFFF;  /* Changed from yellow to white */
    flex-shrink: 0;
    min-width: 60px;  /* Consistent label width */
}

.field-value {
    color: var(--text-color);
    text-align: left;  /* Changed from right to left */
    word-break: break-word;  /* Allow long words to break */
}

.tooltip-definition {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line-color);
    font-style: italic;
    color: #A0A0A0;
    line-height: 1.4;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--line-color);
}

/* Performance optimizations */
.navbar,
.navbar-toggle,
.login-btn {
    will-change: transform;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    :root {
        --navbar-width: 250px; /* Slightly wider on mobile for touch targets */
    }
    
    .main-content {
        padding: 0 5%;
    }
    
    .command-input,
    .prompt {
        font-size: 16px;
    }
}
/* Debug Mode Styles */
.debug-container {
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--line-color);
    padding: 10px 20px;
}

.debug-container.hidden {
    display: none;
}

.debug-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.debug-tab {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--line-color);
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.debug-tab:hover {
    background: rgba(255, 255, 255, 0.05);
}

.debug-tab.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.debug-panels {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--line-color);
    border-radius: 8px;
    max-height: 300px;
    overflow: auto;
}

.debug-panel {
    display: none;
    padding: 15px;
}

.debug-panel.active {
    display: block;
}

.debug-panel pre {
    margin: 0;
    font-family: 'Courier Prime', monospace;
    font-size: 12px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-color);
}

/* Pronoun highlighting in debug mode */
.pronoun-highlight {
    background: rgba(255, 255, 0, 0.2);
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 0, 0.4);
}

.pronoun-pointer {
    color: #4CAF50;
    font-weight: bold;
}

/* Blinking animation for pointer targets */
@keyframes pointer-target-blink {
    0% { fill: #000000; stroke-width: 2; }
    25% { fill: #FF6B6B; stroke: #FF6B6B; stroke-width: 4; }
    50% { fill: #000000; stroke-width: 2; }
    75% { fill: #FF6B6B; stroke: #FF6B6B; stroke-width: 4; }
    100% { fill: #000000; stroke-width: 2; }
}

.tree-node rect.pointer-target-blink {
    animation: pointer-target-blink 1.5s infinite !important;
}
