/* --- Global Styles --- */
html, body {
    height: 100%;
}

body {
    font-family: sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

button:hover {
    cursor: pointer;
}

/* --- Main Layout --- */
#toolbar {
    padding: 10px;
    background: #f0f0f0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

#session-title {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    min-width: 80px;
    flex: 1 1 80px;
}

.toolbar-divider {
    width: 1px;
    background-color: #ccc;
    align-self: stretch;
    margin: 0 5px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.zoom-controls button {
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

#zoom-display {
    width: 48px;
    padding: 4px 4px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    -moz-appearance: textfield;
}

#zoom-display::-webkit-outer-spin-button,
#zoom-display::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

#scale-wrapper {
    position: relative;
    transform-origin: top left;
}

#main-area {
    display: flex;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

#card-container {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    background-color: #fffbe6;
    background-image:
        linear-gradient(0deg, #b4a06426 1px, transparent 1px),
        linear-gradient(90deg, #b4a06426 1px, transparent 1px);
    background-size: 25px 25px;
    overflow: auto;
}

#card-container.no-background {
    background-image: none;
}

#notes-panel {
    display: none;
    flex-direction: column;
    width: 40%;
    min-width: 180px;
    max-width: 480px;
    flex-shrink: 0;
    border-left: 1px solid #ddd;
    background: #fafafa;
    overflow: hidden;
}

#notes-panel.open {
    display: flex;
}

#notes-panel-header {
    padding: 8px 12px;
    font-weight: bold;
    font-size: 13px;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
    color: #444;
}

#notes-textarea {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    border: none;
    background: transparent;
    font-family: sans-serif;
    font-size: 14px;
    resize: none;
    outline: none;
}

/* --- Card Component --- */
.card {
    position: absolute;
    width: 190px;
    min-width: 150px;
    min-height: 100px;
    padding: 0;
    background: #fff;
    border: 2px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card .drag-bar {
    width: 100%;
    height: 24px;
    background: linear-gradient(180deg, rgba(0,0,0,0.03) 0%, rgba(0,0,0,0.06) 100%);
    border-radius: 6px 6px 0 0;
    cursor: grab;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    box-sizing: border-box;
}

.card .drag-bar:hover {
    background: linear-gradient(180deg, rgba(0,0,0,0.06) 0%, rgba(0,0,0,0.1) 100%);
}

.card .drag-bar::before,
.card .drag-bar::after {
    content: '';
    width: calc(100% - 16px);
    height: 2px;
    background: rgba(0,0,0,0.15);
    border-radius: 1px;
}

.card .drag-bar:hover::before,
.card .drag-bar:hover::after {
    background: rgba(0,0,0,0.25);
}

.card .card-content {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card .card-title {
    font-weight: bold;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    padding-left: 20px; /* Added to make room for the delete button */
    min-height: 20px;
}

.card.nucleus {
    border-color: #f39c12;
    border-width: 3px;
}

.card.selected {
    border-color: #3498db;
    border-width: 3px;
    box-shadow: 0 0 0 2px #3498db55;
}

#select-mode-btn.active {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

.card .card-blurb {
    margin-bottom: 8px;
    font-size: 0.9em;
    min-height: 20px;
    cursor: pointer;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 75%;
    overflow-y: auto;
}

.card .connection-pad {
    margin-top: 10px;
    padding: 8px 10px;
    background: #eef2ff;
    border: 2px dashed #a5b4fc;
    border-radius: 6px;
    text-align: center;
    font-size: 0.85em;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    touch-action: none;
    color: #3730a3;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.card .connection-pad-icon {
    font-size: 1.1em;
}

.card .connection-pad.press-ready {
    border-style: solid;
    border-color: #6366f1;
    background: #e0e7ff;
}

.card .connection-pad.active {
    border-color: #4338ca;
    background: #c7d2fe;
    color: #1e1b4b;
    transform: scale(1.02);
}

.card .tags {
    margin-top: 5px;
}

.card input {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 0.8em;
}

.card .delete-btn {
    position: absolute;
    top: 29px;
    left: 8px;
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    color: #cccccc;
    line-height: 1;
}

.card .delete-btn:hover {
    color: #e74c3c; /* Red on hover */
}

.card .duplicate-btn {
    position: absolute;
    top: 30px;
    right: 8px;
    cursor: pointer;
    font-size: 20px;
    color: #cccccc;
    line-height: 1;
    user-select: none;
}

.card .duplicate-btn:hover {
    color: #3498db;
}

.card .resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 10;
}

.card .resize-handle::before {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 12px 12px;
    border-color: transparent transparent rgba(0,0,0,0.2) transparent;
}

.card .resize-handle:hover::before {
    border-color: transparent transparent rgba(0,0,0,0.4) transparent;
}

/* --- Tag Component --- */
.tag {
    display: inline-block;
    background: #ddd;
    padding: 2px 6px;
    margin: 2px;
    border-radius: 4px;
    font-size: 0.8em;
    cursor: pointer;
}

.tag.add-tag-btn {
    background: #e0e0e0;
    border: 1px dashed #aaa;
}

.tag:hover {
    background: #ccc;
}

/* --- Color Palette --- */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid #ccc;
    transition: transform 0.2s;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.selected {
    border: 2px solid #3498db;
}

/* --- Connection Layer --- */
.connection-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: auto;
    z-index: 0;
}

.connector-path {
    stroke: #555;
    stroke-width: 2px;
    fill: none;
    pointer-events: stroke;
    transition: stroke 0.2s;
}

.connector-path:hover {
    stroke: #2c3e50;
}

.connector-label {
    fill: #2c3e50;
    font-size: 12px;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
}

.connector-node {
    cursor: pointer;
    transition: transform 0.2s;
}

.connector-node:hover {
    transform: scale(1.04);
}

.connector-node-bg {
    fill: #f4f6fb;
    stroke: #4a6fa5;
    stroke-width: 1.5px;
    opacity: 0.95;
}

.connector-node:hover .connector-node-bg {
    fill: #e3ecff;
}

.connector-node-active .connector-node-bg {
    fill: #d4e4ff;
    stroke: #1e4d8f;
}

.connector-node-active {
    transform: scale(1.08);
}

.temp-connector {
    stroke-dasharray: 6 4;
    opacity: 0.7;
}

/* --- Modal Component --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 20px 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
}

.modal-content.blurb-modal-content {
    resize: both;
    overflow: hidden;
    width: 50vw;
    max-width: 90vw;
    min-width: 30vw;
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.blurb-modal-content #blurb-textarea {
    flex: 1;
    min-height: 80px;
    resize: none;
}

.modal-content h2 {
    margin-top: 0;
}

.modal-content label {
    font-weight: bold;
    display: block;
    margin-top: 15px;
    margin-bottom: 5px;
}

.modal-content label.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.modal-content textarea {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: sans-serif;
    font-size: 14px;
    resize: vertical;
    min-height: 120px;
}

.modal-content.about-modal {
    text-align: center;
}

.modal-content.about-modal p {
    margin: 10px 0;
}

.modal-content.about-modal p.about-credit {
    margin-top: 20px;
}

.about-github-link {
    color: #3498db;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
    margin-right: auto;
}

.about-github-link:hover {
    text-decoration: underline;
}

.modal-content.about-modal a {
    color: #3498db;
    text-decoration: none;
    font-weight: bold;
}

.modal-content.about-modal a:hover {
    text-decoration: underline;
}

#format-options {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.filter-container {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid #eee;
    padding: 10px;
    margin-top: 5px;
}

.filter-container .tag-option {
    display: block;
}

.filter-container .color-option {
    display: inline-block;
    width: 25px;
    height: 25px;
    margin-right: 5px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
}

.filter-container .color-option.selected {
    border-color: #3498db;
}

.modal-actions {
    margin-top: 20px;
    text-align: right;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* --- UI Enhancements --- */
.file-input-label {
    padding: 1px 6px;
    border-width: 2px;
    border-style: outset;
    border-color: buttonborder;
    border-image: initial;
}
