/* Reset some default styles */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    max-width: 100vw;
    font-family: Arial, sans-serif;
    overflow-x: hidden;
    background-color: #f4f4f4;
}

/* Create a grid layout for the main interface */
.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: 70px 1fr;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Left sidebar for information panels */
.sidebar-left {
    grid-column: 1;
    grid-row: 2;
    background-color: #1e1e1e;
    overflow-y: hidden;
    padding: 0 15px 15px 15px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    z-index: 5;
    height: calc(100vh - 70px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Main content area for the graph */
.main-content {
    grid-column: 2;
    grid-row: 2;
    position: relative;
    overflow: hidden;
    width: 100%;
    height: calc(100vh - 70px);
    transition: height 0.3s ease; /* Add transition for resize */
}

/* Adjust main content when sidebar is open */
.sidebar-bottom.open ~ .main-content {
    height: calc(100vh - 70vh - 70px); /* Adjust for larger sidebar height */
}

/* Graph container takes full space of main content */
#graph-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #1a1a1a;
    z-index: 0;
}

#3d-graph {
    width: 100%;
    height: 100%;
    display: block;
}

/* Search container at the top of the sidebar */
#search-container {
    background-color: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    z-index: 10;
}

.search-row {
    display: flex;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.search-row:last-child {
    margin-bottom: 0;
}

#search-input {
    flex: 1;
    min-width: 120px;
    padding: 8px;
    border: none;
    border-radius: 4px;
    background-color: #3a3a3a;
    color: #f0f0f0;
}

#search-attribute {
    padding: 8px;
    border: none;
    border-radius: 4px;
    background-color: #3a3a3a;
    color: #f0f0f0;
}

#search-button {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    background-color: #0056b3;
    color: white;
    cursor: pointer;
}

#search-button:hover {
    background-color: #007bff;
}

select.control-item {
    width: 120px;
    padding: 0 5px;
}

#dimension-select {
    width: 100px;
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: white;
    height: 4vh;
    font-size: 12px;
}

#dimension-select:hover {
    border-color: #888;
}

#dimension-select:focus {
    outline: none;
    border-color: #666;
    box-shadow: 0 0 3px rgba(0,0,0,0.2);
}

/* Style for information cards */
.info-card {
    background-color: rgba(42, 42, 42, 0.95);
    border-radius: 6px;
    padding: 12px 15px;
    margin-bottom: 15px;
    z-index: 10;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

/* Specific styling for scrollable cards */
.info-card.scrollable {
    overflow-y: auto;
    max-height: 300px;
}

.info-card h4 {
    font-size: 14px;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: #f0f0f0;
    font-weight: 500;
}

.info-card ul {
    padding-left: 20px;
    margin: 0;
}

.info-card li {
    margin-bottom: 10px;
}

.info-card li:last-child {
    margin-bottom: 0;
}

.info-card p {
    margin: 5px 0;
    font-size: 14px;
    color: #e0e0e0;
}

.info-card strong {
    color: #aaa;
}

.info-card span {
    color: #ffffff;
}

/* View controls */
#view-controls {
    background-color: rgba(42, 42, 42, 0.85);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
}

.view-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

/* Pill-style toggle switches */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    background-color: rgba(60, 60, 60, 0.7);
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
    margin-right: 8px;
}

.checkbox-wrapper:hover {
    background-color: rgba(80, 80, 80, 0.7);
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkbox-label {
    color: #fff;
}

.checkbox-wrapper input[type="checkbox"]:checked {
    background-color: #8e44ad;
}

.checkbox-wrapper:has(input[type="checkbox"]:checked) {
    background-color: rgba(142, 68, 173, 0.4);
    border: 1px solid rgba(142, 68, 173, 0.8);
}

.checkbox-label {
    margin-left: 5px;
    font-size: 12px;
    color: #d0d0d0;
    cursor: pointer;
}

/* Checkboxes styling */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid #aaa;
    border-radius: 3px;
    background-color: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    position: relative;
}

input[type="checkbox"]:checked {
    background-color: #8e44ad;
    border-color: #8e44ad;
}

input[type="checkbox"]:checked::after {
    content: "✓";
    color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
}

.compact-button {
    padding: 6px 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: inline-block;
}

.compact-button:hover {
    background-color: #0069d9;
}

.compact-button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.secondary-button {
    background-color: #6c757d;
    margin-left: 8px;
}

.secondary-button:hover {
    background-color: #5a6268;
}

/* Search accordion styling */
.search-accordion {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 265px;
    background-color: rgba(42, 42, 42, 0.95);
    z-index: 10;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    overflow: hidden;
}

.search-accordion .accordion-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.search-accordion .accordion-header {
    width: 100%;
    background-color: rgba(50, 50, 50, 0.8);
    border: none;
    padding: 10px 12px;
    color: #f0f0f0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.search-accordion .accordion-header:hover {
    background-color: rgba(70, 70, 70, 0.8);
}

.search-accordion .accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: rgba(42, 42, 42, 0.95);
    pointer-events: none;
}

.search-accordion .accordion-content.open {
    max-height: 200px;
    padding: 10px 12px;
    overflow-y: auto;
    pointer-events: auto;
}

/* Specific styling for Search Matches to ensure scrolling - only when open */
#search-matches-content.open {
    max-height: 600px !important;
    overflow-y: auto !important;
    padding: 10px 12px !important;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}


.search-accordion .accordion-content p {
    margin: 4px 0;
    font-size: 13px;
}

.search-accordion .accordion-content strong {
    color: #aaa;
}

.search-accordion .accordion-content span {
    color: #ffffff;
}

/* Match count styling */
.match-count {
    color: #aaa;
    font-size: 12px;
    font-weight: normal;
}

#search-info-content p {
    margin: 4px 0;
    font-size: 13px;
}

/* View Controls Panel */
#view-controls-panel {
    position: absolute;
    top: 10px; /* Position at the top */
    left: 325px; /* Increase horizontal space from 305px to 325px */
    width: 190px;
    background-color: rgba(42, 42, 42, 0.95);
    min-height: 135px;
    padding: 12px 15px;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

#view-controls-panel h4 {
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 8px 0;
    padding-bottom: 6px;
}

#view-controls-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#view-controls-content .control-item {
    flex: 1;
    min-height: 30px;
    margin-bottom: 5px; /* Add consistent spacing between controls */
}

#view-controls-content select.control-item {
    padding: 5px;
    min-width: 100px;
    min-height: 28px;
    height: 28px;
    background-color: rgba(60, 60, 60, 0.7);
    color: #f0f0f0;
    border: 1px solid rgba(80, 80, 80, 0.5);
    border-radius: 4px;
}

#view-controls-content .checkbox-wrapper {
    display: flex;
    align-items: center;
    background-color: rgba(60, 60, 60, 0.7);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#view-controls-content .checkbox-wrapper:hover {
    background-color: rgba(80, 80, 80, 0.8);
}

#search-info h4 {
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 8px 0;
    padding-bottom: 6px;
}

/* Search matches content styling (now within accordion) - merged with main rule above */

#search-matches-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#search-matches-content li {
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
}

.match-item {
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
    background-color: rgba(60, 60, 60, 0.4);
    border-radius: 4px;
    transition: background-color 0.2s;
}

.match-item:hover {
    background-color: rgba(80, 80, 80, 0.6);
}

.match-kanji {
    font-size: 15px;
    color: #9c64ff;
    font-weight: 500;
    cursor: pointer;
}

.match-hiragana {
    font-size: 12px;
    color: #ccc;
    margin-bottom: 2px;
}

.match-translation {
    font-size: 12px;
    color: #aaa;
    font-style: italic;
}

/* Selected node styling */
#node-info {
    background-color: #222;
    border-radius: 5px;
    padding: 15px;
    margin-top: 0;
    margin-bottom: 15px;
    color: #fff;
    flex-shrink: 0;
    max-height: 200px;
    overflow-y: hidden;
}

#node-info-content {
    display: flex;
    flex-direction: column;
    height: 170px;
    overflow-y: auto;
    padding-right: 5px;
}

.node-property {
    display: flex;
    margin-bottom: 5px;
    font-size: 0.85rem;
    line-height: 1.2;
}

.property-name {
    font-weight: bold;
    margin-right: 5px;
    min-width: 100px;
    color: #aaa;
}

.property-value {
    color: #fff;
    word-break: break-word;
}

/* Neighbors list styling */
#neighbors-info {
    background-color: #222;
    border-radius: 5px;
    padding: 15px;
    color: #fff;
    flex: 1;
    min-height: 150px;
    max-height: calc(100vh - 350px);
    display: flex;
    flex-direction: column;
}

#neighbors-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 5px;
}

/* Ensure neighbor item is styled properly within scrollable container */
.neighbor-item {
    background-color: #333;
    border-radius: 4px;
    padding: 8px;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    margin-bottom: 6px;
}

.neighbor-item:hover {
    background-color: rgba(80, 80, 80, 0.6);
}

.neighbor-kanji {
    font-size: 15px;
    color: #9c64ff;
    font-weight: 500;
    cursor: pointer;
}

.neighbor-hiragana {
    font-size: 12px;
    color: #ccc;
    margin-bottom: 2px;
}

.neighbor-translation {
    font-size: 12px;
    color: #bbb;
    font-style: italic;
}

.neighbor-relation {
    font-size: 10px;
    color: #8e44ad;
    margin-top: 2px;
}

.node-link {
    color: #673ab7;
    text-decoration: none;
    font-weight: bold;
}

.node-link:hover {
    text-decoration: underline;
}

.relation-strength {
    display: inline-block;
    margin-left: 5px;
    font-size: 0.8em;
    color: #666;
    background-color: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Control items */
.control-item {
    font-size: 12px;
    border-radius: 4px;
    gap: 5px;
    min-height: 24px;
}

/* Control buttons */
.control-button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background-color: #444;
    color: #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.control-button:hover {
    background-color: #555;
}

/* Media queries for responsive design */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: 120px auto 1fr;
    }
    
    .app-header {
        height: 120px;
    }
    
    .header-left {
        width: 100%;
    }
    
    .header-right {
        display: none;
    }
    
    .header-search-container {
        gap: 10px;
    }
    
    .header-search-row {
        flex-wrap: wrap;
    }
    
    .sidebar-left {
        grid-column: 1;
        grid-row: 2;
        max-height: 40vh;
        height: auto;
    }
    
    .main-content {
        grid-column: 1;
        grid-row: 3;
        height: calc(60vh - 120px);
    }
    
    /* Stack the panels in mobile view */
    #search-info, #search-matches, #view-controls-panel {
        position: static;
        width: calc(100% - 30px);
        max-width: none;
        margin: 10px 15px;
        left: auto;
        top: auto;
    }
    
    /* The sidebar bottom should cover the full width */
    .sidebar-bottom {
        left: 0;
        width: 100%;
    }
}

/* Wikidata sidebar styles */
/* Right sidebar for View Controls and Menu */
.sidebar-right {
    position: fixed;
    top: 70px; /* Below header */
    right: -350px; /* Hidden by default */
    width: 350px;
    height: calc(100vh - 70px);
    background-color: #1e1e1e;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: calc(100vh - 70px);
    box-sizing: border-box;
}


.sidebar-right.open {
    right: 0 !important;
}

.sidebar-right:not(.open) {
    right: -350px !important;
    display: none;
}


/* View controls specific styling */
.sidebar-right .view-control-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.sidebar-right .relation-toggle-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Right sidebar accordion styling */
.sidebar-right .accordion {
    margin: 0;
    padding: 15px;
}

.sidebar-right .accordion-item {
    margin-bottom: 10px;
}

.sidebar-right .accordion-header {
    width: 100%;
    background-color: #2a2a2a;
    border: none;
    padding: 10px 12px;
    color: #f0f0f0;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.sidebar-right .accordion-header:hover {
    background-color: #3a3a3a;
}

.sidebar-right .accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: #1e1e1e;
    border-radius: 0 0 4px 4px;
}

.sidebar-right .accordion-content.open {
    max-height: 300px;
    padding: 10px 12px;
    overflow-y: auto;
}

.sidebar-right .accordion-content ul {
    padding-left: 20px;
    margin: 0;
}

.sidebar-right .accordion-content li {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Responsive design for right sidebar */
@media (max-width: 768px) {
    .sidebar-right {
        width: 100%;
        right: -100%;
    }
    
    .sidebar-right.open {
        right: 0 !important;
    }
}

@media (max-width: 1200px) {
    .sidebar-right {
        width: 350px;
        right: -350px;
    }
    
    .sidebar-right.open {
        right: 0 !important;
    }
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #172434;
    border-bottom: 1px solid #344658;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    color: #f8f9fa;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Wikidata button styles */
#show-wikidata-btn {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #264d73;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#show-wikidata-btn:hover {
    background-color: #1e3a57;
}

.wiki-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: #0073aa;
    border-radius: 50%;
    font-weight: bold;
}

/* Wikidata content styles */
#wikidata-details {
    padding: 10px 0;
}

#wikidata-details h4 {
    margin-top: 20px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
    color: #dae6f1;
}

#wikidata-details h4:first-child {
    margin-top: 0;
}

.wikidata-section {
    margin-bottom: 20px;
}

.wikidata-section-title {
    font-weight: bold;
    color: #a2c8e8;
    margin-bottom: 8px;
}

.wikidata-item {
    margin-bottom: 10px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.wikidata-property {
    margin-bottom: 8px;
}

.wikidata-property-name {
    font-weight: bold;
    color: #8caed8;
    margin-right: 5px;
}

.wikidata-image-container {
    margin: 15px 0;
    text-align: center;
}

.wikidata-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
    margin-bottom: 5px;
}

.wikidata-image-caption {
    font-size: 12px;
    color: #a0a0a0;
}


/* External links in Wikidata panel */
.external-link {
    color: #4a9eda;
    text-decoration: none;
    transition: color 0.2s;
    word-break: break-all;
}

.external-link:hover {
    color: #63b8ff;
    text-decoration: underline;
}

/* Bottom sidebar for Node Information */
.sidebar-bottom {
    position: fixed;
    bottom: 0;
    left: 320px; /* Align with the left sidebar */
    width: calc(100% - 320px); /* Extend to the right edge of the screen */
    background-color: rgba(42, 42, 42, 0.95);
    box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.3), 0 0 20px rgba(0, 0, 0, 0.3);
    transition: height 0.3s ease-in-out;
    z-index: 999;
    border-radius: 0; /* Remove border radius */
    transform: none;
    display: flex;
    flex-direction: column;
}

/* Closed state - only show header */
.sidebar-bottom:not(.open) {
    height: 40px; /* Only show the header */
}

/* Open state - expanded to reach under header menu */
.sidebar-bottom.open {
    top: 70px; /* Start right under the header */
    height: calc(100vh - 70px); /* Fill from header to bottom */
    overflow-y: auto;
}

.sidebar-bottom .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: rgba(50, 50, 50, 0.95);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer; /* Make it clickable */
}

.sidebar-bottom .sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

/* Hide the Node Info button as it's no longer needed */
#show-info-btn {
    display: none;
}

/* Media query for mobile view */
@media (max-width: 768px) {
    .sidebar-bottom {
        left: 0;
        width: 100%;
    }
}

/* Hide old side navigation */
#side-nav {
    display: none;
}

/* Base styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #121212;
    color: #f0f0f0;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* App header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background-color: rgba(25, 25, 25, 0.95);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.header-left {
    flex: 1;
    display: flex;
    align-items: center;
    max-width: calc(100% - 150px);
}

.header-right {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    width: 150px;
    max-width: 150px;
    padding-left: 20px;
}

/* Header search container */
.header-search-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 5px 0;
}

.header-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* Search input and controls styling in header */
#search-input {
    flex: 1;
    min-width: 150px;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    background-color: rgba(70, 70, 70, 0.7);
    color: #f0f0f0;
    font-size: 13px;
}

#search-attribute {
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    background-color: rgba(70, 70, 70, 0.7);
    color: #f0f0f0;
    font-size: 13px;
    min-width: 120px;
}

#search-button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background-color: #0056b3;
    color: white;
    cursor: pointer;
    font-size: 13px;
}

#search-button:hover {
    background-color: #007bff;
}

/* Header checkbox style */
.header-checkbox {
    background-color: rgba(70, 70, 70, 0.7);
    padding: 3px 8px;
    border-radius: 15px;
    font-size: 12px;
}

.header-checkbox .checkbox-label {
    font-size: 12px;
    color: #e0e0e0;
}

.header-checkbox:hover {
    background-color: rgba(90, 90, 90, 0.7);
}

/* Control items in header */
.header-search-row .control-item {
    font-size: 12px;
    min-height: 28px;
}

.header-search-row select.control-item {
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    background-color: rgba(70, 70, 70, 0.7);
    color: #f0f0f0;
}

/* Search attribute container with auto-detect indicator */
.search-attribute-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.auto-detect-indicator {
    display: none;
    font-size: 14px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    cursor: help;
}

.auto-detect-indicator.show {
    display: inline-block;
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Menu button */
.menu-button {
    display: flex;
    align-items: center;
    background-color: rgba(60, 60, 60, 0.7);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s;
}

.menu-button:hover {
    background-color: rgba(80, 80, 80, 0.8);
}

/* Menu navigation */
.menu-nav {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    background-color: rgba(30, 30, 30, 0.95);
    overflow-x: hidden;
    transition: width 0.3s ease-in-out;
    padding-top: 60px;
    box-shadow: 3px 0 15px rgba(0, 0, 0, 0.3);
}

.menu-nav.open {
    width: 300px;
}

/* Node tooltip styles */
#node-tooltip {
    position: fixed;
    display: none;
    background-color: rgba(30, 30, 30, 0.9);
    color: #f0f0f0;
    border-radius: 6px;
    padding: 12px;
    max-width: 300px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    font-size: 13px;
    pointer-events: none;
    transition: opacity 0.2s;
    backdrop-filter: blur(3px);
    border: 1px solid rgba(100, 100, 100, 0.5);
}

#node-tooltip h4 {
    margin: 0 0 8px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 16px;
}

#node-tooltip p {
    margin: 4px 0;
    line-height: 1.4;
}

#node-tooltip strong {
    color: #aaa;
    font-weight: normal;
    margin-right: 5px;
}

#node-tooltip span {
    color: #fff;
}

/* Hamburger icon styles */
.hamburger-icon {
    display: flex;
    flex-direction: column;
    margin-right: 8px;
    gap: 4px;
    width: 18px;
}

.hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: white;
    border-radius: 1px;
}

.menu-text {
    font-size: 14px;
    font-weight: 500;
    display: block;
}

/* Accordion styles */
.accordion {
    width: 100%;
    margin-top: 0;
}

.accordion-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.accordion-header {
    width: 100%;
    padding: 15px 20px;
    background: none;
    border: none;
    color: #f8f9fa;
    font-size: 16px;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accordion-header:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0 20px;
    color: #f8f9fa;
    font-size: 14px;
}

.accordion-content p {
    margin: 8px 0;
    font-size: 14px;
    color: #f8f9fa;
    opacity: 0.9;
}

.arrow {
    transition: transform 0.3s ease;
}

/* Close button */
.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 30px;
    color: #f0f0f0;
    background: none;
    border: none;
    cursor: pointer;
}

/* Node info styling */
.node-title {
    font-size: 20px;
    color: #fff;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.node-properties {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Info cards styling adjustments */
.info-card {
    background-color: rgba(42, 42, 42, 0.95);
    border-radius: 6px;
    padding: 12px 15px;
    margin-bottom: 15px;
    z-index: 10;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.info-card h4 {
    font-size: 14px;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: #f0f0f0;
    font-weight: 500;
}

/* Keep search info and matches consistently styled */
#search-info, #search-matches, #view-controls-panel {
    background-color: rgba(42, 42, 42, 0.95);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    padding: 12px 15px;
    border-radius: 6px;
}

#search-info h4, #search-matches h4, #view-controls-panel h4 {
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 8px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

#search-info-content p {
    margin: 4px 0;
    font-size: 13px;
}

/* Fix padding and spacing for neighbor items */
.neighbor-item, .match-item {
    padding: 8px 10px;
    margin-bottom: 6px;
}

.neighbor-kanji, .match-kanji {
    font-size: 15px;
}

/* Update link styles */
.node-link, .neighbor-kanji, .match-kanji {
    color: #9c64ff;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.node-link:hover, .neighbor-kanji:hover, .match-kanji:hover {
    color: #b388ff;
    text-decoration: underline;
}

.view-control-item {
    margin-bottom: 8px;
}

.view-control-item:last-child {
    margin-bottom: 0;
}

.header-checkbox {
    font-size: 0.9em;
    padding: 2px 8px;
    min-width: auto;
}

/* Combined sidebar tabs styling */
.sidebar-tabs {
    display: flex;
    background-color: #333;
    border-bottom: 1px solid #444;
    margin-bottom: 10px;
}

.tab-button {
    padding: 8px 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    flex: 1;
    text-align: center;
    color: #ccc;
}

.tab-button:hover {
    background-color: #444;
}

.tab-button.active {
    background-color: #222;
    font-weight: bold;
    border-bottom: 2px solid #007bff;
    color: #fff;
}

.tab-content {
    display: none;
    padding: 10px;
    font-size: 13px;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #222;
    color: #e0e0e0;
}

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

/* Info button styling */
#show-info-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: rgba(60, 60, 60, 0.9);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#show-info-btn:hover {
    background-color: rgba(80, 80, 80, 0.9);
}

.info-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-weight: bold;
    font-style: italic;
}

/* Combined styles for Wikidata and Gemini content */
#gemini-details, #wikidata-details {
    font-size: 0.95rem;
    color: #e0e0e0;
    width: 100%;
    height: 100%;
}

#gemini-details h4, #wikidata-details h4 {
    color: #ffffff;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 5px;
}

#gemini-details h4:first-child, #wikidata-details h4:first-child {
    margin-top: 0;
}

.gemini-section, .wikidata-section {
    margin-bottom: 20px;
}

.gemini-section-title, .wikidata-section-title {
    font-weight: 600;
    color: #d0d0d0;
    margin-bottom: 10px;
}

.gemini-item, .wikidata-item, .wikidata-property {
    margin-bottom: 15px;
    line-height: 1.5;
    color: #d8d8d8;
}

.usage-example {
    background-color: rgba(60, 60, 60, 0.7);
    padding: 10px;
    border-left: 3px solid rgba(150, 150, 150, 0.5);
    margin-bottom: 10px;
    font-style: italic;
    color: #d8d8d8;
}

/* Bottom sidebar header arrow */
.sidebar-bottom .sidebar-header .arrow {
    transition: transform 0.3s ease;
    font-size: 12px;
    margin-right: 5px;
}

/* Initially set the sidebar to be in closed state */
.sidebar-bottom {
    /* Start in closed state by default */
    height: 40px;
}

/* Set initial transform of arrow */
.sidebar-bottom:not(.open) .arrow {
    transform: rotate(0deg);
}

.sidebar-bottom .sidebar-content {
    flex: 1;
    overflow: hidden; /* Hide overflow at the container level */
    padding: 0; /* Remove padding as it's handled by tab-content */
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    background-color: #333;
    border-bottom: 1px solid #444;
    margin-bottom: 10px;
}

.tab-button {
    padding: 8px 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    flex: 1;
    text-align: center;
    color: #ccc;
}

.tab-button:hover {
    background-color: #444;
}

.tab-button.active {
    background-color: #222;
    font-weight: bold;
    border-bottom: 2px solid #007bff;
    color: #fff;
}

.tab-content {
    display: none;
    padding: 10px;
    font-size: 13px;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #222;
    color: #e0e0e0;
}

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

/* AI Generation Tab Styles */
#ai-generation-details {
    padding: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 0.95rem;
    color: #e0e0e0;
    width: 100%;
    height: 100%;
}

#ai-generation-controls {
    width: 100%;
    overflow-x: hidden;
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 15px;
}

#ai-generation-controls button {
    margin-bottom: 10px;
}

#generation-status {
    width: 100%;
    margin-top: 5px;
    word-break: break-word;
    font-size: 12px;
}

.loading {
    color: #aaa;
    font-style: italic;
}

.success {
    color: #4caf50;
    font-weight: bold;
}

.partial-success {
    color: #ff9800;
    font-weight: bold;
}

.error {
    color: #f44336;
    font-weight: bold;
}

.ai-generation-content h4 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 5px;
}

.generation-item {
    background-color: rgba(60, 60, 60, 0.7);
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 15px;
    border-left: 3px solid #555;
}

.source-lexeme {
    border-left-color: #17a2b8;
}

.synonym-item {
    border-left-color: #4caf50;
}

.antonym-item {
    border-left-color: #f44336;
}

.generation-item p {
    margin: 5px 0;
    font-size: 12px;
    color: #d8d8d8;
    line-height: 1.5;
}

.item-title {
    font-size: 14px !important;
    font-weight: bold;
    margin-bottom: 8px !important;
    color: #fff;
}

.item-hiragana {
    font-size: 12px;
    color: #bbb;
    margin-left: 5px;
}

.item-strength {
    font-size: 11px;
    color: #bbb;
    margin-left: 5px;
}

.no-data {
    color: #aaa;
    font-style: italic;
}

.stats-item {
    background-color: rgba(30, 30, 30, 0.7);
    border-left: 4px solid #007bff;
    margin-bottom: 15px;
    padding: 12px;
}

.stats-item p {
    margin: 5px 0;
    font-size: 13px;
}

.stats-item strong {
    color: #ffffff;
    margin-right: 5px;
}

/* AI Generation results container */
#generation-results {
    width: 100%;
    overflow-x: hidden;
    word-wrap: break-word;
    padding: 0 5px;
}

#generation-results .stats-item {
    margin-bottom: 10px;
}

#update-graph-btn {
    background-color: #28a745;
    color: white;
    margin-left: 8px;
    font-weight: bold;
    display: inline-block;
}

#update-graph-btn:hover {
    background-color: #218838;
}

#update-graph-btn:disabled {
    background-color: #6c757d;
}

/* Lexical Exercise Tab Styles */
#exercises-tab {
    background-color: #181818;
    color: #f8f9fa;
    border-radius: 5px;
    padding: 15px;
}

/* Subtabs for Exercises */
.exercise-subtabs {
    display: flex;
    background-color: #292929;
    border-radius: 5px 5px 0 0;
    overflow: hidden;
    margin-bottom: 15px;
    border: 1px solid #3a3a3a;
}

.subtab-button {
    background-color: transparent;
    border: none;
    padding: 10px 15px;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    flex: 1;
    text-align: center;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.subtab-button:hover {
    background-color: #333;
    color: #fff;
}

.subtab-button.active {
    color: #3498db;
    background-color: #333;
    border-bottom: 3px solid #3498db;
}

.subtab-content {
    display: none;
    margin-bottom: 15px;
}

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

/* Conversation controls */
.conversation-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 15px;
    border-radius: 5px;
    border: 1px solid #3a3a3a;
    background-color: #292929;
    margin-bottom: 15px;
}

#exercises-tab .no-data {
    color: #6c757d;
    font-style: italic;
    padding: 20px;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 5px;
    margin-bottom: 15px;
}

/* Exercise controls bar */
.exercise-controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #292929;
    padding: 10px 15px;
    border-radius: 5px;
    border: 1px solid #3a3a3a;
}

.level-selector {
    display: flex;
    align-items: center;
}

.level-selector label {
    margin-right: 10px;
    font-weight: 600;
    color: #e0e0e0;
}

.level-selector select {
    width: 150px;
    height: 30px;
    padding: 2px 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #333;
    color: #fff;
}

/* Exercise content area */
.exercise-chat-area {
    border: 1px solid #333;
    border-radius: 5px;
    background-color: #222;
    position: relative;
    display: flex;
    flex-direction: column;
}

.exercise-chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

#exercise-input-container {
    position: sticky;
    bottom: 5px;
    background-color: #292929;
    border-top: 1px solid #333;
    padding: 10px;
    z-index: 10;
}

.chat-input-group {
    display: flex;
    gap: 10px;
}

.chat-input-group textarea {
    flex: 1;
    resize: none;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 8px;
    background-color: #333;
    color: #fff;
}

.chat-input-group button {
    height: 38px;
    align-self: flex-end;
}

/* Chat message styles */
.chat-message {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 85%;
    word-wrap: break-word;
}

/* Markdown styles within chat messages */
.chat-message code {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.chat-message pre {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
}

.chat-message pre code {
    background-color: transparent;
    padding: 0;
}

.chat-message h1, 
.chat-message h2, 
.chat-message h3, 
.chat-message h4 {
    margin-top: 15px;
    margin-bottom: 10px;
    font-weight: 600;
}

.chat-message p {
    margin-bottom: 10px;
}

.chat-message ul, 
.chat-message ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

.chat-message table {
    border-collapse: collapse;
    margin: 10px 0;
    width: 100%;
}

.chat-message th, 
.chat-message td {
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 5px 8px;
    text-align: left;
}

.tutor-message {
    align-self: flex-start;
    background-color: #2c4c5e;
    border: 1px solid #386a8c;
    border-top-left-radius: 4px;
    margin-right: auto;
    color: #e0e0e0;
}

.user-message {
    align-self: flex-end;
    background-color: #2e4c38;
    border: 1px solid #386a45;
    border-bottom-right-radius: 4px;
    margin-left: auto;
    color: #e0e0e0;
}

/* Status indicator */
#exercise-status {
    margin-bottom: 15px;
    font-size: 0.9em;
    color: #aaa;
}

/* Loading spinner for exercise generation */
.exercise-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: #3498db;
    animation: spin 1s ease-in-out infinite;
    margin-left: 10px;
}

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

/* Ensure the side navigation panel opens correctly */
#side-nav.open {
    width: 300px; /* Override the default width: 0 from the base #side-nav rule */
    left: auto;   /* Override .menu-nav's left: 0 to avoid conflicting with right: 0 */
}

/* Readability Display Styling */
.readability-info {
    margin: 10px 0;
    background-color: rgba(42, 42, 42, 0.9);
    border-radius: 6px;
    padding: 8px 12px;
    border-left: 4px solid #007bff;
    transition: all 0.3s ease-in-out;
    opacity: 0;
    transform: translateY(-10px);
}

.readability-info.show {
    opacity: 1;
    transform: translateY(0);
}

.readability-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.readability-label {
    color: #cccccc;
    font-size: 12px;
    font-weight: 500;
}

.readability-level {
    background-color: #007bff;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 70px;
    text-align: center;
}

.readability-score {
    color: #ffffff;
    font-size: 11px;
    font-weight: 500;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 8px;
}

/* Color coding for different readability levels */
.readability-level.upper-advanced {
    background-color: #8B0000;
}

.readability-level.lower-advanced {
    background-color: #FF4500;
}

.readability-level.upper-intermediate {
    background-color: #FF8C00;
}

.readability-level.lower-intermediate {
    background-color: #FFD700;
    color: #333333;
}

.readability-level.upper-elementary {
    background-color: #9ACD32;
    color: #333333;
}

.readability-level.lower-elementary {
    background-color: #32CD32;
    color: #333333;
}

.readability-level.out-of-range {
    background-color: #808080;
}

/* Responsive design for readability badge */
@media (max-width: 480px) {
    .readability-badge {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .readability-level {
        min-width: auto;
    }
}