/* Окно взаимодействия с NPC */
.npc-window {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: var(--color-bg);
    position: relative;
    animation: npcFadeIn 0.2s ease-out;
    overflow: visible;
}

@keyframes npcFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.npc-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: var(--color-panel-light);
    color: var(--color-text-dim);
    border: 1px solid var(--color-border);
    pointer-events: auto;
    cursor: pointer;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.2em;
    font-weight: 400;
    transition: all var(--transition-fast);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.npc-close:hover {
    background: rgba(197, 48, 48, 0.15);
    border-color: rgba(197, 48, 48, 0.3);
    color: var(--color-accent-bright);
}

.npc-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 20px;
    gap: 16px;
}

.npc-profile {
    background: var(--color-panel);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    gap: 16px;
}

.npc-avatar {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-md);
    background: var(--color-panel-light);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    flex-shrink: 0;
    overflow: hidden;
}

.npc-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.npc-info {
    flex: 1;
}

.npc-name {
    color: var(--color-accent-bright);
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 8px;
}

.npc-roles {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.npc-role-badge {
    padding: 4px 10px;
    background: rgba(155, 44, 44, 0.1);
    border: 1px solid rgba(155, 44, 44, 0.3);
    border-radius: var(--radius-sm);
    font-size: 0.7em;
    color: var(--color-accent-bright);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.npc-description {
    color: var(--color-text-dim);
    font-size: 0.85em;
    line-height: 1.5;
}

.npc-actions {
    background: var(--color-panel);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.npc-actions-title {
    color: var(--color-text-dim);
    font-weight: 600;
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.npc-action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.npc-btn {
    padding: 10px 20px;
    background: var(--color-panel-light);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: all var(--transition-fast);
    min-width: 100px;
}

.npc-btn:hover:not(:disabled) {
    background: var(--color-panel-hover);
    border-color: var(--color-accent);
    color: var(--color-accent-bright);
}

.npc-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.npc-dialogue {
    background: var(--color-panel);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    min-height: 60px;
    display: flex;
    align-items: center;
}

.npc-dialogue-text {
    color: var(--color-text);
    font-size: 0.9em;
    line-height: 1.6;
    font-style: italic;
}

/* ===== ТОРГОВЛЯ С NPC — минималистичный стиль ===== */
.npc-trade-window {
    display: grid;
    grid-template-columns: 1fr minmax(260px, 300px) 1fr;
    grid-template-rows: 1fr auto;
    gap: 12px;
    height: 100%;
    max-height: calc(100vh - 180px);
    padding: 14px 18px;
    font-size: 0.88em;
    overflow: hidden;
}

.npc-trade-section {
    background: var(--color-panel);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
    min-height: 0;
    max-height: calc(100vh - 240px);
}

.npc-trade-title {
    color: var(--color-accent-bright);
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.npc-trade-slots-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: space-between;
}

.npc-trade-slots-container {
    background: var(--color-panel);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px;
}

.npc-trade-slots-title {
    color: var(--color-text-dim);
    font-size: 0.68em;
    font-weight: 600;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.npc-trade-slots {
    display: grid;
    grid-template-columns: repeat(5, 43px);
    gap: 4px;
    justify-content: center;
}

.npc-trade-slot {
    position: relative;
    width: 43px;
    height: 43px;
    min-width: 43px;
    min-height: 43px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.npc-trade-slot.empty {
    border-style: dashed;
    opacity: 0.4;
    cursor: default;
}
.npc-trade-slot.filled {
    border-color: var(--color-accent);
    background: rgba(255,255,255,0.03);
}
.npc-trade-slot.filled:hover {
    background: rgba(255,255,255,0.06);
    border-color: var(--color-accent-bright);
}
.npc-trade-slot img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.slot-remove {
    position: absolute;
    top: 0;
    right: 0;
    width: 13px;
    height: 13px;
    background: rgba(200,50,50,0.85);
    color: #fff;
    border-radius: 50%;
    font-size: 9px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    line-height: 1;
    border: none;
    cursor: pointer;
}
.npc-trade-slot.filled:hover .slot-remove { opacity: 1; }

/* ── Баланс ── */
.npc-trade-balance {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
}
.balance-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    color: var(--color-text-dim);
    font-size: 0.8em;
}
.balance-row.total {
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 2px;
    padding-top: 4px;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--color-accent);
}

/* ── Сетка предметов ── */
.npc-inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 43px);
    gap: 4px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    max-height: 300px;
    justify-content: center;
    align-content: start;
}
.npc-inventory-grid::-webkit-scrollbar { width: 4px; }
.npc-inventory-grid::-webkit-scrollbar-track { background: transparent; }
.npc-inventory-grid::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

.npc-item-slot {
    position: relative;
    width: 43px;
    height: 43px;
    min-width: 43px;
    min-height: 43px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.npc-item-slot:hover:not(.empty) {
    background: rgba(255,255,255,0.04);
    border-color: var(--color-accent);
}
.npc-item-slot.selected {
    border-color: var(--color-accent);
    box-shadow: 0 0 6px rgba(212,165,116,0.3);
}
.npc-item-slot img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    display: block;
}
.npc-item-price {
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(0,0,0,0.85);
    color: var(--color-gold, #d4a574);
    font-size: 8px;
    padding: 0 2px;
    border-radius: 2px;
    line-height: 1.3;
}
.npc-item-qty {
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(0,0,0,0.85);
    color: #fff;
    font-size: 8px;
    padding: 0 2px;
    border-radius: 2px;
    line-height: 1.4;
}
.npc-item-selected {
    position: absolute;
    top: 1px;
    left: 1px;
    background: var(--color-accent);
    color: #000;
    font-size: 0.6em;
    font-weight: 600;
    padding: 1px 3px;
    border-radius: 2px;
}

/* ── Итого ── */
.npc-trade-summary {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 8px;
}
.npc-trade-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.82em;
    color: var(--color-text-dim);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.npc-trade-summary-row:last-child {
    border-bottom: none;
    font-weight: 600;
    color: var(--color-accent);
}

/* ── Кнопки ── */
.npc-trade-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 6px;
    padding: 4px;
    justify-content: center;
}
.npc-trade-btn {
    min-width: 100px;
    padding: 7px 14px;
    background: var(--color-panel-light);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
    font-size: 0.82em;
}
.npc-trade-btn:hover:not(:disabled) {
    border-color: var(--color-accent);
    background: rgba(212,165,116,0.08);
}
.npc-trade-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.npc-trade-btn-confirm {
    color: #8bc34a;
    border-color: rgba(139,195,74,0.3);
}
.npc-trade-btn-confirm:hover:not(:disabled) {
    background: rgba(139,195,74,0.1);
    border-color: rgba(139,195,74,0.5);
}

/* ── Модальное окно количества ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.npc-quantity-modal {
    max-width: 300px;
    background: var(--color-panel);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.npc-quantity-modal h3 {
    color: var(--color-accent-bright);
    margin: 0 0 10px 0;
    font-size: 1em;
    font-weight: 600;
}
.npc-quantity-item-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
}
.npc-quantity-item-preview img {
    width: 36px;
    height: 36px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
}
.npc-quantity-item-info { flex: 1; }
.npc-quantity-item-name {
    color: var(--color-text);
    font-weight: 600;
    font-size: 0.88em;
}
.npc-quantity-item-price {
    color: var(--color-accent);
    font-size: 0.78em;
    margin-top: 1px;
}
.npc-quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 12px 0;
}
.npc-quantity-controls input {
    width: 60px;
    text-align: center;
    background: rgba(0,0,0,0.3);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 5px;
    border-radius: 3px;
    font-size: 0.9em;
}
.npc-quantity-controls input:focus {
    outline: none;
    border-color: var(--color-accent);
}
.npc-quantity-total {
    text-align: center;
    color: var(--color-text-dim);
    margin-bottom: 10px;
    font-size: 0.82em;
}
.npc-quantity-total-value {
    color: var(--color-accent);
    font-weight: 600;
}
.npc-quantity-modal-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
}
.npc-quantity-btn {
    background: var(--color-panel-light);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.82em;
}
.npc-quantity-btn:hover {
    border-color: var(--color-accent);
    background: rgba(212,165,116,0.08);
}
.npc-quantity-selector {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-top: 8px;
}
.npc-quantity-input {
    width: 60px;
    padding: 5px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    color: var(--color-text);
    text-align: center;
    font-size: 0.95em;
}
.npc-quantity-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* Стили для узловой системы диалогов */
.npc-dialogue-window {
    display: flex;
    background: var(--color-panel);
    border: 2px solid var(--color-border);
    border-radius: 8px;
    padding: 20px;
    gap: 20px;
    min-height: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.npc-dialogue-avatar {
    width: 120px;
    height: 120px;
    border-radius: 8px;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    flex-shrink: 0;
    overflow: hidden;
}

.npc-dialogue-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.npc-dialogue-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.npc-dialogue-name {
    color: var(--color-accent-bright);
    font-size: 1.3em;
    font-weight: 600;
}

.npc-dialogue-text {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 5px;
    border-left: 3px solid var(--color-accent);
    color: var(--color-text);
    line-height: 1.6;
    font-size: 1.05em;
    flex: 1;
}

.npc-dialogue-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dialogue-option {
    padding: 12px 16px;
    background: linear-gradient(to bottom, #3a3227 0%, #2d271f 100%);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    font-size: 1.05em;
    text-align: left;
    transition: all 0.2s ease;
}

.dialogue-option:hover {
    background: linear-gradient(to bottom, #4a4237 0%, #3d372f 100%);
    border-color: var(--color-accent);
    transform: translateX(5px);
}

.dialogue-option:active {
    transform: translateX(3px);
}
