/* --- Manager & Editor Styles --- */

.manager-view {
    animation: fadeIn 0.3s ease-out;
    width: 100%;
}

.manager-actions {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

textarea {
    width: 100%;
    height: 400px;
    background: var(--panel-bg);
    color: var(--text-color-light);
    border: 1px solid var(--border-color);
    padding: 15px;
    font-family: monospace;
    font-size: 14px;
    box-sizing: border-box;
}

.form-group textarea {
    height: 140px;
    min-height: 40px;
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 10px;
    resize: vertical;
}

/* Editor Specifics */
.editor-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
}

.tab-btn {
    background: transparent;
    color: var(--text-color-light);
    border: 1px solid transparent;
    border-bottom: none;
    padding: 10px 15px;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: all 0.2s;
    opacity: 0.7;
}

.tab-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    opacity: 1;
    border: 1px solid var(--accent-gold);
    border-bottom: 2px solid var(--panel-bg);
    margin-bottom: -2px;
    background: var(--panel-bg);
    color: var(--accent-gold);
    font-weight: bold;
}

.editor-card-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--accent-gold);
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 10px;
    background: #111;
    color: #eee;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-body);
}

.form-group input[type="text"]:focus {
    border-color: var(--accent-gold);
    outline: none;
}

.input-as-text {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    color: var(--text-color-light) !important;
    font-weight: bold;
    cursor: default;
    box-shadow: none !important;
    height: auto !important;
    pointer-events: none;
}

.ort-editor-box {
    border: 1px solid var(--border-color);
    padding: 15px;
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 15px;
    border-radius: 8px;
    border-left: 3px solid var(--accent-gold);
}

.probe-selector-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.probe-mod-select {
    width: 100px !important;
    text-align: center;
}

.manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.manager-header h2 {
    margin: 0;
}

/* Refinements for Neue Karte Editor - Archivist's Lens */
.import-box {
    border-left: 4px solid var(--accent-gold) !important;
    background: linear-gradient(135deg, rgba(30, 27, 24, 0.98), rgba(10, 9, 8, 0.98)) !important;
    border: 1px solid rgba(var(--accent-gold-rgb), 0.3);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.9), 0 5px 15px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    padding: 20px;
    z-index: 10;
    transition: all 0.3s ease-in-out;
}

.import-box.sticky-import {
    position: sticky;
    top: -1px;
    /* Slight offset to ensure border alignment */
    margin-bottom: 25px;
    z-index: 100;
}

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

.import-box-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-import-help {
    color: var(--accent-gold);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-import-help:hover {
    opacity: 1;
    transform: scale(1.1);
    text-shadow: 0 0 10px rgba(197, 160, 89, 0.4);
}

.import-box.collapsed {
    padding: 10px 20px;
}

.import-box.collapsed .import-box-content {
    display: none;
}

.import-box.collapsed .import-box-header {
    margin-bottom: 0;
}

.toggle-import {
    color: var(--accent-gold);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    transition: transform 0.3s ease;
}

.toggle-import:hover {
    color: var(--accent-gold-active);
    transform: scale(1.1);
}

.import-box h4 {
    margin: 0;
}

/* Scanline Overlay with Flicker Effect */
.import-box::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(0deg,
            rgba(0, 0, 0, 0.15) 0px,
            rgba(0, 0, 0, 0.15) 1px,
            transparent 1px,
            transparent 2px);
    pointer-events: none;
    z-index: 1;
    animation: techFlicker 0.15s infinite alternate;
}

@keyframes techFlicker {
    0% {
        opacity: 0.4;
    }

    100% {
        opacity: 0.7;
    }
}

.import-box h4 {
    color: var(--accent-gold) !important;
    text-shadow: 0 0 15px rgba(197, 160, 89, 0.4);
    margin-bottom: 12px;
    letter-spacing: 2px;
    font-size: 1.1rem;
    position: relative;
    z-index: 5;
    animation: textPulse 4s ease-in-out infinite;
}

@keyframes textPulse {

    0%,
    100% {
        opacity: 0.8;
        text-shadow: 0 0 10px rgba(197, 160, 89, 0.2);
        transform: scale(1);
    }

    50% {
        opacity: 1;
        text-shadow: 0 0 20px rgba(197, 160, 89, 0.7);
        transform: scale(1.02);
    }
}

.import-box p {
    font-size: 0.85rem;
    margin-bottom: 15px;
    color: #aba090;
    position: relative;
    z-index: 5;
    font-style: italic;
}

.import-disclaimer {
    font-size: 0.85rem;
    margin-bottom: 12px;
    color: var(--text-muted);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.8;
}

.import-disclaimer i {
    color: var(--accent-gold);
    font-size: 0.8rem;
    text-shadow: 0 0 5px rgba(197, 160, 89, 0.4);
}

.experimental-badge {
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.4);
    color: #ff6b6b;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 10px;
    font-family: var(--font-body);
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: inline-block;
    vertical-align: middle;
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.1);
}

.import-box textarea {
    height: 140px;
    margin-bottom: 15px;
    background: #050504 !important;
    border: 1px solid #3a342c !important;
    color: #a68a56 !important;
    /* Muted/Matte Gold */
    font-family: 'Courier New', Courier, monospace;
    padding: 12px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 5;
    font-size: 0.95rem;
    line-height: 1.4;
    caret-color: var(--accent-gold);
}

.import-box textarea::placeholder {
    color: rgba(255, 179, 26, 0.3);
}

.import-box .btn.secondary {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background: rgba(197, 160, 89, 0.03);
    border-radius: 0;
    /* Industrial feel */
    position: relative;
    z-index: 5;
    letter-spacing: 1px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.import-box .btn.secondary:hover {
    background: rgba(197, 160, 89, 0.1);
    box-shadow: 0 0 15px rgba(197, 160, 89, 0.2);
    transform: translateY(-1px);
}

.success-branch-title {
    color: #4ade80 !important;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.6), 0 0 20px rgba(74, 222, 128, 0.3);
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-family: var(--font-heading);
}

.failure-branch-title {
    color: #ff6b6b !important;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.6), 0 0 20px rgba(255, 107, 107, 0.3);
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-family: var(--font-heading);
}

.editor-form-separator {
    border: none;
    border-bottom: 1px solid #444;
    margin: 20px 0;
}

.editor-subheader {
    color: var(--accent-gold) !important;
    text-shadow: 0 0 10px rgba(197, 160, 89, 0.4), 0 0 20px rgba(197, 160, 89, 0.2);
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

/* Hamburger & Mobile Menu (Shared with Header/Nav but mostly Editor-focused UX) */
#mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: rgba(14, 13, 12, 0.98);
    background-image: url('../assets/black-paper.png');
    z-index: var(--z-index-modal);
    display: flex;
    justify-content: flex-end;
    transition: opacity 0.3s ease;
}

.mobile-menu-content {
    width: 80%;
    max-width: 320px;
    height: 100%;
    background: var(--panel-bg);
    border-left: 2px solid var(--accent-gold);
    padding: 60px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.9);
    position: relative;
    overflow-y: auto;
}

.close-menu-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: transparent;
    border: none;
    color: var(--accent-gold);
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
}

.menu-title {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--accent-gold);
    padding-bottom: 15px;
    font-family: var(--font-heading);
    color: var(--accent-gold);
}

/* Modal Styles for Card Preview */


#modal-card-container .card-view {
    margin: 0;
    width: 100%;
}

/* --- Manager Control Panel Redesign --- */
.manager-control-panel {
    background: linear-gradient(135deg, rgba(30, 27, 24, 0.95), rgba(15, 13, 12, 0.95));
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8), 0 5px 15px rgba(0, 0, 0, 0.5);
    margin-bottom: 25px;
    display: flex;
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
}

.manager-control-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
    opacity: 0.5;
}

.panel-section {
    flex: 1;
    min-width: 250px;
    padding: 20px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
}

.panel-section:last-child {
    border-right: none;
}

.panel-title {
    font-size: 1.1rem;
    color: var(--accent-gold);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-desc {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 15px;
    flex-grow: 1;
    line-height: 1.4;
}

.panel-section .btn-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel-section .btn {
    width: 100%;
    font-size: 0.85rem;
    padding: 10px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-badge {
    margin-top: 15px;
    font-size: 0.8rem;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    border-left: 3px solid #666;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge.connected {
    color: var(--text-color-light);
    border-left-color: #4CAF50;
}

/* --- Legend Modal Styles --- */


/* --- Editor Mobile & Tablet Optimizations --- */
.editor-tabs-wrapper {
    width: 100%;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 15px;
}

.editor-deck-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.editor-deck-header .btn-row {
    display: flex;
    gap: 10px;
}

/* --- Editor Form Styles --- */
.editor-form-container {
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--accent-gold);
}

.manager-notice {
    background: rgba(139, 0, 0, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.4);
    color: #ffb3b3;
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.editor-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.editor-form-footer {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

/* Tablet Overrides */
@media screen and (max-width: 1024px) {
    .editor-deck-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .editor-deck-header .btn-row {
        justify-content: flex-end;
    }
}

/* Mobile Overrides */
@media screen and (max-width: 600px) {
    .manager-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start !important;
    }

    .manager-header h2 {
        font-size: 1.5rem;
    }

    .editor-tabs-wrapper {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
        mask-image: linear-gradient(to right, black 85%, transparent 100%);
    }

    .editor-tabs-wrapper .editor-tabs {
        display: inline-flex;
        flex-wrap: nowrap;
    }

    .editor-deck-header .btn-row {
        flex-direction: row;
        gap: 10px;
    }

    .editor-deck-header .btn {
        flex: 1;
        justify-content: center;
        padding: 12px 10px !important;
        font-size: 0.9rem;
    }

    .editor-card-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .editor-card-item>div:last-child {
        width: 100%;
        display: flex;
        justify-content: space-between;
        gap: 5px;
    }

    .editor-card-item .btn {
        flex: 1;
        justify-content: center;
        padding: 12px !important;
    }



    .editor-form-container {
        padding: 15px;
    }

    .editor-form-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .editor-form-header h3 {
        font-size: 1.2rem;
        margin: 0;
    }

    .editor-form-footer {
        flex-direction: column;
    }

    .editor-form-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

/* --- JSON Expert Mode Highlighter --- */
.json-editor-wrapper {
    position: relative;
    width: 100%;
    height: 500px;
    background: #1a1511;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

#json-editor,
#json-highlighter {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 15px;
    padding-left: 55px;
    /* Room for line numbers */
    border: none;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre !important;
    /* Changed to pre for better line number mapping */
    word-wrap: normal !important;
    /* Disable wrapping for reliable line numbers */
    box-sizing: border-box;
    overflow: auto;
}

#json-line-numbers {
    position: absolute;
    top: 0;
    left: 0;
    width: 45px;
    height: 100%;
    padding: 15px 5px;
    background: rgba(0, 0, 0, 0.2);
    color: #666;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
    text-align: right;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 3;
    overflow: hidden;
    user-select: none;
    box-sizing: border-box;
    white-space: pre;
}

#json-editor {
    background: transparent !important;
    color: transparent !important;
    caret-color: #fff;
    z-index: 2;
    resize: none;
    outline: none;
}

#json-highlighter {
    background: transparent;
    z-index: 1;
    overflow: auto;
    /* Required for scroll sync */
}

#json-highlighter code {
    font-family: inherit;
    color: #d4d4d4;
}

/* Tokens */
.json-key {
    color: var(--accent-gold);
}

.json-string {
    color: #ce9178;
}

/* Terracotta/Orange-ish */
.json-number {
    color: #b5cea8;
}

/* Light Green */
.json-boolean {
    color: #569cd6;
}

/* Blue */
.json-null {
    color: #808080;
}

/* Gray */

/* Error States */
#json-error-msg {
    color: #ff6b6b;
    font-size: 0.85rem;
    margin-top: 8px;
    min-height: 1.2rem;
    font-style: italic;
}

.editor-error-state {
    border-color: #ff6b6b !important;
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.2);
}

/* --- Sticky Footer Styles --- */
.editor-form-sticky-footer {
    position: sticky;
    bottom: -20px; /* Adjust based on container padding */
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(10, 9, 8, 1) 0%, rgba(10, 9, 8, 0.95) 70%, transparent 100%);
    padding: 40px 20px 20px 20px;
    margin-top: 20px;
    z-index: 100;
    display: flex;
    justify-content: center;
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(197, 160, 89, 0.2);
}

.footer-actions-container {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 600px;
}

.footer-actions-container .btn {
    flex: 1;
    padding: 12px !important;
    font-size: 1.05rem !important;
}

.editor-form-container {
    padding-bottom: 80px; /* Prevent footer from covering content */
}

@media screen and (max-width: 600px) {
    .footer-actions-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .editor-form-sticky-footer {
        padding: 30px 15px 15px 15px;
    }
}
/* --- Import Help Modal Styles --- */
.import-help-steps {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 25px 0;
}

.help-step {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.step-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: rgba(197, 160, 89, 0.1);
    border: 1px solid rgba(197, 160, 89, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-gold);
    font-size: 1.2rem;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

.step-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #2b1f11; /* Dark text for light paper */
}

.step-text strong {
    color: #8e6d42; /* Darker gold/brown for emphasis */
}

.import-notice {
    background: rgba(142, 109, 66, 0.1);
    border: 1px solid rgba(142, 109, 66, 0.3);
    padding: 15px;
    border-radius: 6px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-top: 10px;
    font-size: 0.9rem;
    font-style: italic;
    color: #5e462e; /* Darker brown */
}

.import-notice i {
    color: var(--accent-gold);
    font-size: 1.1rem;
    margin-top: 2px;
}
