/* Collection Page Styles */

/* Collection Grid */
.collection-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    min-height: 300px;
}

/* Collection Controls */
.collection-controls {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    align-items: center;
}

#collection .search-bar-container {
    flex-grow: 1;
    margin: 0;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 20px 0;
}

.pagination button {
    background-color: #2a2a3a; /* A slightly lighter shade of the background */
    border: 1px solid var(--border-color, #444);
    color: var(--text-color, #ccc);
    padding: 8px 14px;
    margin: 0 2px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Titillium Web', sans-serif;
    font-size: 1rem;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.pagination button:hover {
    background-color: var(--border-color, #444);
    border-color: var(--accent-color, #ff9900);
    color: #fff;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #222;
}

.pagination button.active {
    background-color: var(--accent-color, #ff9900);
    color: var(--primary-bg, #1a1a2a); /* Dark text on bright button */
    border-color: var(--accent-color, #ff9900);
    font-weight: 700;
}

.pagination span {
    color: var(--text-secondary, #888);
    padding: 0 5px;
    align-self: center;
}

/* Promotion Controls in Modal */
/* --- Promotion Stars Styles --- */
.promotion-controls {
    background-color: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 20px;
}

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

.promotion-header .modal-section-title {
    margin: 0;
    padding: 0;
    border: none;
}

.promotion-level-text {
    font-family: var(--font-header);
    font-weight: 600;
    color: #ccc;
    font-size: 1rem;
}

.promotion-stars-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 15px 0;
}

.promotion-star {
    position: relative;
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 0 3px rgba(0,0,0,0.8));
}

.star-chunk {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--border-color);
    transition: background-color 0.4s ease;
}

.star-chunk.filled {
    background-color: #d93a3a;
}

/* 5-pointed star chunks using clip-path */
.star-chunk.chunk-1 { /* Top point */
    clip-path: polygon(50% 0%, 61% 35%, 39% 35%);
}
.star-chunk.chunk-2 { /* Right arm */
    clip-path: polygon(61% 35%, 98% 35%, 68% 57%);
}
.star-chunk.chunk-3 { /* Bottom-right leg */
    clip-path: polygon(68% 57%, 79% 91%, 50% 70%);
}
.star-chunk.chunk-4 { /* Bottom-left leg */
    clip-path: polygon(50% 70%, 21% 91%, 32% 57%);
}
.star-chunk.chunk-5 { /* Left arm */
    clip-path: polygon(32% 57%, 2% 35%, 39% 35%);
}

.promotion-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.promotion-buttons button {
    padding: 10px;
    border-radius: 5px;
    font-family: var(--font-header);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
}

.btn-promote {
    background-color: var(--accent-color);
    border: 1px solid var(--accent-color);
    color: var(--primary-bg);
}
.btn-promote:hover {
    background-color: #ffaf33;
    transform: translateY(-2px);
}

.btn-reset {
    background: none;
    border: 1px solid #ff5555;
    color: #ff5555;
}
.btn-reset:hover {
    background-color: rgba(255, 85, 85, 0.2);
    color: #ff8888;
}

/* Level Simulation */
.level-sim {
    background-color: rgba(255, 153, 0, 0.1) !important;
    border-color: var(--accent-color) !important;
}

.level-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background-color: rgba(0,0,0,0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.level-value {
    font-weight: 600;
    font-family: var(--font-header);
    font-size: 1.1rem;
    min-width: 2ch;
    text-align: center;
    color: var(--accent-color);
    padding: 0 var(--spacing-xs);
}

/* No Results */
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 0;
    color: #aaa;
    font-style: italic;
    font-size: 1rem;
}
@media (max-width: 380px) {
    .rarity-filter-btn,
    .faction-filter-btn {
        font-size: x-small;
        padding: 4px 8px;
    }

    .ship-skill-layout
    {
        gap: 0 !important;
        padding: 0 !important;
    }
    .skill-icon
    {
        width: 55px;
        height: 55px;
        margin-bottom: 0.5em;
    }
    .skill-node
    {
        width: 65px;
    }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .collection-controls {
        gap: var(--spacing-sm);
    }

    .ship-skill-layout{
        gap: 0 !important;
        padding: 0 !important;
    }

    .turret-selection-grid
    {
        --radius: 150px;
    }

    .rarity-filter-btn,
    .faction-filter-btn {
        font-size: 0.69em;
        padding: 4px 8px;
    }
    
    .category-filters {
        order: 1;
        align-self: stretch;
        justify-content: center;
    }
    
    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pagination-btn {
        min-width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
    
    .promotion-stars-container {
        gap: var(--spacing-xs);
    }
    
    .star-chunk {
        width: 35px;
        height: 35px;
    }
    .modal-attributes, .modal-skills {
        gap: 0;
    }
}

/* Add this new block of CSS for the ship skill layout. */

.ship-skill-container {
    margin-top: var(--spacing-lg);
    position: relative;
}

.ship-skill-layout {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: var(--spacing-sm);
    align-items: center;
    justify-items: center;
    background-color: rgba(0,0,0,0.2);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    min-height: 240px;
}

.ship-skill-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    min-height: 90px; /* Ensures a consistent minimum size */
    height: auto;
    cursor: pointer;
    text-align: center;
    width: 80px;
    transition: transform var(--transition-fast);
}
.ship-skill-node:hover {
    transform: scale(1.05);
}

.ship-skill-node .skill-icon {
    width: 60px;
    height: 60px;
    background-color: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
}

.ship-skill-node .skill-level-display {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: var(--radius-sm);
}

.ship-skill-node:hover .skill-icon {
    border-color: var(--accent-color);
}

.ship-skill-node .skill-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-color);
    
    /* Add only if these specific rules don't exist yet */
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
    min-height: 2.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
}

.ship-skill-node.turret .skill-icon {
    background-size: 80% !important; /* Adjusts the icon to fit nicely within the new padding */
    background-repeat: no-repeat;
}

.skill-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px; /* Optional: to match container's rounded corners */
}

/* Grid placement based on your sketch */
.ship-skill-node[data-slot="1"] { grid-area: 1 / 1; }
.ship-skill-node[data-slot="2"] { grid-area: 1 / 3; }
.ship-skill-node[data-slot="3"] { grid-area: 3 / 1; }
.ship-skill-node[data-slot="4"] { grid-area: 3 / 3; }
.ship-skill-node.turret { grid-area: 2 / 2; }

/* --- Shared Ship Skill Node Layout (Corrected for Sizing) --- */

/* This targets ship skill nodes in both the collection and config modals */
#modal-content .ship-skill-node,
.modal-content-config .ship-skill-node {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center; /* Horizontally center content */
    width: 110px; /* Give the container a bit of extra width */
}

/* This increases the size of the icon itself */
#modal-content .ship-skill-node .skill-icon,
.modal-content-config .ship-skill-node .skill-icon {
    width: 80px;
    height: 80px;
}

#modal-content .ship-skill-node .skill-name,
.modal-content-config .ship-skill-node .skill-name {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: var(--spacing-xs);
    margin: 0.2em;
}

#modal-content .ship-skill-node .skill-level-display,
.modal-content-config .ship-skill-node .skill-level-display {
    position: static;
    font-family: var(--font-header);
    margin: 0 auto;
    background: none;
    font-weight: normal;
    padding-top: var(--spacing-xs);
}

/* --- Filter Containers & Buttons (Final Layout) --- */

/*Agents*/

#modal-overlay .modal-category-gear .modal-portrait
{
    width: 100%;
}

/* --- Agent Card Coloring --- */
.card-info .agent-type {
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.75rem;
}

.agent-type-offense { background-color: #b33939; }
.agent-type-defense { background-color: #227093; }
.agent-type-support { background-color: #218c74; }

.card-info .agent-level {
    font-style: italic;
    color: var(--text-color-secondary);
    font-size: 0.8rem;
}

/* This section styles the parent containers for the button groups */
#rarity-filters,
#faction-filters {
    display: flex; /* Changed to flex for rarity, grid for faction below */
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

/* This rule forces rarity buttons onto a single, scrollable line */
#rarity-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 10px;
    /* Add this line to create space at the end of the list */
    padding-right: var(--spacing-sm, 8px); 
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#rarity-filters::-webkit-scrollbar {
    display: none; /* For Chrome, Safari, and Opera */
}

/* This rule uses CSS Grid for a perfectly aligned layout for faction buttons */
#faction-filters {
    display: grid;
    /* Creates responsive columns that are at least 110px wide */
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}

/* This is the base style for all filter buttons */
.rarity-filter-btn,
.faction-filter-btn {
    padding: 6px 13px;
    border: 2px solid transparent;
    border-left-width: 4px;
    border-left-style: solid;
    border-radius: var(--radius-sm);
    background-color: rgba(30, 30, 30, 0.6);
    font-weight: 600;
    text-align: center; /* Ensures text is centered within grid cells */
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0; /* Prevents rarity buttons from shrinking */
}

.rarity-filter-btn:hover:not(.active),
.faction-filter-btn:hover:not(.active) {
    background-color: rgba(45, 45, 45, 0.9);
    transform: translateY(-1px);
}

/* Generic active state: adds right border and brightens text */
.rarity-filter-btn.active,
.faction-filter-btn.active {
    border-right-width: 4px;
    border-right-style: solid;
    color: #ffffff;
    transform: translateY(-1px);
}


/* --- Rarity Specific Colors & Styles --- */

/* This rule styles the inactive "All" button with a gray left border */
#rarity-filters .rarity-filter-btn[data-rarity="all"] {
    border-left-color: var(--border-color);
    color: var(--text-color-secondary, #aaa);
}

/* This rule styles the active "All" button with the main accent color */
#rarity-filters .rarity-filter-btn[data-rarity="all"].active {
    border-left-color: var(--light_border-color);
    border-right-color: var(--light_border-color);
    background-color: rgba(255, 153, 0, 0.15);
    color: var(--light_border-color);
}

/* Rarity button inactive states (sets left border and text color) */
#rarity-filters .rarity-filter-btn[data-rarity="common"] { border-left-color: #11ed27; color: #11ed27; }
#rarity-filters .rarity-filter-btn[data-rarity="rare"] { border-left-color: #13a3e1; color: #13a3e1; }
#rarity-filters .rarity-filter-btn[data-rarity="epic"] { border-left-color: #a335ee; color: #a335ee; }
#rarity-filters .rarity-filter-btn[data-rarity="legendary"] { border-left-color: #ff9900; color: #ff9900; }

/* Rarity button active states (sets right border and background) */
#rarity-filters .rarity-filter-btn[data-rarity="common"].active { border-right-color: #11ed27; background-color: rgba(17, 237, 39, 0.1); }
#rarity-filters .rarity-filter-btn[data-rarity="rare"].active { border-right-color: #13a3e1; background-color: rgba(19, 163, 225, 0.1); }
#rarity-filters .rarity-filter-btn[data-rarity="epic"].active { border-right-color: #a335ee; background-color: rgba(163, 53, 238, 0.1); }
#rarity-filters .rarity-filter-btn[data-rarity="legendary"].active { border-right-color: #ff9900; background-color: rgba(255, 153, 0, 0.1); }


/* --- Faction Buttons --- */

/* Inactive State for all faction buttons */
#faction-filters .faction-filter-btn {
    border-left-color: var(--border-color);
    color: var(--text-color-secondary, #aaa);
}

/* Active state now correctly uses your --light_border_color variable */
#faction-filters .faction-filter-btn.active {
    border-left-color: var(--light_border_color);
    border-right-color: var(--light_border_color);
    background-color: rgba(255, 153, 0, 0.1);
    color: var(--light_border_color);
}
/*Styling for bug warnings*/
/* Update the bug-warning rule */
.bug-warning {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    cursor: pointer;
    z-index: 5;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* Remove the old .bug-warning .bug-description and .bug-warning.expanded rules */

/* Add this new rule for the modal content */
.bug-warning-modal {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.bug-warning-modal #bug-warning-close-btn {
    margin-top: var(--spacing-lg);
    align-self: center;
}

.bug-warning-modal h3 {
    color: #ffdd44;
    margin-bottom: var(--spacing-md);
}

.bug-warning-modal p {
    color: var(--text-color-secondary);
}

#bug-warning-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: calc(var(--z-modal) + 10);
    border-radius: var(--radius-xl);
    overflow: hidden;
    /* THE FIX: Add flex properties to center the content */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
}

.bug-warning-modal-container {
    max-width: 320px;
    /* THE FIX: Use width instead of max-height for better scaling */
    width: 100%; 
    /* THE FIX: Add a background color to the card itself */
    background-color: var(--secondary-bg);
}

/* --- Skill Name Display Fix --- */

/* 1. Make the main node a flex container */
.ship-skill-node,
.skill-node {
    display: flex;
    flex-direction: column;
    height: 100%; /* Allow it to fill the grid cell */
}

/* 2. Allow the skill name to grow and take up available space */
.ship-skill-node .skill-name,
.skill-node .skill-name {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
    line-height: 1.2;
    padding-bottom: var(--spacing-xs);
}

/* 3. Ensure the level indicator stays at the bottom */
.ship-skill-node .skill-level-display,
.skill-node .skill-level-display {
    flex-shrink: 0;
    margin-top: auto;
}