/* Encounter Manager Styles (encounter-specific only) */
/* Shared styles (.mns-*) are in shared-components.css */

/* ── Encounter bar ─────────────────────────────────────────────────────────── */
.em-encounter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-300, #dee2e6);
}

.em-enc-select {
    padding: 0.25rem 0.4rem;
    font-size: 0.85rem;
    border: 1px solid var(--gray-400, #adb5bd);
    border-radius: 4px;
    background: var(--gray-100, #f8f9fa);
    color: inherit;
    min-width: 140px;
}

@media (prefers-color-scheme: dark) {
    .em-encounter-bar {
        border-color: #4b5563;
    }
    .em-enc-select {
        background: #374151;
        border-color: #4b5563;
        color: #e5e7eb;
    }
}

/* ── Turn bar ──────────────────────────────────────────────────────────────── */
.em-turn-bar {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--gray-300, #dee2e6);
    border-radius: 6px;
    background: var(--gray-50, #fdfdfd);
    overflow: hidden;
}

.em-turn-btn-row {
    display: flex;
    gap: 0;
    align-items: stretch;
    border-bottom: 1px solid var(--gray-300, #dee2e6);
}

.em-turn-btn-row .mns-btn {
    flex: 1;
    text-align: center;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--gray-300, #dee2e6);
    padding: 0.3rem 0.4rem;
}

.em-turn-btn-row .mns-btn:last-child {
    border-right: none;
}

@media (prefers-color-scheme: dark) {
    .em-turn-btn-row { border-bottom-color: #374151; }
    .em-turn-btn-row .mns-btn { border-right-color: #374151; }
}

.em-turn-label {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.35rem 0.6rem;
    text-align: center;
    border-bottom: 1px solid var(--gray-300, #dee2e6);
}
.em-turn-players {
    background: var(--mns-player-bg);
    color: var(--mns-player-text);
}
.em-turn-npcs {
    background: var(--mns-npc-bg);
    color: var(--mns-npc-text);
}

@media (prefers-color-scheme: dark) {
    .em-turn-bar {
        background: #1f2937;
        border-color: #4b5563;
    }
    .em-turn-label { border-bottom-color: #374151; }
}

/* ── Add NPC panel ─────────────────────────────────────────────────────────── */
.em-add-panel {
    margin-bottom: 1rem;
    border: 1px solid var(--gray-300, #dee2e6);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
}

.em-add-panel-toggle-row {
    display: flex;
    align-items: center;
}

.em-search-input {
    width: 100%;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
    border: 1px solid var(--gray-400, #adb5bd);
    border-radius: 4px;
    box-sizing: border-box;
    background: inherit;
    color: inherit;
    margin-top: 0.4rem;
}

.em-search-results {
    list-style: none;
    margin: 0.4rem 0 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}

.em-search-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.3rem;
    border-bottom: 1px solid var(--gray-200, #f0f0f0);
}
.em-search-item:last-child {
    border-bottom: none;
}

.em-search-name {
    font-weight: 500;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.em-search-empty {
    color: var(--gray-500, #6b7280);
    padding: 0.3rem;
    font-style: italic;
    list-style: none;
}

.em-add-divider {
    margin: 0.5rem 0 0.35rem;
    font-size: 0.72rem;
    color: var(--gray-500, #6b7280);
    font-style: italic;
}

.em-player-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.em-player-input {
    flex: 1;
    padding: 0.25rem 0.4rem;
    font-size: 0.82rem;
    border: 1px solid var(--gray-400, #adb5bd);
    border-radius: 4px;
    background: inherit;
    color: inherit;
}

@media (prefers-color-scheme: dark) {
    .em-add-panel {
        border-color: #4b5563;
    }
    .em-search-input {
        border-color: #4b5563;
        background: #1f2937;
        color: #e5e7eb;
    }
    .em-search-item {
        border-color: #374151;
    }
    .em-add-divider {
        color: #6b7280;
    }
    .em-player-input {
        border-color: #4b5563;
        background: #1f2937;
        color: #e5e7eb;
    }
}

/* ── NPC list & item wrapper ───────────────────────────────────────────────── */
.em-npc-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.em-npc-item {
    display: flex;
    align-items: stretch;
    gap: 0.3rem;
    position: relative;
}

.em-npc-item > .mns-card {
    flex: 1;
    min-width: 0;
}

/* Drop line indicators */
.em-drop-before::before,
.em-drop-after::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--mns-primary);
    border-radius: 2px;
    pointer-events: none;
    z-index: 10;
}
.em-drop-before::before { top: -4px; }
.em-drop-after::after   { bottom: -4px; }

/* ── Card variants (encounter-specific) ───────────────────────────────────── */
.mns-card.em-card-has-instances {
    border-color: var(--mns-green-border);
}

/* ── Body row padding for encounter-specific sections ─────────────────────── */
.em-instances-section {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* ── Name input (editable) ────────────────────────────────────────────────── */
.em-name-input {
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    flex: 1;
    min-width: 100px;
}
.em-name-input:hover, .em-name-input:focus {
    border-color: var(--gray-400, #9ca3af);
    background: var(--gray-50, #f9fafb);
    outline: none;
}

@media (prefers-color-scheme: dark) {
    .em-name-input:hover, .em-name-input:focus {
        border-color: #6b7280;
        background: #111827;
    }
}

/* ── Instances section ─────────────────────────────────────────────────────── */
.em-instances-section {
    border-top: 2px solid var(--gray-200, #e5e7eb);
    padding-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.em-instances-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--gray-500, #6b7280);
    margin-bottom: 0.1rem;
}

@media (prefers-color-scheme: dark) {
    .em-instances-section { border-top-color: #374151; }
    .em-instances-title { color: #9ca3af; }
}

/* ── Instance block ────────────────────────────────────────────────────────── */
.em-instance-block {
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 5px;
    background: var(--gray-50, #f9fafb);
    overflow: hidden;
}
.em-instance-eliminated { opacity: 0.4; }
.em-instance-inactive { opacity: 0.65; }

.em-instance-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.55rem;
    cursor: pointer;
    user-select: none;
    background: var(--gray-100, #f3f4f6);
    flex-wrap: wrap;
}
.em-instance-header:hover { background: var(--gray-200, #e9ecef); }

.em-instance-name {
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.em-instance-body {
    padding: 0.45rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    border-top: 1px solid var(--gray-200, #e5e7eb);
}

@media (prefers-color-scheme: dark) {
    .em-instance-block {
        background: #1a2433;
        border-color: #374151;
    }
    .em-instance-header {
        background: #1f2937;
    }
    .em-instance-header:hover { background: #273345; }
    .em-instance-body { border-top-color: #374151; }
}

/* ── Collapsed instances ──────────────────────────────────────────────────── */
.em-collapsed-instances {
    border-top: 1px solid var(--gray-200, #e5e7eb);
    padding: 0.2rem 0.55rem 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.em-collapsed-inst-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
    font-size: 0.82rem;
}
.em-collapsed-inst-row:last-child {
    border-bottom: none;
}

@media (prefers-color-scheme: dark) {
    .em-collapsed-instances {
        border-top-color: #374151;
    }
    .em-collapsed-inst-row {
        border-bottom-color: #1f2937;
    }
}

/* ── Edit panel ────────────────────────────────────────────────────────────── */
.em-edit-panel {
    background: var(--gray-50, #fafafa);
    border-top: 2px solid var(--mns-primary);
}

.em-edit-title {
    font-weight: 600;
    font-size: 0.85rem;
    flex: 1;
}

.em-edit-label {
    font-size: 0.78rem;
    color: var(--gray-600, #4b5563);
    white-space: nowrap;
    min-width: 7rem;
}

.em-edit-num {
    width: 4rem;
    padding: 0.2rem 0.35rem;
    font-size: 0.82rem;
    border: 1px solid var(--gray-400, #adb5bd);
    border-radius: 4px;
    background: inherit;
    color: inherit;
    -moz-appearance: textfield;
}
.em-edit-num::-webkit-inner-spin-button,
.em-edit-num::-webkit-outer-spin-button { -webkit-appearance: none; }

.em-edit-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--gray-500, #6b7280);
    margin-top: 0.2rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--gray-200, #e5e7eb);
}

.em-edit-skills-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.em-edit-skill-wrap {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.em-edit-focus-items {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.em-edit-focus-name {
    flex: 1;
    min-width: 100px;
    padding: 0.2rem 0.35rem;
    font-size: 0.82rem;
    border: 1px solid var(--gray-400, #adb5bd);
    border-radius: 4px;
    background: inherit;
    color: inherit;
}

@media (prefers-color-scheme: dark) {
    .em-edit-panel {
        background: #111827;
    }
    .em-edit-label { color: #9ca3af; }
    .em-edit-num {
        border-color: #4b5563;
        background: #1f2937;
        color: #e5e7eb;
    }
    .em-edit-section-title {
        color: #9ca3af;
        border-top-color: #374151;
    }
    .em-edit-focus-name {
        border-color: #4b5563;
        background: #1f2937;
        color: #e5e7eb;
    }
}

/* ── Kebab menu ────────────────────────────────────────────────────────────── */
.em-kebab-wrap {
    position: relative;
    display: inline-block;
}

.em-kebab-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
    letter-spacing: 0.05em;
}

.em-kebab-menu {
    position: absolute;
    top: calc(100% + 2px);
    right: 0;
    background: #fff;
    border: 1px solid var(--gray-300, #dee2e6);
    border-radius: 5px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.12);
    z-index: 200;
    min-width: 130px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.em-kebab-item {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    white-space: nowrap;
}

.em-kebab-item:hover {
    background: var(--gray-100, #f3f4f6);
}

@media (prefers-color-scheme: dark) {
    .em-kebab-menu {
        background: #1f2937;
        border-color: #4b5563;
        box-shadow: 0 3px 10px rgba(0,0,0,0.4);
    }
    .em-kebab-item:hover { background: #374151; }
}

/* ── Actor status chips (turn bar) ─────────────────────────────────────────── */
.em-actors-status {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.35rem 0.6rem 0.4rem;
    border-top: 1px solid var(--gray-200, #e5e7eb);
}

.em-actor-chip {
    font-size: 0.72rem;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    font-weight: 500;
    white-space: nowrap;
}

.em-actor-player {
    background: var(--mns-player-bg);
    color: var(--mns-player-text);
}

.em-actor-npc {
    background: var(--mns-npc-bg);
    color: var(--mns-npc-text);
}

.em-actor-acted {
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-400, #9ca3af);
    text-decoration: line-through;
}

.em-actor-partial {
    background: var(--mns-partial-bg);
    color: var(--mns-partial-text);
}

@media (prefers-color-scheme: dark) {
    .em-actors-status { border-top-color: #374151; }
    .em-actor-acted { background: #1f2937; color: #4b5563; }
}

/* ── Drag grip (outside card) ──────────────────────────────────────────────── */
.em-drag-grip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    flex-shrink: 0;
    cursor: grab;
    color: var(--gray-300, #d1d5db);
    background: none;
    border: none;
    font-size: 0.9rem;
    padding: 0;
    user-select: none;
}
.em-drag-grip:hover { color: var(--gray-500, #6b7280); }
.em-drag-grip:active { cursor: grabbing; }

@media (prefers-color-scheme: dark) {
    .em-drag-grip { color: #374151; }
    .em-drag-grip:hover { color: #6b7280; }
}

/* ── Header right controls ─────────────────────────────────────────────────── */
.em-header-right-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.em-remove-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
    background: #dc2626;
    border-color: #b91c1c;
    color: #fff;
}
.em-remove-btn:hover {
    background: #b91c1c;
    border-color: #991b1b;
}

/* ── Turn bar pinned to right side ─────────────────────────────────────────── */
.em-turn-bar {
    position: fixed;
    top: 3.5rem;
    right: 1rem;
    width: 220px;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    z-index: 50;
    margin-bottom: 0;
}

/* ── Mobile responsive (encounter-specific) ────────────────────────────────── */
@media (max-width: 900px) {
    .em-turn-bar {
        position: static;
        width: auto;
        max-height: none;
        overflow-y: visible;
        margin-bottom: 0.75rem;
    }
}

/* ── Ref section border collapse with skills ──────────────────────────────── */
.mns-ref-section + .em-instances-section {
    border-top-color: var(--gray-200, #e5e7eb);
}
@media (prefers-color-scheme: dark) {
    .mns-ref-section + .em-instances-section { border-top-color: #374151; }
}
