/* unit-detail.css - Styles for the UnitDetail component */

.unit-stats-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    pointer-events: all;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInOverlay 0.1s ease-out;
}

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

.unit-stats-popup {
    background: linear-gradient(135deg,
        hsla(210, 12%, 14%, 0.98) 0%,
        hsla(215, 15%, 18%, 0.98) 100%);
    border: 2px solid var(--accent-blue);
    border-radius: 12px;
    min-width: 600px;
    max-width: 1200px;
    width: 95%;
    max-height: 85vh;
    box-shadow: 0 20px 80px hsla(0, 0%, 0%, 0.9),
                0 0 40px hsla(200, 80%, 55%, 0.3);
    backdrop-filter: blur(12px);
    overflow: hidden;
    animation: fadeInPopup 0.1s ease-out;
    pointer-events: all;
}

@keyframes fadeInPopup {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.unit-stats-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, hsla(200, 80%, 55%, 0.15), hsla(200, 80%, 55%, 0.08));
    border-bottom: 1px solid hsla(210, 30%, 35%, 0.3);
}

.unit-stats-popup-header h3 {
    margin: 0;
    color: var(--accent-blue);
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Philosopher', sans-serif;
}

.unit-stats-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.unit-stats-close:hover {
    background-color: hsla(0, 75%, 55%, 0.2);
    color: var(--accent-red);
}

.unit-stats-popup-body {
    padding: 16px;
    max-height: calc(85vh - 60px);
    overflow-y: auto;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 16px;
}

/* Column 1: Image + Description */
.unit-stats-column-1 {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.unit-stats-image-section {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 0;
}

.unit-stats-image {
    width: 100%;
    height: auto;
    max-width: 100%;
    border-radius: 8px;
    border: 2px solid hsla(200, 80%, 55%, 0.4);
    background: hsla(210, 12%, 30%, 0.6);
    padding: 12px;
    box-sizing: border-box;
}

/* Column 2: Nested Grid Layout */
.unit-stats-column-2 {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Top Section: Stats/Abilities + Custom Equipment */
.column-2-top-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

.column-2-left {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.column-2-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 280px;
}

/* Bottom Section: Weapons | Armor */
.column-2-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.unit-stats-section {
    margin-bottom: 0;
    padding: 12px;
    background: hsla(210, 12%, 12%, 0.4);
    border-radius: 8px;
    border: 1px solid hsla(210, 30%, 35%, 0.2);
}

.unit-stats-section h4 {
    margin: 0 0 10px 0;
    color: var(--accent-blue);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Philosopher', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.unit-stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    justify-items: stretch;
}

/* Core stats in 2 columns to save vertical space */
.column-2-left > .unit-stats-section:first-child .unit-stats-grid {
    grid-template-columns: repeat(2, 1fr);
}

.unit-stat-item {
    display: flex;
    align-items: center;
    justify-self: stretch;
    gap: 6px;
    padding: 6px 10px;
    background: hsla(220, 20%, 6%, 0.5);
    border-radius: 6px;
    font-size: 0.85rem;
    max-width: 160px;
    overflow: hidden;
}

.unit-stat-item .stat-emoji {
    font-size: 1.1rem;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.unit-stat-item .stat-name {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.unit-stat-item .stat-value {
    color: var(--text-primary);
    font-weight: 600;
    margin-left: auto;
    flex-shrink: 0;
}

.unit-stat-item .stat-value.negative {
    color: var(--accent-red);
}

.unit-abilities-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.unit-stats-section.abilities-section {
    grid-column: 1 / -1;
}

/* Items/Equipment section - top right */
.unit-stats-section.items-section {
    /* Stays in second column by default */
}

.items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-card {
    padding: 8px 10px;
    background: hsla(220, 20%, 6%, 0.5);
    border-radius: 6px;
    border: 1px solid hsla(210, 20%, 40%, 0.3);
    transition: all 0.2s;
}

.item-card:hover {
    background: hsla(220, 20%, 10%, 0.7);
    border-color: var(--accent-blue);
}

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

.item-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.item-tags {
    display: flex;
    gap: 4px;
}

.item-tag {
    font-size: 0.7rem;
    padding: 2px 6px;
    background: hsla(200, 80%, 55%, 0.2);
    border-radius: 3px;
    color: var(--accent-blue);
    font-weight: 500;
}

.item-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.8rem;
}

.item-stat {
    display: flex;
    align-items: center;
    gap: 3px;
    color: var(--text-secondary);
}

.item-stat .stat-emoji {
    font-size: 0.9rem;
}

.item-stat .stat-text {
    white-space: nowrap;
}

/* Resistances section - full width, row layout */
.unit-stats-section.resistances-section {
    grid-column: 1 / -1;
}

.resistances-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.resistance-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: hsla(220, 20%, 6%, 0.5);
    border-radius: 6px;
    font-size: 0.85rem;
    border: 1px solid hsla(210, 20%, 40%, 0.2);
    transition: all 0.2s;
}

.resistance-item:hover {
    background: hsla(220, 20%, 10%, 0.7);
    border-color: var(--accent-blue);
}

.resistance-item .stat-emoji {
    font-size: 1rem;
}

.resistance-item .stat-value {
    color: var(--text-primary);
    font-weight: 600;
}

.resistance-item .stat-value.negative {
    color: var(--accent-red);
}

/* Costs section - horizontal row layout */
.unit-stats-section.costs-section {
    grid-column: 1 / -1;
}

.unit-stats-section.costs-section h4 {
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.unit-stats-section.costs-section .unit-stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.unit-stats-section.costs-section .unit-stat-item {
    max-width: none !important;
    min-width: 150px;
    flex: 1 1 150px;
}


.unit-ability-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: hsla(220, 20%, 6%, 0.5);
    border-radius: 6px;
    border: 1px solid hsla(210, 20%, 40%, 0.3);
    transition: all 0.2s;
}

.unit-ability-item:hover {
    background: hsla(220, 20%, 10%, 0.7);
    border-color: var(--accent-blue);
}

.unit-ability-item .ability-emoji {
    font-size: 1.2rem;
    min-width: 24px;
    text-align: center;
}

.unit-ability-item .ability-name {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.unit-ability-item.negative-ability .ability-name {
    color: var(--accent-red);
}

/* Magic-granted abilities (from magic path knowledge) */
.unit-ability-item.magic-ability {
    position: relative;
}

.unit-ability-item.magic-ability:hover {
    border-color: hsla(280, 60%, 60%, 0.7);
    background: linear-gradient(135deg, hsla(280, 45%, 20%, 0.7), hsla(220, 30%, 12%, 0.6));
}

.ability-magic-indicator {
    font-size: 0.7rem;
    color: hsl(280, 70%, 65%);
    margin-left: auto;
    opacity: 0.8;
}

.unit-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    font-style: italic;
}

/* Scrollbar styling */
.unit-stats-popup-body::-webkit-scrollbar {
    width: 6px;
}

.unit-stats-popup-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.unit-stats-popup-body::-webkit-scrollbar-thumb {
    background: hsla(200, 80%, 55%, 0.4);
    border-radius: 3px;
}

.unit-stats-popup-body::-webkit-scrollbar-thumb:hover {
    background: hsla(200, 80%, 55%, 0.6);
}

/* Mobile responsiveness */
@media only screen and (max-width: 1200px) {
    .unit-stats-popup {
        max-width: 900px;
    }

    .unit-stats-popup-body {
        grid-template-columns: 250px 1fr;
    }
}

@media only screen and (max-width: 900px) {
    .unit-stats-popup {
        min-width: 320px;
        max-width: 90vw;
    }

    .unit-stats-popup-body {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .unit-stats-image {
        max-width: 200px;
    }

    /* Stack column 2 grids vertically on mobile */
    .column-2-top-grid,
    .column-2-bottom-grid {
        grid-template-columns: 1fr;
    }

    /* Revert to 1 column for core stats on mobile */
    .column-2-left > .unit-stats-section:first-child .unit-stats-grid {
        grid-template-columns: 1fr;
    }
}

@media only screen and (max-width: 600px) {
    .unit-stats-popup {
        min-width: 280px;
        max-width: 95vw;
        width: 95vw;
    }
}

/* ============================================
   Floating Tooltip (FloatingUI powered)
   ============================================ */

.unit-stats-tooltip {
    position: fixed;
    background: linear-gradient(145deg,
        hsla(210, 12%, 16%, 0.98) 0%,
        hsla(215, 15%, 20%, 0.95) 100%);
    border: 2px solid hsl(200, 70%, 55%);
    border-radius: 10px;
    padding: 14px;
    min-width: 220px;
    max-width: 320px;
    z-index: 10001;
    box-shadow: 0 8px 30px hsla(0, 0%, 0%, 0.85),
                0 0 20px hsla(200, 70%, 50%, 0.3);
    pointer-events: none;
    backdrop-filter: blur(10px);
}

/* Ability tooltip - purple accent */
.unit-stats-tooltip.tooltip-ability {
    border-color: hsl(271, 68%, 63%);
    box-shadow: 0 8px 30px hsla(0, 0%, 0%, 0.85),
                0 0 20px hsla(271, 68%, 53%, 0.3);
}

/* Weapon tooltip - red accent */
.unit-stats-tooltip.tooltip-weapon {
    border-color: hsl(0, 65%, 55%);
    box-shadow: 0 8px 30px hsla(0, 0%, 0%, 0.85),
                0 0 20px hsla(0, 65%, 50%, 0.3);
}

/* Armor tooltip - blue accent */
.unit-stats-tooltip.tooltip-armor {
    border-color: hsl(210, 70%, 55%);
    box-shadow: 0 8px 30px hsla(0, 0%, 0%, 0.85),
                0 0 20px hsla(210, 70%, 50%, 0.3);
}

.unit-stats-tooltip .tooltip-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid hsla(200, 60%, 50%, 0.3);
    margin-bottom: 10px;
}

.tooltip-ability .tooltip-header {
    border-color: hsla(271, 68%, 53%, 0.3);
}

.tooltip-weapon .tooltip-header {
    border-color: hsla(0, 65%, 50%, 0.3);
}

.tooltip-armor .tooltip-header {
    border-color: hsla(210, 70%, 50%, 0.3);
}

.unit-stats-tooltip .tooltip-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.unit-stats-tooltip .tooltip-title-section {
    flex: 1;
    min-width: 0;
}

.unit-stats-tooltip .tooltip-name {
    color: hsl(200, 80%, 90%);
    font-weight: 700;
    font-size: 1rem;
    font-family: 'Philosopher', serif;
    line-height: 1.2;
}

.tooltip-ability .tooltip-name {
    color: hsl(271, 68%, 90%);
}

.tooltip-weapon .tooltip-name {
    color: hsl(0, 65%, 90%);
}

.tooltip-armor .tooltip-name {
    color: hsl(210, 70%, 90%);
}

.unit-stats-tooltip .tooltip-subtype {
    color: hsl(200, 50%, 65%);
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unit-stats-tooltip .tooltip-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.unit-stats-tooltip .tooltip-description {
    color: hsl(200, 30%, 75%);
    font-size: 0.9rem;
    line-height: 1.5;
}

.unit-stats-tooltip .tooltip-detail {
    display: flex;
    gap: 6px;
    font-size: 0.85rem;
}

.unit-stats-tooltip .detail-label {
    color: hsl(200, 50%, 60%);
    font-weight: 600;
}

.unit-stats-tooltip .detail-value {
    color: hsl(200, 30%, 80%);
}

.unit-stats-tooltip .detail-value.warning {
    color: hsl(40, 90%, 60%);
    font-weight: 600;
}

.unit-stats-tooltip .tooltip-source {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: hsl(280, 60%, 70%);
    padding-top: 8px;
    border-top: 1px solid hsla(280, 50%, 50%, 0.2);
    margin-top: 4px;
}

.unit-stats-tooltip .magic-indicator {
    color: hsl(280, 70%, 65%);
    font-size: 0.9rem;
}

/* Tags for weapons/armor */
.unit-stats-tooltip .tooltip-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.unit-stats-tooltip .tooltip-tag {
    background: hsla(200, 60%, 40%, 0.3);
    border: 1px solid hsla(200, 60%, 50%, 0.4);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    color: hsl(200, 70%, 75%);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.tooltip-weapon .tooltip-tag {
    background: hsla(0, 60%, 40%, 0.3);
    border-color: hsla(0, 60%, 50%, 0.4);
    color: hsl(0, 70%, 80%);
}

/* Stats grid for weapons/armor */
.unit-stats-tooltip .tooltip-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.unit-stats-tooltip .tooltip-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    background: hsla(200, 30%, 20%, 0.4);
    padding: 4px 8px;
    border-radius: 4px;
}

.tooltip-weapon .tooltip-stat {
    background: hsla(0, 30%, 20%, 0.4);
}

.tooltip-armor .tooltip-stat {
    background: hsla(210, 30%, 20%, 0.4);
}

.unit-stats-tooltip .tooltip-stat .stat-emoji {
    font-size: 0.9rem;
}

.unit-stats-tooltip .tooltip-stat .stat-label {
    color: hsl(200, 40%, 65%);
    font-weight: 500;
}

.unit-stats-tooltip .tooltip-stat .stat-value {
    color: hsl(60, 60%, 75%);
    font-weight: 700;
    margin-left: auto;
}

/* Stat tooltip - gold accent */
.unit-stats-tooltip.tooltip-stat {
    border-color: hsl(45, 70%, 50%);
    box-shadow: 0 8px 30px hsla(0, 0%, 0%, 0.85),
                0 0 20px hsla(45, 70%, 45%, 0.3);
}

.tooltip-stat .tooltip-header {
    border-color: hsla(45, 70%, 45%, 0.3);
}

.tooltip-stat .tooltip-name {
    color: hsl(45, 80%, 85%);
}

.unit-stats-tooltip .tooltip-stat-value {
    color: hsl(45, 60%, 65%);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 2px;
}

/* Stat item with magic bonus indicator */
.unit-stat-item {
    position: relative;
}

.unit-stat-item.stat-has-magic {
    border-color: hsla(280, 50%, 50%, 0.4);
}

.unit-stat-item.stat-has-magic:hover {
    border-color: hsla(280, 60%, 60%, 0.6);
    background: hsla(280, 30%, 15%, 0.5);
}

.stat-magic-indicator {
    font-size: 0.7rem;
    color: hsl(280, 70%, 65%);
    margin-left: 2px;
}
