/* Inventory Grid Styles - Unified with Bag Slots */



/* Mobile Item Menu Styles */
.mobile-item-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(30, 30, 30, 0.98); /* Darker, almost opaque background */
    border: 2px solid #c0a060; /* Golden border */
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.9); /* Stronger shadow */
    z-index: 100000; /* Ensure it's on top of everything */
    padding: 10px; /* Reduced padding */
    display: flex;
    flex-direction: column;
    gap: 8px; /* Reduced gap */
    width: 40%; /* Reduced width by half */
    max-width: 150px; /* Reduced max width by half */
    opacity: 0; /* Start hidden for transition */
    visibility: hidden; /* Hide from screen readers when not visible */
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.mobile-item-menu.visible {
    opacity: 1;
    visibility: visible;
}

.mobile-item-menu .menu-button {
    display: block;
    width: 100%;
    padding: 12px 15px;
    background: #4a3a2a; /* Dark brown/earthy tone for buttons */
    color: #e0e0e0;
    text-decoration: none;
    border-radius: 6px;
    border: 1px solid #6a5a4a;
    box-shadow: 0 3px 5px rgba(0,0,0,0.4);
    transition: background 0.3s ease, transform 0.2s ease;
    font-weight: bold;
    font-family: var(--player-font, 'Cinzel Decorative'), cursive, Arial, sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    font-size: 1em;
}

.mobile-item-menu .destroy-button {
    margin-top: 15px; /* Increased gap above destroy button */
}

.mobile-item-menu .menu-button:hover {
    background: #6a4a3a; /* Lighter brown on hover */
    transform: translateY(-2px);
    box-shadow: 0 5px 8px rgba(0,0,0,0.6);
}

.mobile-item-menu .menu-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 3px rgba(0,0,0,0.4);
}

.mobile-item-menu .destroy-button {
    background: #a03030; /* Reddish for destroy button */
    border-color: #c04040;
}

.mobile-item-menu .destroy-button:hover {
    background: #c04040;
}

.mobile-item-menu .use-button, .item-context-menu .use-button {
    background: #2d5a27 !important; /* Darker green for use/equip button */
    border-color: #3e7a36 !important;
}

.mobile-item-menu .use-button:hover, .item-context-menu .use-button:hover {
    background: #3e7a36 !important;
}

.item-context-menu .use-button.destroy-button {
    background: #a03030 !important; /* Reddish for destroy button, overriding !important green */
    border-color: #c04040 !important;
}

.item-context-menu .use-button.destroy-button:hover {
    background: #c04040 !important;
}

.mobile-item-menu .use-button:disabled, .item-context-menu .use-button:disabled {
    background: #2a2a2a !important;
    border-color: #444 !important;
    color: #666 !important;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.mobile-item-menu .close-button {
    margin-top: 8px; /* Increased gap above close button */
    background: #4a3a2a; /* Dark brown/earthy tone for close button */
    border-color: #6a5a4a;
}

.mobile-item-menu .close-button:hover {
    background: #6a4a3a;
}

/* Adjustments for smaller screens */
@media (max-width: 480px) {
    .mobile-item-menu {
        width: 90%;
        padding: 10px;
        gap: 8px;
    }
    .mobile-item-menu .menu-button {
        font-size: 0.9em;
        padding: 10px 12px;
    }
}

/* Pilnas inventoriaus atidarymas (ne SPA): apačios erdvė kaip su paslėpta bottom-nav + mažiau flex suspaudimo */
body.inventory-standalone {
    box-sizing: border-box;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
}

@media (max-width: 768px) {
    body.inventory-standalone {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.inventory-standalone #app-view.container {
        flex-shrink: 0;
        align-self: flex-start;
    }
}

/* Styles moved from inventory/player_inventory.php */
.inventory-container-wrapper {
    display: flex;
    flex-direction: column; /* Arrange inventory and bag slots vertically */
    align-items: center; /* Center content horizontally */
    gap: 5px; /* Reduced space between inventory and bag slots */
    margin-top: 10px; /* Reduced top margin */
}

/* Inventoriaus skyrių iššokantis langas kairėje (kaip pokalbis dešinėje) */
body.inv-section-drawer-open {
    overflow: hidden;
}

.inv-section-drawer-button {
    position: fixed;
    left: 0;
    top: 40%;
    transform: translateY(-50%);
    z-index: 5000;
    width: 3vw;
    min-width: 35px;
    max-width: 55px;
    height: 3.5vw;
    min-height: 40px;
    max-height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #a08040, #c0a060, #a08040);
    border: 1px solid #6a5a4a;
    border-left: none;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
    cursor: pointer;
    padding: 0;
    color: #fff;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s ease, visibility 0.1s ease;
}

.inv-section-drawer-button.positioned {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 769px) {
    /* PC: veidrodinis chat mygtukui — apvalumas kairėje (išorė), tiesus kraštas prie konteinerio dešinėje */
    #app-view.spa-view-inventory.container .inv-section-drawer-button {
        position: fixed;
        top: 200px;
        transform: translateY(0);
        width: 44px;
        height: 50px;
        min-width: 44px;
        min-height: 50px;
        max-width: 44px;
        max-height: 50px;
        z-index: 6000;
        border: 1px solid #6a5a4a;
        border-right: none;
        border-radius: 0;
        border-top-left-radius: 10px;
        border-bottom-left-radius: 10px;
    }
}

.inv-section-drawer-button:active {
    transform: translateY(-50%) scale(0.98);
}

@media (min-width: 769px) {
    #app-view.spa-view-inventory.container .inv-section-drawer-button:active {
        transform: translateY(0) scale(0.98);
    }
}

.inv-section-drawer-button-icon {
    font-size: 15px;
    line-height: 1;
}

.inv-section-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 6000;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(1px);
}

.inv-section-drawer {
    position: fixed;
    /* top/left nustato JS — šalia mažo kairiojo mygtuko */
    z-index: 7000;
    width: min(198px, calc(100vw - 16px));
    max-width: 198px;
    height: auto;
    max-height: min(260px, 42vh);
    background: linear-gradient(180deg, rgba(38, 34, 29, 0.99), rgba(22, 22, 22, 0.99));
    border: 1px solid rgba(106, 90, 74, 0.95);
    border-radius: 12px;
    box-shadow:
        4px 6px 18px rgba(0, 0, 0, 0.5),
        0 0 12px rgba(192, 160, 96, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.inv-section-drawer.hidden,
.inv-section-drawer-overlay.hidden {
    display: none !important;
}

.inv-section-drawer-tabs {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    flex-direction: column;
    justify-content: flex-start;
    flex-wrap: nowrap;
    max-width: none;
    padding: 8px;
    gap: 6px;
}

.inv-section-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(106, 90, 74, 0.75);
    background: linear-gradient(180deg, rgba(62, 50, 36, 0.82), rgba(24, 22, 20, 0.72));
    flex-shrink: 0;
}

.inv-section-drawer-title {
    color: #c0a060;
    font-weight: bold;
    letter-spacing: 0.3px;
    font-size: 0.82rem;
}

.inv-section-drawer-close {
    width: 28px;
    height: 28px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #4a3a2a;
    color: #e0e0e0;
    border: 1px solid #6a5a4a;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.inv-section-drawer-close:hover {
    background: #6a4a3a;
}

.inv-section-drawer-tab {
    flex: 0 0 auto;
    width: 100%;
    text-transform: none;
    letter-spacing: 0.02em;
    border-radius: 8px !important;
    justify-content: center;
    padding: 8px 10px !important;
    font-size: 0.74rem !important;
    min-height: 32px !important;
}


.inventory-tab-switcher {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    max-width: calc(5 * 45px + 4 * 5px + 10px);
    box-sizing: border-box;
    margin-bottom: 2px;
}

.inventory-tab-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 6px 14px;
    border: 1px solid rgba(192, 160, 96, 0.55);
    border-radius: 999px;
    background: rgba(42, 42, 42, 0.95);
    color: #d6c39a;
    font-size: 0.78rem;
    font-weight: bold;
    letter-spacing: 0.04em;
    text-decoration: none;
    text-transform: uppercase;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.inventory-tab-button.inventory-page-tab {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    cursor: pointer;
    font-family: var(--player-font, 'Cinzel Decorative'), cursive, Arial, sans-serif;
    box-sizing: border-box;
}

.inventory-tab-button:hover {
    background: rgba(74, 58, 42, 0.95);
    color: #f1dfb6;
    transform: translateY(-1px);
}

.inventory-tab-button.active {
    background: linear-gradient(180deg, rgba(192, 160, 96, 0.25), rgba(88, 67, 35, 0.95));
    color: #fff3cc;
    box-shadow: 0 0 8px rgba(192, 160, 96, 0.28);
}

.inventory-page-tab {
    flex: 1 1 auto;
    min-width: 0;
    padding-inline: 10px;
}

.inventory-tab-panel {
    display: none;
    width: 100%;
}

.inventory-tab-panel.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.currency-tab-panel,
.reputation-tab-panel {
    width: calc(5 * 45px + 4 * 5px + 10px);
}

.inventory-tab-placeholder {
    width: 100%;
    padding: 14px 12px;
    border: 1px dashed rgba(192, 160, 96, 0.35);
    border-radius: 10px;
    background: rgba(24, 24, 24, 0.88);
    color: #b9ab87;
    font-size: 0.88rem;
    text-align: center;
    box-sizing: border-box;
}

.currency-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
}

.currency-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
    border: 1px solid rgba(192, 160, 96, 0.25);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(48, 40, 30, 0.95), rgba(28, 28, 28, 0.98));
    box-sizing: border-box;
}

.currency-card-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
    width: 100%;
    text-align: center;
}

.currency-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(192, 160, 96, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.22);
    flex-shrink: 0;
}

.currency-icon-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.currency-icon-fallback {
    color: #d6c39a;
    font-size: 1.1rem;
    font-weight: bold;
    line-height: 1;
}

.currency-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    width: 100%;
}

.currency-name {
    color: #f2e3bd;
    font-size: 0.78rem;
    font-weight: bold;
    line-height: 1.2;
    word-break: break-word;
    text-align: center;
}

.currency-code {
    color: #a89a78;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
}

.currency-amount {
    color: #ffe8a6;
    font-size: 0.88rem;
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
}

.currency-empty-state {
    width: 100%;
    padding: 14px 12px;
    border: 1px dashed rgba(192, 160, 96, 0.35);
    border-radius: 10px;
    background: rgba(24, 24, 24, 0.88);
    color: #b9ab87;
    font-size: 0.88rem;
    text-align: center;
    box-sizing: border-box;
}

.mount-slot-container {
    display: flex;
    justify-content: center;
    width: calc(5 * 45px + 4 * 5px + 10px);
    box-sizing: border-box;
}

.mount-slot {
    width: 45px;
    height: 45px;
}

.mount-status-badge {
    position: absolute;
    top: 1px;
    left: 1px;
    z-index: 12;
    padding: 0 3px;
    border-radius: 2px;
    font-size: 7px !important;
    line-height: 1.1;
    font-weight: bold;
    font-family: Arial, sans-serif;
    color: #fff !important;
    pointer-events: none;
    text-transform: uppercase;
}

.mount-status-on {
    background-color: rgba(36, 122, 47, 0.92);
    border: 1px solid rgba(122, 219, 140, 0.85);
}

.mount-status-off {
    background-color: rgba(133, 33, 33, 0.92);
    border: 1px solid rgba(235, 128, 128, 0.85);
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(5, 45px); /* 5 columns, 45px each */
    grid-auto-rows: 45px; /* 45px height for rows */
    gap: 5px; /* Gap between slots */
    width: calc(5 * 45px + 4 * 5px + 10px); /* 5 slots + 4 gaps + 10px padding */
    border: 1px solid #555;
    padding: 5px;
    background-color: #222;
    box-sizing: border-box;
}

/* Specific styles for the buff grid on the characteristics page */
.character-grid.inventory-grid {
    grid-template-columns: repeat(5, 45px); /* Ensure 5 columns, 45px each */
    max-height: calc(2 * 45px + 1 * 5px + 10px); /* 2 rows of 45px slots + 1 gap + 10px padding */
    overflow-y: auto;
    overflow-x: hidden; /* Hide horizontal scrollbar */
    margin-top: 10px; /* Add some top margin for separation */
    border-radius: 8px; /* Slightly rounded corners */
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5); /* Inner shadow for depth */
}

.inventory-slot, .bag-slot {
    width: 45px;
    height: 45px;
    /* border: 1px solid #555; */ /* Pašalintas apvadas */
    background-color: #2a2a2a; /* Changed to dark grey */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 0.6em;
    text-align: center;
    position: relative;
    /* Removed overflow: hidden for debugging */
    box-sizing: border-box;
    border-radius: 4px;
    /* Hide any direct text content within inventory-slot that is not explicitly styled */
    font-size: 0; /* Hide text content */
}

.inventory-slot .buff-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: initial; /* Re-enable font size for content inside buff-content */
    position: relative;
}

.inventory-slot .buff-content img {
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.inventory-slot .buff-content .buff-timer {
    position: absolute;
    bottom: 1px;
    right: 1px;
    background-color: rgba(0, 0, 0, 0.13);
    color: #fff;
    font-size: 0.65em !important; /* Adjusted font size for timer */
    padding: 1px 3px; /* Adjusted padding */
    border-radius: 3px;
    font-weight: bold;
    pointer-events: none;
    z-index: 2;
    white-space: nowrap; /* Ensure text stays on one line */
    font-family: Arial, sans-serif; /* Set font to Arial */
}

.inventory-slot.has-item, .bag-slot.has-item {
    /* border-color: #a0a0a0; */ /* Pašalintas apvado spalvos nustatymas */
    background-color: #444;
    cursor: pointer;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

.inventory-slot.has-item:hover, .bag-slot.has-item:hover {
    background-color: #555;
    border-color: #c0a060;
}

.inventory-slot img, .bag-slot img {
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.item-quantity {
    position: absolute;
    bottom: 1px;
    right: 1px;
    background-color: rgba(0, 0, 0, 0.8);
    color: rgb(218, 218, 218) !important; /* Changed to yellow for high contrast */
    font-size: 11px !important; /* Increased font size significantly for testing */
    line-height: 1; /* Ensure line height doesn't cause issues */
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: bold;
    pointer-events: none;
    z-index: 10; /* Increased z-index to ensure visibility */
    display: flex; /* Use flexbox for centering */
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
    white-space: nowrap; /* Prevent text from wrapping */
    min-width: 10px; /* Ensure minimum width */
    min-height: 10px; /* Ensure minimum height */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.9); /* Stronger text shadow for visibility */
    background-color: rgba(2, 2, 2, 0.315) !important; /* Added red background for extreme contrast */
    font-family: Arial, sans-serif !important; /* Explicitly set a common font */
}

.bag-slots-container {
    display: flex;
    flex-direction: row; /* Arrange bag slots horizontally */
    flex-wrap: nowrap; /* Keep bags in one line */
    justify-content: space-between; /* Distribute bags evenly */
    gap: 5px;
    border: 1px solid #555;
    padding: 5px;
    background-color: #222;
    width: calc(5 * 45px + 4 * 5px + 10px); /* 5 slots + 4 gaps + 10px padding */
    box-sizing: border-box;
}

.belt-use-slots-section {
    display: none;
}

.bag-slot.locked {
    background-color: #1a1a1a; /* Darker background for locked slots */
    border-color: #444; /* Darker border */
    cursor: not-allowed;
    position: relative;
}
.bag-slot.locked img {
    filter: brightness(0.7);
}
.bag-slot.locked .locked-bag-icon {
    filter: hue-rotate(330deg) saturate(300%) brightness(70%); /* Redder tint for locked bag icon */
    opacity: 0.7; /* Keep some opacity for the locked look */
}


/* Removed .bag-slot-label as per user request */

/* Layered Item Styles */
.inventory-slot.item-container {
    position: relative;
    width: 45px; /* Match inventory-slot width */
    height: 45px; /* Match inventory-slot height */
    overflow: hidden; /* Ensure layers don't spill out */
    display: flex; /* Use flex to center content */
    align-items: center;
    justify-content: center;
    font-size: 0; /* Hide any default text content */
}

.item-combined-image {
    width: 100%;
    height: 100%;
    object-fit: fill; /* Ensure the combined image fills the slot */
}

/* Specific styles for item icons within the info modal to ensure correct sizing */
.info-modal-content-wrapper .item-container {
    width: 45px !important;
    height: 45px !important;
    min-width: 45px !important;
    min-height: 45px !important;
    max-width: 45px !important;
    max-height: 45px !important;
    /* border: 1px solid #aaa; */ /* Pašalintas apvadas */
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    position: relative !important;
}

.info-modal-content-wrapper .item-container .item-combined-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

@media (max-width: 480px) {
    .inv-section-drawer-tab {
        font-size: 0.78rem;
        padding: 10px 12px !important;
    }

    .inventory-tab-switcher,
    .currency-tab-panel,
    .reputation-tab-panel {
        width: 100%;
        max-width: calc(5 * 45px + 4 * 5px + 10px);
    }

    .inventory-tab-button {
        font-size: 0.72rem;
        padding: 6px 10px;
    }

    .currency-card {
        padding: 6px 4px;
    }

    .currency-name {
        font-size: 0.74rem;
    }

    .currency-amount {
        font-size: 0.84rem;
    }
}
