/* hyperlink styles */
a {
    color: #00e5ff;
}

a:visited {
    color: #00e5ff;
}

a:hover {
    color: #7df5ff;
}
/* general styles */
body {
    background: #000000;
    color: white;
    font-family: Arial;
}
#centerNode {
    width: auto;
    margin-top: 4px;
    padding: 8px;
    background: #444;
    border-radius: 10px;
}
/* search input and related nodes */
#searchInput {
    display: block;
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    border: 1px solid #fffb00;
    border-radius: 20px;
}
#relatedNodes {
    display: flex;
    justify-content: left;
    margin-top: 4px;
    margin-bottom: 4px;
    text-align: center;
}
.relatedNode {
    padding: 10px 12px;
    border-radius: 20px;
    margin-right: 5px;
    margin-left: 5px;
    margin-bottom: 5px;
    border: none;
    cursor: pointer;
    background: #fffb00;
}
/* graph container and graph styles */
#graphContainer { display:flex; justify-content:center; margin:10px 0; }
#graph { width: 90%; height: 90%; background: #111; border-radius: 12px; box-shadow: 0 0 10px rgba(0,0,0,0.6); }
#graph svg { width: 100%; height: 100%; }
#graph .nodes text { font-size: 12px; fill: #fffb00; pointer-events: none; }
#graph .links line { stroke: #fff; stroke-opacity: 0.8; }

/* Two-column layout: left 2/3 graph, right 1/3 controls */
#layout { display: flex; gap: 16px; padding: 16px; box-sizing: border-box; height: 95vh; }
#leftPane { flex: 2; display: flex; }
#rightPane { flex: 1; display: flex; flex-direction: column; max-width: 420px; }
#controls { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
#controls input#searchInput { flex: 1; }
#controls button,
#searchPanel button {
    padding: 8px 10px;
    border-radius: 10px;
    background: #222;
    color: #fffb00;
    border: 1px solid #444;
    cursor: pointer;
}
/* Buttons for editing, saving, and canceling */
#editButton,
#saveButton,
#cancelButton {
    padding: 8px 12px;
    border-radius: 12px;
    border: 2px solid #111;
    cursor: pointer;
}
#editButton:hover,
#saveButton:hover,
#cancelButton:hover {
    background: #fffb00;
}

/* Order of elements in the right pane */
#centerNode { order: 1; overflow-y: auto; max-height: calc(95vh - 220px); }
#relatedNodes { order: 2; display:flex; flex-wrap:wrap; justify-content:flex-start; padding: 8px; }
#graph { height: calc(100vh - 64px); }
#searchPanel { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; justify-content: space-between; }
#searchPanel #searchInput { flex: 1; }
#searchPanel #newNodeButton { flex-shrink: 0; }
/* Proposal panel styles */
#proposalPanel {
    background: #222;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 0 12px rgba(0,0,0,0.35);
}

/* Proposal panel hidden state */
#proposalPanel.hidden {
    display: none;
}

.panel-header, .proposal-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

#proposalPanel h2,
#proposalPanel h3 {
    margin: 0;
    font-size: 1rem;
}

#proposalPanel textarea,
#proposalPanel input {
    width: 100%;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #444;
    background: #111;
    color: #fff;
    box-sizing: border-box;
}

#proposalPanel button {
    padding: 8px 12px;
    border-radius: 10px;
    background: #222;
    color: #fffb00;
    border: 1px solid #fffb00;
    cursor: pointer;
}

.proposal-list {
    max-height: 260px;
    overflow-y: auto;
    display: grid;
    gap: 10px;
}

.proposal-card {
    background: #111;
    border: 1px solid #444;
    border-radius: 10px;
    padding: 12px;
}

.proposal-card .meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
    align-items: center;
}

.proposal-card .meta span {
    font-size: 12px;
    color: #ccc;
}

.proposal-card .proposal-message {
    margin-bottom: 10px;
    white-space: pre-wrap;
}

.proposal-card .proposal-actions {
    display: flex;
    gap: 8px;
}

.proposal-card button {
    flex: 1;
}

.proposal-diff {
    display: grid;
    gap: 6px;
}

.line-diff {
    border: 1px solid #444;
    border-radius: 6px;
    overflow: hidden;
    font-family: monospace;
    white-space: pre-wrap;
}

.line-diff > div {
    padding: 3px 7px;
}

.diff-old {
    color: #ffb3b3;
    background: rgba(180, 40, 40, 0.2);
    text-decoration: line-through;
}

.diff-new {
    color: #b8ffb8;
    background: rgba(40, 160, 70, 0.22);
}

.diff-same {
    color: #ddd;
}

.review-warning {
    color: #ffcb70;
}

/* Readonly input styling */
input.readonly {
    background: #222; 
    color: #bbb;
    border-color: #666;
    cursor: not-allowed;
}

/* Disabled new node button */
#newNodeButton:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: #222;
    color: #888;
    border-color: #444;
}

/* Search input states */
#searchInput.search-match { box-shadow: 0 0 6px rgba(0,255,0,0.12); border-color: #0f0; }
#searchInput.search-new { box-shadow: 0 0 6px rgba(255,255,0,0.08); border-color: #fffb00; }

.readonly { opacity: 0.9; }

/* Edit panel links selector */
#editLinksPanel {
    margin: 10px 0;
    padding: 8px;
    background: #333;
    border-radius: 8px;
}

#editLinksPanel label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    color: #fffb00;
}

#editLinksSearch {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid #666;
    border-radius: 6px;
    background: #222;
    color: #fff;
    font-size: 13px;
    box-sizing: border-box;
}

#editLinksList {
    max-height: 120px;
    overflow-y: auto;
    margin-bottom: 8px;
    padding: 4px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #1a1a1a;
}

.link-option {
    padding: 6px 10px;
    margin: 2px 0;
    background: #222;
    border: 1px solid #666;
    border-radius: 4px;
    cursor: pointer;
    color: #ccc;
    font-size: 13px;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.link-option input[type="checkbox"] {
    cursor: pointer;
}

.link-option:hover {
    background: #333;
    border-color: #fffb00;
}

#editSelectedLinks {
    margin: 8px 0;
    padding: 8px;
    background: #222;
    border-radius: 6px;
    min-height: 30px;
}

.selected-link-tag {
    display: inline-block;
    background: #fffb00;
    color: #000;
    padding: 4px 8px;
    margin: 2px 4px 2px 0;
    border-radius: 12px;
    font-size: 12px;
    cursor: default;
}

.selected-link-tag button {
    background: none;
    border: none;
    color: #000;
    cursor: pointer;
    margin-left: 4px;
    font-weight: bold;
    padding: 0;
}

.selected-link-tag button:hover {
    color: #666;
}

/* Mobile Responsive Design - Tablets and below (768px and smaller) */
@media (max-width: 768px) {
    /* Stack layout vertically */
    #layout {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
        height: auto;
        min-height: 100vh;
    }

    #leftPane {
        flex: 0;
        min-height: 300px;
        width: 100%;
    }

    #rightPane {
        flex: 1;
        max-width: none;
        width: 100%;
    }

    /* Increase touch-friendly button sizes */
    #controls button,
    #searchPanel button,
    button {
        padding: 12px 14px;
        font-size: 14px;
        min-height: 44px;
    }

    /* Make search input larger and easier to tap */
    #searchInput {
        padding: 12px 14px;
        font-size: 16px;
        min-height: 44px;
    }

    /* Adjust graph height for mobile */
    #graph {
        height: 300px;
    }

    /* Adjust centerNode max-height for mobile */
    #centerNode {
        max-height: none;
        overflow-y: visible;
    }

    /* Adjust margins and padding */
    #controls {
        margin-bottom: 8px;
        flex-wrap: wrap;
    }

    #searchPanel {
        margin-bottom: 8px;
    }

    /* Make sure edit panel is readable on mobile */
    #editPanel input,
    #editPanel textarea {
        font-size: 16px;
        padding: 12px;
    }

    /* Related nodes should wrap better on mobile */
    #relatedNodes {
        padding: 4px;
    }

    /* Adjust proposal panel for mobile */
    #proposalPanel {
        padding: 10px;
    }

    /* Increase button sizes in proposal panel */
    #proposalPanel button {
        min-height: 44px;
        padding: 12px;
    }
}

/* Extra small devices (phones under 480px) */
@media (max-width: 480px) {
    #layout {
        padding: 4px;
        gap: 4px;
    }

    #leftPane {
        min-height: 250px;
    }

    #graph {
        height: 250px;
    }

    /* Stack buttons vertically on very small screens */
    #controls {
        flex-direction: column;
        gap: 4px;
    }

    #controls button {
        width: 100%;
    }

    #searchPanel {
        flex-direction: column;
        gap: 4px;
    }

    #searchPanel #searchInput {
        width: 100%;
    }

    #searchPanel #newNodeButton {
        width: 100%;
    }
}
