/* NPC Portrait Bars System - Display NPCs with HP bars during combat and dialogue */

/* Container for multiple NPC portrait bars (combat mode) */
.npc-portraits-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 90vw;
    pointer-events: none;
}

.npc-portraits-container.dialogue-mode {
    position: fixed;
    top: 30px;
    right: 30px;
    bottom: auto;
    left: auto;
    transform: none;
    max-width: 400px;
}

/* Individual NPC Portrait Bar */
.npc-portrait-bar {
    background: linear-gradient(135deg, rgba(42, 42, 78, 0.95), rgba(26, 26, 46, 0.95));
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 95, 31, 0.5);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6), 0 0 15px rgba(255, 95, 31, 0.2);
    transition: all 0.3s ease;
    cursor: pointer;
    pointer-events: auto;
    min-width: 120px;
    max-width: 140px;
}

.npc-portrait-bar:hover {
    border-color: rgba(255, 95, 31, 0.8);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), 0 0 25px rgba(255, 95, 31, 0.4);
    transform: translateY(-3px) scale(1.02);
}

/* Portrait Image */
.npc-portrait-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255, 95, 31, 0.6);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5), inset 0 0 8px rgba(255, 95, 31, 0.2);
    background: linear-gradient(135deg, #2a2a4e, #1a1a2e);
    margin-bottom: 6px;
}

.npc-portrait-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Placeholder when no portrait available */
.npc-portrait-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    background: linear-gradient(135deg, #ff5f1f, #dc2626);
    color: #fff;
}

/* HP Bar Container */
.npc-hp-bar-container {
    width: 100%;
    height: 16px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
    position: relative;
    margin-bottom: 4px;
}

/* HP Bar Fill */
.npc-hp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #dc2626, #ef4444, #f87171);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Shimmer effect on HP bar */
.npc-hp-bar-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmerNpc 2s infinite;
}

@keyframes shimmerNpc {
    0% { left: -100%; }
    100% { left: 200%; }
}

/* HP Text Overlay */
.npc-hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7em;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 1);
    letter-spacing: 0.5px;
    z-index: 1;
    pointer-events: none;
}

/* NPC Name Label */
.npc-name-label {
    font-size: 0.85em;
    font-weight: bold;
    color: #fff;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.3px;
}

/* Level Badge */
.npc-level-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, #ff5f1f, #dc2626);
    color: #fff;
    font-weight: bold;
    font-size: 0.75em;
    padding: 3px 6px;
    border-radius: 6px;
    border: 2px solid #1a1a2e;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    min-width: 24px;
    text-align: center;
}

/* Status Effects */
.npc-status-effects {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 3px;
}

.npc-status-icon {
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
}

/* Low HP Warning - Red pulse */
.npc-portrait-bar.low-hp {
    animation: npcLowHpPulse 1.5s ease-in-out infinite;
    border-color: #dc2626;
}

.npc-portrait-bar.low-hp .npc-portrait-image {
    border-color: #dc2626;
    box-shadow: 0 3px 10px rgba(220, 38, 38, 0.8), inset 0 0 8px rgba(220, 38, 38, 0.5);
}

@keyframes npcLowHpPulse {
    0%, 100% {
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6), 0 0 15px rgba(220, 38, 38, 0.6);
    }
    50% {
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6), 0 0 30px rgba(220, 38, 38, 1);
    }
}

/* Critical HP - More intense pulsing */
.npc-portrait-bar.critical-hp {
    animation: npcCriticalHpPulse 0.8s ease-in-out infinite;
    border-color: #991b1b;
}

.npc-portrait-bar.critical-hp .npc-portrait-image {
    border-color: #991b1b;
    animation: npcPortraitShake 0.4s ease-in-out infinite;
}

@keyframes npcCriticalHpPulse {
    0%, 100% {
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6), 0 0 25px rgba(153, 27, 27, 1);
    }
    50% {
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6), 0 0 40px rgba(239, 68, 68, 1);
    }
}

@keyframes npcPortraitShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* HP Change Animations */
.npc-hp-bar-fill.increasing {
    animation: hpIncrease 0.6s ease-out;
}

.npc-hp-bar-fill.decreasing {
    animation: hpDecrease 0.6s ease-out;
}

@keyframes hpIncrease {
    0% { filter: brightness(1); }
    50% { filter: brightness(1.5); }
    100% { filter: brightness(1); }
}

@keyframes hpDecrease {
    0% { filter: brightness(1); }
    50% { filter: brightness(0.7); }
    100% { filter: brightness(1); }
}

/* Dead/Defeated State */
.npc-portrait-bar.defeated {
    opacity: 0.5;
    filter: grayscale(1);
    pointer-events: none;
    border-color: #666;
}

.npc-portrait-bar.defeated .npc-portrait-image {
    border-color: #666;
}

.npc-portrait-bar.defeated::after {
    content: '☠';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5em;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    z-index: 10;
}

/* ============================================
   NPC DETAIL MODAL
   ============================================ */

/* Modal Overlay */
.npc-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.npc-detail-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal Container */
.npc-detail-modal {
    background: linear-gradient(135deg, rgba(30, 60, 114, 0.98), rgba(42, 82, 152, 0.98));
    border: 3px solid rgba(255, 95, 31, 0.6);
    border-radius: 20px;
    padding: 0;
    max-width: 600px;
    width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(255, 95, 31, 0.3);
    animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.8) translateY(-50px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Modal Header */
.npc-detail-header {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.3));
    padding: 20px 25px;
    border-bottom: 2px solid rgba(255, 95, 31, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.npc-detail-title {
    font-size: 1.5em;
    font-weight: bold;
    color: #ff5f1f;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.npc-detail-level {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
    margin-left: 10px;
}

.npc-detail-close-btn {
    background: rgba(220, 38, 38, 0.8);
    border: 2px solid rgba(220, 38, 38, 1);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    color: #fff;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.npc-detail-close-btn:hover {
    background: rgba(220, 38, 38, 1);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.8);
}

/* Modal Body */
.npc-detail-body {
    padding: 25px;
}

/* Full Body Portrait */
.npc-detail-portrait {
    width: 100%;
    max-width: 512px;
    aspect-ratio: 1;
    margin: 0 auto 20px;
    border-radius: 15px;
    overflow: hidden;
    border: 3px solid rgba(255, 95, 31, 0.6);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    background: linear-gradient(135deg, #2a2a4e, #1a1a2e);
}

.npc-detail-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.npc-detail-portrait-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6em;
    color: rgba(255, 255, 255, 0.5);
}

/* Stats Section */
.npc-detail-stats {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

.npc-detail-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.npc-detail-stat-row:last-child {
    border-bottom: none;
}

.npc-detail-stat-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95em;
}

.npc-detail-stat-value {
    color: #ffd700;
    font-weight: bold;
    font-size: 1em;
}

/* HP Bar in Modal */
.npc-detail-hp-bar {
    width: 100%;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
    position: relative;
    margin-top: 8px;
}

.npc-detail-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #dc2626, #ef4444, #f87171);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.npc-detail-hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85em;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    z-index: 1;
}

/* Equipment Section */
.npc-detail-equipment {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

.npc-detail-section-title {
    font-size: 1.2em;
    font-weight: bold;
    color: #ff5f1f;
    margin-bottom: 12px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.npc-detail-equipment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.npc-detail-equipment-item {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    gap: 10px;
}

.npc-detail-equipment-item::before {
    content: '⚔️';
    font-size: 1.2em;
}

/* Personality/Description */
.npc-detail-description {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
}

/* Action Buttons */
.npc-detail-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    padding: 20px 25px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 2px solid rgba(255, 95, 31, 0.4);
}

.npc-detail-action-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: #fff;
    font-size: 0.95em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.npc-detail-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    border-color: rgba(255, 255, 255, 0.4);
}

.npc-detail-action-btn.danger {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}

.npc-detail-action-btn.danger:hover {
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .npc-portraits-container {
        bottom: 20px;
        gap: 10px;
    }

    .npc-portraits-container.dialogue-mode {
        top: 20px;
        right: 20px;
    }

    .npc-portrait-bar {
        min-width: 100px;
        max-width: 110px;
    }

    .npc-detail-modal {
        max-width: 95vw;
        max-height: 90vh;
    }

    .npc-detail-header {
        padding: 15px 20px;
    }

    .npc-detail-title {
        font-size: 1.2em;
    }

    .npc-detail-body {
        padding: 20px;
    }

    .npc-detail-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    .npc-portraits-container {
        bottom: 15px;
        gap: 8px;
    }

    .npc-portrait-bar {
        min-width: 80px;
        max-width: 90px;
        padding: 6px;
    }

    .npc-hp-bar-container {
        height: 14px;
    }

    .npc-name-label {
        font-size: 0.75em;
    }

    .npc-detail-actions {
        grid-template-columns: 1fr;
    }
}

/* Hide NPCs during character creation */
body.character-creation-active .npc-portraits-container {
    display: none;
}
