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

/* ── Base ────────────────────────────────────────────────────────── */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
    background: #e8e8e8;
    width: 100vw;
    height: 100vh;
}

/* ── Toolbar (fixed top bar) ─────────────────────────────────────── */
#toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.toolbar-left {
    display: flex;
    align-items: center;
}

.app-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    user-select: none;
}

.app-title:hover {
    opacity: 0.85;
}

.toolbar-section-btn {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    background: #3d566e;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.toolbar-section-btn:hover {
    background: #4a6d8c;
}

.board-name-display {
    color: #ecf0f1;
    font-size: 14px;
    font-weight: 600;
    margin-left: 10px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: #4a6d8c;
    margin: 0 12px;
}

#addNoteBtn {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    background: #f39c12;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

#addNoteBtn:hover {
    background: #e67e22;
}

.mode-btn {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    margin-left: 8px;
}

.mode-btn:hover {
    background: #2980b9;
}

.mode-btn.active {
    background: #1a5276;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.hint {
    color: #bdc3c7;
    font-size: 13px;
    margin-left: 12px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    margin-left: auto;
    gap: 4px;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    font-size: 18px;
    font-weight: 700;
    background: #3d566e;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}

.zoom-btn:hover {
    background: #4a6d8c;
}

#zoomLabel {
    color: #bdc3c7;
    font-size: 13px;
    min-width: 42px;
    text-align: center;
}

/* ── Board Panel (slide-out sidebar) ────────────────────────────── */

/* Semi-transparent backdrop — closes the panel on click */
.board-panel-backdrop {
    display: none;
}

.board-panel-backdrop.visible {
    display: block;
}

.board-panel {
    position: fixed;
    top: 48px;
    left: -300px;
    width: 280px;
    bottom: 0;
    background: #fff;
    z-index: 50;
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    transition: left 0.25s ease;
}

.board-panel.visible {
    left: 0;
}

.board-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.board-panel-header h3 {
    font-size: 16px;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.close-btn:hover {
    color: #333;
}

.new-board-btn {
    margin: 12px 16px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    text-align: center;
}

.new-board-btn:hover {
    background: #219a52;
}

.board-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.board-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.1s;
}

.board-item:hover {
    background: #f5f5f5;
}

.board-item.active {
    background: #e8f4fd;
    border-left: 3px solid #3498db;
    padding-left: 13px;
}

.board-item-name {
    flex: 1;
    font-size: 14px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

.board-item.active .board-item-name {
    font-weight: 600;
    color: #2c3e50;
}

.board-item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}

.board-item:hover .board-item-actions {
    opacity: 1;
}

.board-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: #999;
    cursor: pointer;
    border-radius: 4px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, color 0.1s;
}

.board-action-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.board-action-btn.danger:hover {
    background: #fde8e8;
    color: #c0392b;
}

.board-rename-input {
    flex: 1;
    font-size: 14px;
    font-family: inherit;
    padding: 2px 6px;
    border: 2px solid #3498db;
    border-radius: 4px;
    outline: none;
    margin-right: 8px;
}

/* ── Dark Theme Overrides ────────────────────────────────────────── */

/* ── Dark Theme Overrides ────────────────────────────────────────── */

/* Board panel dark mode */
[data-theme="dark"] .board-panel {
    background: #2a2a3a;
    box-shadow: 4px 0 16px rgba(0,0,0,0.4);
}

[data-theme="dark"] .board-panel-header {
    border-bottom-color: #444;
}

[data-theme="dark"] .board-panel-header h3 {
    color: #ddd;
}

[data-theme="dark"] .close-btn {
    color: #888;
}

[data-theme="dark"] .close-btn:hover {
    color: #ddd;
}

[data-theme="dark"] .new-board-btn {
    background: #27ae60;
}

[data-theme="dark"] .board-item:hover {
    background: #333348;
}

[data-theme="dark"] .board-item.active {
    background: #1a3a5a;
    border-left-color: #5ba3e6;
}

[data-theme="dark"] .board-item-name {
    color: #ddd;
}

[data-theme="dark"] .board-item.active .board-item-name {
    color: #fff;
}

[data-theme="dark"] .board-action-btn {
    color: #888;
}

[data-theme="dark"] .board-action-btn:hover {
    background: #3a3a4a;
    color: #ddd;
}

[data-theme="dark"] .board-action-btn.danger:hover {
    background: #3a2020;
    color: #e74c3c;
}

[data-theme="dark"] .board-rename-input {
    background: #1a1a2e;
    border-color: #5ba3e6;
    color: #ddd;
}

[data-theme="dark"] .board-panel-backdrop {
    background: rgba(0,0,0,0.5);
}

/* ── Context Menus ──────────────────────────────────────────────── */

/* Shared base styles for note, connection, and canvas context menus */
.context-menu {
    position: fixed;
    display: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.1);
    min-width: 180px;
    padding: 4px 0;
    z-index: 100;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.context-menu.visible {
    display: block;
}

.context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    position: relative;
    color: #333;
}

.context-menu-item:hover {
    background: #f0f0f0;
}

.context-menu-item.danger {
    color: #c0392b;
}

.context-menu-item.danger:hover {
    background: #fde8e8;
}

.context-menu-icon {
    width: 22px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
}

.context-menu-separator {
    height: 1px;
    background: #e0e0e0;
    margin: 4px 0;
}

.context-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: -4px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.1);
    padding: 8px;
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    min-width: 120px;
}

.has-submenu:hover > .context-submenu {
    display: grid;
}

.context-color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

.context-color-option:hover {
    transform: scale(1.2);
}

.context-theme-submenu {
    grid-template-columns: 1fr;
    min-width: 140px;
}

.context-theme-option {
    padding: 8px 14px;
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
    font-size: 13px;
    color: #333;
}

.context-theme-option:hover {
    background: #f0f0f0;
}

.context-theme-option.active {
    background: #e8f4fd;
    font-weight: 600;
}

.context-shape-submenu {
    grid-template-columns: 1fr;
    min-width: 140px;
}

.context-shape-option {
    padding: 8px 14px;
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
    font-size: 13px;
    color: #333;
}

.context-shape-option:hover {
    background: #f0f0f0;
}

.context-shape-option.active {
    background: #e8f4fd;
    font-weight: 600;
}

/* Context menu dark mode */
[data-theme="dark"] .context-menu {
    background: #2a2a3a;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.3);
}

[data-theme="dark"] .context-menu-item {
    color: #ddd;
}

[data-theme="dark"] .context-menu-item:hover {
    background: #3a3a4a;
}

[data-theme="dark"] .context-menu-item.danger {
    color: #e74c3c;
}

[data-theme="dark"] .context-menu-item.danger:hover {
    background: #3a2020;
}

[data-theme="dark"] .context-menu-separator {
    background: #444;
}

[data-theme="dark"] .context-submenu {
    background: #2a2a3a;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.3);
}

[data-theme="dark"] .context-theme-option {
    color: #ddd;
}

[data-theme="dark"] .context-theme-option:hover {
    background: #3a3a4a;
}

[data-theme="dark"] .context-theme-option.active {
    background: #1a3a5a;
}

[data-theme="dark"] .context-shape-option {
    color: #ddd;
}

[data-theme="dark"] .context-shape-option:hover {
    background: #3a3a4a;
}

[data-theme="dark"] .context-shape-option.active {
    background: #1a3a5a;
}

[data-theme="dark"] body {
    background: #1a1a2e;
}

/* ── Canvas ──────────────────────────────────────────────────────── */
#canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    cursor: default;
}

/* ── Toast Notification (slides up from bottom) ─────────────────── */
#toast {
    position: fixed;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: bottom 0.3s ease;
    white-space: nowrap;
}

#toast.visible {
    bottom: 24px;
}

[data-theme="dark"] #toast {
    background: #3d566e;
}

/* ── About Modal ────────────────────────────────────────────────── */

/* Modal backdrop overlay */
.about-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    display: none;
}

.about-modal-backdrop.visible {
    display: block;
}

.about-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    z-index: 201;
    width: 90%;
    max-width: 480px;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.about-modal.visible {
    display: flex;
}

.about-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.about-modal-header h2 {
    font-size: 18px;
    color: #2c3e50;
    margin: 0;
}

.about-modal-body {
    padding: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #444;
}

.about-modal-body p {
    margin-bottom: 12px;
}

.about-modal-body p:last-child {
    margin-bottom: 0;
}

/* About modal dark mode */
[data-theme="dark"] .about-modal {
    background: #2a2a3a;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

[data-theme="dark"] .about-modal-header {
    border-bottom-color: #444;
}

[data-theme="dark"] .about-modal-header h2 {
    color: #ddd;
}

[data-theme="dark"] .about-modal-body {
    color: #ccc;
}

[data-theme="dark"] .about-modal-backdrop {
    background: rgba(0,0,0,0.6);
}
