/* 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 (initiative tracker — fixed bottom footer) ───────────────────── */
.em-turn-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 2px solid var(--gray-300, #dee2e6);
    background: var(--gray-50, #fdfdfd);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.12);
    max-height: 38vh;
    overflow-y: auto;
}

.em-turn-top {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--gray-50, #fdfdfd);
    border-bottom: 1px solid var(--gray-300, #dee2e6);
}

@media (prefers-color-scheme: dark) {
    .em-turn-top { background: #1f2937; }
}

.em-turn-btn-row {
    display: flex;
    flex: 1;
    gap: 0;
    align-items: stretch;
}

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

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

.em-turn-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.4rem 1.1rem;
    white-space: nowrap;
    flex-shrink: 0;
}
.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-top-color: #4b5563;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.4);
    }
}

/* ── 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;
    background: var(--gray-100, #f3f4f6);
    flex-wrap: wrap;
}

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

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

/* ── 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: fixed;
    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; }
}

/* ── Inline controls (acted + stat steppers in headers) ────────────────────── */
.em-inline-controls {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.9rem;
    margin-top: 0.3rem;
    padding-top: 0.35rem;
    border-top: 1px dashed var(--gray-300, #d1d5db);
}

.em-inline-acted {
    font-size: 0.8rem;
}

/* Status dropdown styled as a colored pill (uses .mns-status-* colors) */
.mns-status-select {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.12rem 1rem 0.12rem 0.4rem;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-repeat: no-repeat;
    background-position: right 0.3rem center;
    background-size: 0.55rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23333' stroke-width='1.5'/%3E%3C/svg%3E");
}
.mns-status-select:focus { outline: none; }

@media (prefers-color-scheme: dark) {
    .mns-status-select {
        border-color: rgba(255, 255, 255, 0.18);
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23ddd' stroke-width='1.5'/%3E%3C/svg%3E");
    }
    .mns-status-select option { background: #1f2937; color: #e5e7eb; }
}

/* In compact collapsed-instance rows, drop the divider */
.em-collapsed-inst-row .em-inline-controls {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

@media (prefers-color-scheme: dark) {
    .em-inline-controls { border-top-color: #374151; }
}

/* ── 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;
}

/* ── 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; }
}
