/* frontend/styles/components/selection-modal.css (Corrected) */

/* * L'overlay est une couche qui vient se placer par-dessus le contenu de la modale principale.
 * Il doit être en position 'absolute' pour remplir son parent (#modal-container).
*/
#selection-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 20, 0.85); /* Fond sombre avec une légère teinte bleue */
    backdrop-filter: blur(4px); /* Effet de flou sur le contenu derrière */
    z-index: 1010; /* Increased from 1000 to be on top of the enhancement modal */
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* Animation d'apparition */
    animation: fadeIn 0.2s ease-out;
}

/* --- CORRECTION : ID mis à jour de #selection-modal vers #selection-modal-container --- */
/* C'est la "carte" intérieure de la modale de sélection. */
#selection-modal-container {
    width: 95%;
    max-width: 800px; /* Ajout d'une largeur maximale pour les grands écrans */
    height: 90%;
    max-height: 700px; /* Ajout d'une hauteur maximale */
    
    display: flex;
    flex-direction: column;
    padding: var(--spacing-md);
    
    background: rgba(25, 28, 35, 0.95); /* Fond de la carte légèrement plus clair */
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.37);
}

.selection-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0; /* Empêche l'en-tête de rétrécir */
}

.selection-modal-header h3 {
    font-family: var(--font-header);
    color: var(--accent-color);
    font-size: 1.2rem;
}

#selection-modal-close-btn {
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-color);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s ease, color 0.2s ease;
}
#selection-modal-close-btn:hover {
    color: var(--accent-color);
    transform: scale(1.1);
}

.selection-modal-grid {
    flex-grow: 1;
    overflow-y: auto; /* Active le défilement si la grille dépasse la hauteur */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: var(--spacing-md);
    padding-right: var(--spacing-xs); /* Petit espace pour la barre de défilement */
    padding-top: 0.5em;
}

.selection-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm); /* Un peu plus d'espace */
    cursor: pointer;
    text-align: center;
    transition: transform var(--transition-very-fast), opacity var(--transition-very-fast);
}

.selection-item-image-wrapper {
    border: 2px solid var(--border-light-color); /* Default State */
    border-radius: var(--radius-md);
    padding: 2px;
    transition: border-color var(--transition-very-fast), box-shadow var(--transition-very-fast);
    background-color: rgba(0,0,0,0.3);
    height: 130px;
    width: 100px;
}

.selection-item img {
    height: 100%;
    width: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

#selection-modal-container.selection-type-rig .selection-item img,
#selection-modal-container.selection-type-implant .selection-item img {
 object-fit: contain;
}

.selection-item-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.2;
}

/* === États des items === */
.selection-item.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(100%);
}

/* The 'selected' state uses the base rarity color. */
.selection-item.selected .selection-item-image-wrapper {
    border-color: var(--rarity-color);
    box-shadow: 0 0 8px var(--rarity-color);
}

/* On EITHER 'selected' OR 'hover', apply the dynamic rarity color and glow. */
.selection-item.selected .selection-item-image-wrapper,
.selection-item:not(.disabled):hover .selection-item-image-wrapper {
    border-color: var(--rarity-color);
}

.selection-item:not(.disabled):hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
}

/* Formation Selection Modal */
.selection-type-formation .selection-item-image-wrapper {
    border: none;
    background-color: transparent;
}
/* Enhances the 'staged'/'selected' look with a brighter border */
/* Adds a hover effect to the inner image wrapper */
.selection-item:not(.disabled):hover .selection-item-image-wrapper {
    outline: 2px solid var(--rarity-color);
    outline-offset: -2px;
}

.selection-item.selected .selection-item-image-wrapper,
.selection-item.staged .selection-item-image-wrapper {
    outline: 2px solid var(--rarity-color);
    outline-offset: -2px;
    border-color: var(--accent-color); /* Also color the main border */
    box-shadow: 0 0 8px var(--glow-color); /* Add a glow effect */
}
/* =================================== */
/* --- SELECTION MODAL ENHANCEMENTS --- */
/* =================================== */
.create-build-modal.selection-active .selector-wrapper {
    pointer-events: none;
}

.selection-modal-controls {
    padding: 0 var(--spacing-sm) var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

#selection-modal-search {
    width: 100%;
    padding: var(--spacing-sm);
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: var(--radius-sm);
}

.selection-modal-filters {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.selection-modal-footer {
    /* This uses flexbox to center the button */
    display: flex;
    justify-content: center;
    padding: var(--spacing-sm);
    border-top: 1px solid var(--border-color);
}

.selection-modal-footer {
    /* This uses flexbox to center the button */
    display: flex;
    justify-content: center;
    padding: var(--spacing-sm);
    border-top: 1px solid var(--border-color);
}

.selection-modal-filters .filter-group {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

.selection-modal-filters button {
    padding: 4px 10px;
    font-size: 0.8rem;
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.selection-modal-filters button:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.selection-modal-filters button.active {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--primary-bg);
    font-weight: 700;
}

/* List Area & Grouping Banner */
.selection-modal-list-area {
    flex-grow: 1;
    max-height: 40vh;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.selection-group {
    margin-bottom: var(--spacing-sm);
}

.selection-group-banner {
    background-color: var(--banner-color, #555);
    color: #fff;
    font-family: var(--font-header);
    font-size: 0.8rem;
    padding: 3px var(--spacing-sm);
    border-radius: var(--radius-sm);
    text-align: center;
    text-transform: uppercase;
    margin-bottom: var(--spacing-sm);
}

.selection-group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--spacing-lg);
}

/* Adds a white inner outline to the image container for selected/staged items */
.selection-item.selected .selection-item-image-wrapper,
.selection-item.staged .selection-item-image-wrapper {
    outline: 2px solid var(--rarity-color);
    outline-offset: -2px; /* Moves the outline inside the element's border */
}

/* SNIPPET FOR: selection-modal.css */

/* --- Item Detail Overlay (Layer 3) --- */
/* This is the semi-transparent background for the detail popup */
#item-detail-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1010; /* On top of the selection modal */
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
}

/* This is the content card for the description */
.item-detail-card {
    position: relative;
    width: 90%;
    max-width: 320px;
    padding: var(--spacing-lg);
    background: rgba(35, 38, 45, 0.98);
    border: 1px solid var(--accent-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.item-detail-card .close-btn {
    position: absolute;
    top: 6px;
    right: 8px;
}

.item-detail-card h4 {
    color: var(--accent-color);
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
    text-transform: uppercase;
}

.item-detail-card p {
    font-size: 0.9rem;
    color: var(--text-color-secondary, #ccc);
    line-height: 1.6;
    margin: 0;
}

/* Styles for the empty rig/implant slot placeholders */
.enhancement-selector.empty .placeholder-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%; /* Adjust size of the placeholder icon */
    height: 90%;
    z-index: 1;
}

.enhancement-selector.empty .placeholder-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 1; /* Make the placeholder subtle */
}

/* Slot detail indicator */
.selection-item-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.skill-slot-indicator {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary-bg);
    background-color: var(--accent-color);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

/* --- Selection List Info Button & Description Modal --- */

.selection-item {
  position: relative; /* Required for positioning the info button */
}

.selection-item-info {
    position: absolute;
    top: -10px;
    right: -5px;
    z-index: 2;
    width: 35px;
    height: 35px;
    background-color: rgba(0, 0, 0, 0.6);
    color: var(--text-color);
    border-radius: 50%;
    border: 2px solid #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    transition: all var(--transition-fast);
}

.selection-item-info:hover {
    color: var(--primary-bg);
    border-color: var(--accent-color);
}

.simple-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    border-radius: var(--radius-xl);
}

.simple-popup-content {
    position: relative;
    width: 90%;
    max-width: 320px;
    padding: var(--spacing-lg);
    background: #1a1a1a;
    border: 1px solid var(--accent-color);
}

.simple-popup-content .simple-popup-close {
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 2rem;
    color: var(--text-color);
}
.simple-popup-content .simple-popup-close:hover
{
    color: var(--accent-color);
}

/* Style for the "Normal" group banner */
.selection-group-banner:is([style*="--banner-color: #667"]) {
    background-color: rgb(105, 129, 131);
    margin-bottom: 2em;
}

/* Style for the "Special" group banner */
.selection-group-banner:is([style*="--banner-color: #889"]) {
    background-color: var(--accent-color); /* A slightly different orange */
    margin-bottom: 2em;
    margin-top: 2em;
}