/* ============================================================
   Multi-Board Paragon Planner
   Zoomable/pannable surface with multiple connected boards
   ============================================================ */

/* --- Container --- */
.mp-container {
    display: flex;
    flex-direction: column;
    height: min(850px, calc(100vh - 180px));
    min-height: 450px;
    position: relative;
}

/* --- Viewport (overflow hidden, receives events) --- */
.mp-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: #1A1B1F;
    border: 1px solid #252830;
    border-radius: 0 0 8px 8px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    min-height: 600px;
}

.mp-viewport--grabbing {
    cursor: grabbing;
}

/* --- Surface (pannable/zoomable) --- */
.mp-surface {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
}

/* --- Board --- */
.mp-board {
    position: absolute;
    border: 1px solid rgba(200, 60, 40, 0.6);
    border-radius: 0;
    background: transparent;
}

.mp-board__header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: #13151a;
    border-bottom: 1px solid #2a2a35;
    border-radius: 4px 4px 0 0;
    height: 36px;
    white-space: nowrap;
    overflow: hidden;
}

.mp-board__name {
    color: #c4a24e;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-board__glyph-badge {
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    flex-shrink: 0;
}

.mp-board__lvl-btn {
    width: 18px;
    height: 18px;
    border: 1px solid rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.1);
    color: #c4b5fd;
    font-size: 12px;
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    vertical-align: middle;
}

.mp-board__lvl-btn:hover {
    background: rgba(139, 92, 246, 0.3);
    color: #fff;
}

.mp-board__glyph-level {
    display: inline-block;
    min-width: 20px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.mp-board__controls {
    display: flex;
    gap: 3px;
    margin-left: auto;
    flex-shrink: 0;
}

.mp-board__btn {
    width: 26px;
    height: 26px;
    border: 1px solid #3a3a48;
    background: #1a1a24;
    color: #a0a0a0;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.mp-board__btn:hover {
    background: #2a2a38;
    color: #e0ddd5;
}

.mp-board__btn--remove:hover {
    background: #4a1a1a;
    color: #ff5040;
    border-color: #cc2020;
}

.mp-board__btn--rotate {
    width: auto;
    padding: 0 6px;
    font-size: 10px;
    gap: 2px;
}

.mp-board__btn--glyph {
    font-size: 14px;
}

/* --- Board Label (translucent overlay) --- */
.mp-board__label {
    position: absolute;
    top: 4px;
    left: 8px;
    z-index: 12;
    color: #ffffff;
    font-family: 'Roboto', sans-serif;
    font-size: 9px;
    font-weight: 400;
    background: rgba(20, 20, 30, 0.85);
    padding: 1px 5px;
    border-radius: 3px;
    pointer-events: none;
    white-space: nowrap;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mp-board__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 8px;
    font-weight: 400;
    line-height: 1;
}

.mp-board__label-glyph {
    color: #c4a24e;
    font-weight: 500;
}

.mp-board__label-sep {
    color: #3a3a48;
    margin: 0 2px;
}

.mp-board__label-stat {
    color: #a0a090;
    font-weight: 400;
    margin-right: 4px;
}

/* --- Board Controls (always visible, edit mode only) --- */
.mp-board__controls {
    position: absolute;
    top: 4px;
    right: 8px;
    z-index: 12;
    display: flex;
    gap: 4px;
    align-items: center;
}

.mp-board__controls button {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #3a3a48;
    background: rgba(20, 20, 30, 0.85);
    color: #ffffff;
    font-family: 'Roboto', sans-serif;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: all 0.15s;
}

.mp-board__controls button:hover {
    background: rgba(196, 162, 78, 0.15);
    border-color: #c4a24e;
    box-shadow: 0 0 8px rgba(196, 162, 78, 0.3);
}

.mp-board__controls button[data-action="remove"]:hover {
    background: rgba(255, 60, 60, 0.15);
    border-color: #cc2020;
    color: #ff5040;
    box-shadow: 0 0 8px rgba(255, 60, 60, 0.3);
}

/* --- Glyph Info Badge (on board) --- */
.mp-board__glyph-info {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
    background: rgba(13, 13, 20, 0.85);
    color: #8b5cf6;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    pointer-events: none;
    white-space: nowrap;
}

/* --- Board Grid Mount --- */
.mp-board__grid {
    width: 756px;
    height: 756px;
    position: relative;
    overflow: visible;
}

.mp-board__no-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #7a7870;
    font-size: 14px;
}

/* --- Embedded Grid Overrides --- */
.pb-grid--embedded {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    transform: none !important;
}

/* --- Gate Add Buttons --- */
.mp-gate-add {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px dashed #3a3a48;
    background: rgba(20, 20, 30, 0.85);
    color: #c4a24e;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
    padding: 0;
    line-height: 1;
}

.mp-gate-add:hover {
    border-color: #c4a24e;
    background: rgba(196, 162, 78, 0.15);
    box-shadow: 0 0 12px rgba(196, 162, 78, 0.3);
    transform: scale(1.15);
}

/* --- Connection Lines --- */
.mp-connection {
    position: absolute;
    background: rgba(60, 60, 80, 0.3);
    z-index: 0;
}

/* --- Toolbar (top bar above viewport) --- */
.mp-toolbar {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: #1A1B1F;
    border: 1px solid var(--border-color, #252830);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    font-size: 12px;
    color: #e0ddd5;
    flex-shrink: 0;
    gap: 8px;
    position: relative;
}

.mp-toolbar__glyphs {
    display: flex;
    align-items: center;
    gap: 2px;
    border: 1px solid #3a3a48;
    background: #1a1a24;
    border-radius: 4px;
    padding: 0 4px;
    height: 40px;
    box-sizing: border-box;
}

.mp-toolbar__separator {
    color: #3a3a48;
}

.mp-toolbar__points {
    font-size: 14px;
    color: #e0ddd5;
    border: 1px solid #3a3a48;
    background: #1a1a24;
    border-radius: 4px;
    padding: 0 10px;
    height: 40px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.mp-toolbar__points strong {
    color: #c4a24e;
}

.mp-toolbar__remaining {
    color: #7a7870;
    font-size: 12px;
}

.mp-toolbar__glyph-tag {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid rgba(139, 92, 246, 0.25);
    white-space: nowrap;
}

.mp-toolbar__no-glyphs {
    color: #5a5a5a;
    font-style: italic;
    font-size: 11px;
}

/* (toolbar items are direct flex children now) */

/* Zoom level overlay (bottom-right of viewport) */
.mp-zoom-overlay {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 12;
    font-size: 12px;
    color: #7a7870;
    background: rgba(15, 16, 20, 0.75);
    padding: 2px 8px;
    border-radius: 3px;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}

/* Glyph circles in toolbar */
.mp-toolbar__glyph-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid rgba(139, 92, 246, 0.5);
    background: rgba(139, 92, 246, 0.1);
    color: #c4b5fd;
    font-size: 9px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    flex-shrink: 0;
}

.mp-toolbar__glyph-circle:has(.mp-toolbar__glyph-icon) {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
}

.mp-toolbar__glyph-circle--empty {
    border-color: rgba(100, 100, 110, 0.3);
    background: transparent;
    color: #5a5a5a;
}

.mp-toolbar__glyph-icon {
    width: 44px;
    height: 44px;
    object-fit: cover;
}

/* Toolbar action buttons (reset, fullscreen) */
.mp-toolbar__btn {
    width: 40px;
    height: 40px;
    border: 1px solid #3a3a48;
    background: #1a1a24;
    color: #e0ddd5;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    box-sizing: border-box;
}

.mp-toolbar__btn:hover {
    background: #2a2a38;
    border-color: #555;
}

.mp-toolbar__btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.mp-toolbar__separator {
    color: #3a3a48;
}

/* --- Fullscreen mode --- */
.mp-container--fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    height: 100vh !important;
    border-radius: 0;
    background: #0a0a0f;
}

.mp-container--fullscreen .mp-viewport {
    border-radius: 0;
    min-height: auto;
}

.mp-container--fullscreen .mp-toolbar {
    border-radius: 0;
}

body.mp-fullscreen-active .site-header,
body.mp-fullscreen-active .site-footer,
body.mp-fullscreen-active .build-editor__header,
body.mp-fullscreen-active .build-editor__sub-bar,
body.mp-fullscreen-active .editor-tabs,
body.mp-fullscreen-active .build-editor__save-bar {
    display: none !important;
}

/* --- Toolbar Toggle (Leveling Path) --- */
.mp-toolbar__left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 8px;
}

.mp-toolbar__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    border: 1px solid #3a3a48;
    background: #1a1a24;
    border-radius: 4px;
    padding: 0 18px;
    height: 40px;
    box-sizing: border-box;
}

/* Node search */
.mp-toolbar__search {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #3a3a48;
    background: #1a1a24;
    border-radius: 4px;
    padding: 0 10px;
    height: 40px;
    box-sizing: border-box;
    flex: 1;
    min-width: 0;
}

.mp-toolbar__search-icon {
    font-size: 14px;
    opacity: 0.5;
    flex-shrink: 0;
}

.mp-toolbar__search-input {
    background: transparent;
    border: none;
    outline: none;
    color: #e0ddd5;
    font-size: 14px;
    width: 100%;
    min-width: 0;
    padding: 0;
    font-family: inherit;
}

.mp-toolbar__search-input::placeholder {
    color: #5a5a5a;
}

.mp-toolbar__toggle-input {
    display: none;
}

.mp-toolbar__toggle-switch {
    width: 34px;
    height: 18px;
    border-radius: 9px;
    background: #2a2a35;
    border: 1px solid #3a3a45;
    position: relative;
    transition: background 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}

.mp-toolbar__toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #6a6860;
    transition: transform 0.2s ease, background 0.2s ease;
}

.mp-toolbar__toggle-input:checked + .mp-toolbar__toggle-switch {
    background: rgba(165, 9, 5, 0.3);
    border-color: #a50905;
}

.mp-toolbar__toggle-input:checked + .mp-toolbar__toggle-switch::after {
    transform: translateX(16px);
    background: #a50905;
}

.mp-toolbar__toggle-label {
    font-size: 14px;
    font-weight: 600;
    color: #7a7870;
    white-space: nowrap;
}

.mp-toolbar__toggle-input:checked ~ .mp-toolbar__toggle-label {
    color: #a50905;
}

/* --- Leveling Path Panel --- */
.mp-path-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    background: rgba(15, 16, 20, 0.96);
    border-right: 1px solid #2a2a35;
    z-index: 15;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    pointer-events: auto;
}

.mp-path-panel--open {
    transform: translateX(0);
}

.mp-path-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid #2a2a35;
    font-size: 14px;
    font-weight: 700;
    color: #a50905;
    flex-shrink: 0;
}

.mp-path-panel__count {
    font-size: 12px;
    font-weight: 500;
    color: #6a6860;
}

.mp-path-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
    scrollbar-width: thin;
    scrollbar-color: #3a3a45 transparent;
}

/* --- Board Sections --- */
.mp-path-board__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #1e1f25;
    user-select: none;
    transition: background 0.15s;
}

.mp-path-board__header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.mp-path-board__arrow {
    font-size: 10px;
    color: #6a6860;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    width: 12px;
    text-align: center;
}

.mp-path-board--collapsed .mp-path-board__arrow {
    transform: rotate(-90deg);
}

.mp-path-board__name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #c4a24e;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mp-path-board__count {
    font-size: 11px;
    color: #5a5850;
    flex-shrink: 0;
}

.mp-path-board__body {
    display: block;
}

.mp-path-board--collapsed .mp-path-board__body {
    display: none;
}

.mp-path-board__empty {
    padding: 10px 14px 10px 32px;
    color: #4a4840;
    font-size: 12px;
    font-style: italic;
}

/* --- Steps --- */
.mp-path-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 14px;
    font-size: 12px;
    color: #c0bdb5;
    transition: background 0.1s;
}

.mp-path-step:hover {
    background: rgba(255, 255, 255, 0.03);
}

.mp-path-step__num {
    min-width: 22px;
    text-align: right;
    font-weight: 700;
    color: #4a4840;
    font-size: 11px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.mp-path-step__icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #3a3a45;
    background: #1a1a24;
}

.mp-path-step__icon-placeholder {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #1e1f25;
    border: 1px solid #2a2a30;
    flex-shrink: 0;
}

.mp-path-step__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.mp-path-step__type {
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
    text-transform: capitalize;
}

/* Node highlight when clicked from path panel */
.mp-node--highlight {
    z-index: 20 !important;
    filter: brightness(1.6);
    box-shadow: 0 0 18px 8px rgba(196, 162, 78, 0.7);
    border-radius: 50%;
    transition: box-shadow 0.3s ease, filter 0.3s ease;
}

.mp-path-step__type--normal { color: #7a7870; }
.mp-path-step__type--magic { color: #4a90d9; }
.mp-path-step__type--rare { color: #ffd700; }
.mp-path-step__type--legendary { color: #c4a24e; }

/* --- Empty State --- */
.mp-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #7a7870;
}

.mp-empty__icon {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 12px;
}

.mp-empty__text {
    font-size: 14px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .mp-container {
        min-height: 350px;
    }

    .mp-toolbar {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 10px;
    }

    .mp-toolbar__toggle-label {
        display: none;
    }

    .mp-toolbar__points {
        font-size: 12px;
        padding: 0 8px;
        height: 34px;
    }

    .mp-toolbar__glyphs {
        height: 34px;
        padding: 0 2px;
    }

    .mp-toolbar__glyph-circle {
        width: 24px;
        height: 24px;
        font-size: 8px;
    }

    .mp-toolbar__glyph-circle:has(.mp-toolbar__glyph-icon) {
        width: 32px;
        height: 32px;
    }

    .mp-toolbar__glyph-icon {
        width: 32px;
        height: 32px;
    }

    .mp-toolbar__search {
        flex-basis: 100%;
        order: 10;
        height: 34px;
    }

    .mp-toolbar__search-input {
        font-size: 16px; /* Prevent iOS zoom */
    }

    .mp-toolbar__btn {
        width: 34px;
        height: 34px;
    }

    .mp-gate-add {
        width: 48px;
        height: 48px;
        font-size: 26px;
    }

    /* Path panel as bottom-sheet */
    .mp-path-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 50vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        border-right: none;
        border-top: 1px solid #2a2a35;
        transform: translateY(100%);
        z-index: 100;
    }

    .mp-path-panel--open {
        transform: translateY(0);
    }

    .mp-viewport {
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    .mp-toolbar__points {
        font-size: 11px;
        padding: 0 6px;
        height: 30px;
    }

    .mp-toolbar__glyphs {
        height: 30px;
    }

    .mp-toolbar__glyph-circle {
        width: 20px;
        height: 20px;
        font-size: 7px;
    }

    .mp-toolbar__glyph-circle:has(.mp-toolbar__glyph-icon) {
        width: 28px;
        height: 28px;
    }

    .mp-toolbar__glyph-icon {
        width: 28px;
        height: 28px;
    }

    .mp-toolbar__btn {
        width: 30px;
        height: 30px;
    }

    .mp-gate-add {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }

    .mp-viewport {
        min-height: 250px;
    }
}
