/**
 * Inventory Popup Styles
 * Version: 1.0
 * Design colors:
 * - Button background: #FE3700
 * - Button border: #A41B00
 * - Text: white
 */

/* ===== Backdrop ===== */
.inventory-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1100;
    justify-content: center;
    align-items: center;
}

.inventory-backdrop.active {
    display: flex;
}

/* ===== Main Container ===== */
.inventory-popup {
    background: transparent;
    width: 90%;
    max-width: 450px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ===== Header (floating outside) ===== */
.inventory-header {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 0 10px 0;
    background: transparent;
}

.inventory-title-img {
    height: 100px;
    width: auto;
}

.inventory-close-btn {
    position: absolute;
    right: 0;
    top: 20px;
    width: 45px;
    height: 45px;
    cursor: pointer;
    transition: transform 0.2s;
}

.inventory-close-btn:hover {
    transform: scale(1.1);
}

.inventory-close-btn:active {
    transform: scale(0.95);
}

/* ===== Tabs ===== */
.inventory-tabs {
    display: flex;
    gap: 8px;
    padding: 0 10px;
    justify-content: center;
    margin-bottom: 0;
}

.inventory-tab {
    flex: 1;
    padding: 12px 10px;
    font-family: 'Prompt', sans-serif;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-align: center;
    border: none;
    border-radius: 10px 10px 0 0;
    /* Inactive style: light pink background */
    background: #FFE4E1;
    color: #DF9595;
}

.inventory-tab:hover {
    background: #FFCEC9;
    color: #DA3732;
}

.inventory-tab.active {
    background: #DA3732;
    color: #fff;
}

/* ===== Content Wrapper (red border) ===== */
.inventory-content-wrapper {
    margin: 0;
    border: 3px solid #DA3732;
    border-radius: 15px;
    overflow: hidden;
    background: #fff;
}

/* ===== Content Area ===== */
.inventory-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    min-height: 280px;
    max-height: 380px;
    background: #fff;
}

/* ===== Item List ===== */
.inventory-item {
    display: flex;
    align-items: center;
    background: #f0f0f0;
    border-radius: 15px;
    padding: 10px 15px;
    margin-bottom: 8px;
}

.inventory-item-icon {
    width: 55px;
    height: 55px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    padding: 5px;
    flex-shrink: 0;
}

.inventory-item-info {
    flex: 1;
    margin-left: 12px;
    min-width: 0;
}

.inventory-item-name {
    font-family: 'Prompt', sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: #333;
    margin: 0;
}

.inventory-item-status {
    font-family: 'Prompt', sans-serif;
    font-size: 12px;
    color: #888;
    margin: 2px 0 0 0;
}

.inventory-item-status.placed {
    color: #28a745;
    font-weight: 500;
}

.inventory-item-status.unavailable {
    color: #dc3545;
    font-size: 11px;
}

.inventory-item-quantity {
    font-family: 'Prompt', sans-serif;
    font-size: 14px;
    color: #666;
    margin-right: 10px;
}

/* ===== Action Buttons ===== */
.inventory-item-btns {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.inventory-item-btn {
    padding: 8px 14px;
    border-radius: 20px;
    font-family: 'Prompt', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.inventory-item-btn.use {
    background: #FE3700;
    color: #fff;
    border: 2px solid #A41B00;
}

.inventory-item-btn.use:hover {
    background: #e63200;
    transform: scale(1.05);
}

.inventory-item-btn.use:active {
    transform: scale(0.95);
}

.inventory-item-btn.cancel {
    background: #888;
    color: #fff;
    border: 2px solid #666;
}

.inventory-item-btn.cancel:hover {
    background: #777;
    transform: scale(1.05);
}

.inventory-item-btn.switch {
    background: #5a7fcf;
    color: #fff;
    border: 2px solid #3d5aa9;
}

.inventory-item-btn.switch:hover {
    background: #4a6fbc;
    transform: scale(1.05);
}

.inventory-item-btn.switch:active {
    transform: scale(0.95);
}

.inventory-item-btn.disabled {
    background: #ccc;
    color: #999;
    border: 2px solid #bbb;
    cursor: not-allowed;
}

.inventory-item-btn.disabled:hover {
    transform: none;
}

/* ===== Empty State ===== */
.inventory-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #999;
}

.inventory-empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.inventory-empty-text {
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    text-align: center;
}

/* ===== Pagination ===== */
.inventory-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #eee;
}

.inventory-page-btn {
    padding: 8px 25px;
    border-radius: 25px;
    font-family: 'Prompt', sans-serif;
    font-size: 14px;
    cursor: pointer;
    border: 2px solid #ddd;
    background: #fff;
    color: #888;
    transition: all 0.2s ease;
}

.inventory-page-btn:hover:not(:disabled) {
    border-color: #FE3700;
    color: #FE3700;
}

.inventory-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.inventory-page-info {
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    color: #333;
    min-width: 40px;
    text-align: center;
}

/* ===== Loading State ===== */
.inventory-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
}

.inventory-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #FE3700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.inventory-loading-text {
    font-family: 'Prompt', sans-serif;
    font-size: 14px;
    color: #666;
    margin-top: 15px;
}

/* ===== Scrollbar ===== */
.inventory-content::-webkit-scrollbar {
    width: 6px;
}

.inventory-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.inventory-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.inventory-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ===== Energy Warning Overlay ===== */
.inventory-warning-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 15px;
    animation: fadeIn 0.2s ease-out;
}

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

.inventory-energy-warning {
    background: #fff;
    padding: 25px 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 280px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.inventory-energy-warning .warning-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.inventory-energy-warning .warning-message {
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.5;
}

.inventory-energy-warning .warning-close-btn {
    background: #DA3732;
    color: #fff;
    border: none;
    padding: 10px 30px;
    border-radius: 20px;
    font-family: 'Prompt', sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.inventory-energy-warning .warning-close-btn:hover {
    background: #c23732;
}

/* ===== Success Highlight Animation ===== */
@keyframes successPulse {
    0% {
        background-color: #f0f0f0;
        transform: scale(1);
    }
    25% {
        background-color: #d4edda;
        transform: scale(1.02);
        box-shadow: 0 0 15px rgba(40, 167, 69, 0.4);
    }
    50% {
        background-color: #c3e6cb;
    }
    100% {
        background-color: #f0f0f0;
        transform: scale(1);
        box-shadow: none;
    }
}

@keyframes successCheck {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
    100% {
        opacity: 0;
        transform: scale(1);
    }
}

.inventory-item.success-highlight {
    animation: successPulse 0.8s ease-out;
}

.inventory-item.success-highlight::after {
    content: '\2713';
    position: absolute;
    right: 100px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 28px;
    color: #28a745;
    font-weight: bold;
    animation: successCheck 0.8s ease-out forwards;
    pointer-events: none;
    z-index: 10;
}

.inventory-item {
    position: relative;
}

/* ===== Mobile Responsive ===== */
@media screen and (max-width: 480px) {
    .inventory-popup {
        width: 95%;
        max-height: 90vh;
    }

    .inventory-header {
        padding: 0 0 5px 0;
    }

    .inventory-title-img {
        height: 70px;
    }

    .inventory-close-btn {
        width: 40px;
        height: 40px;
        top: 10px;
    }

    .inventory-tabs {
        padding: 0 5px;
        gap: 3px;
        margin-bottom: -1px; /* เชื่อม tab กับ content */
    }

    .inventory-tab {
        padding: 10px 8px;
        font-size: 14px;
        border-radius: 8px 8px 0 0;
    }

    .inventory-content-wrapper {
        border-radius: 12px;
        border-top-left-radius: 0;
    }

    .inventory-content {
        padding: 8px 10px;
        min-height: 250px;
    }

    .inventory-item {
        padding: 10px 12px;
    }

    .inventory-item-icon {
        width: 50px;
        height: 50px;
    }

    .inventory-item-name {
        font-size: 16px;
    }

    .inventory-item-btns {
        gap: 3px;
    }

    .inventory-item-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .inventory-item.success-highlight::after {
        right: 80px;
        font-size: 24px;
    }
}

/* ===== Section Headers ===== */
.inventory-section {
    margin-bottom: 15px;
}

.inventory-section-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
}

.inventory-section-title {
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* ===== Skin Grid ===== */
.inventory-skin-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 5px;
}

.inventory-skin-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    background: #f5f5f5;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    position: relative;
}

.inventory-skin-item:hover:not(.locked) {
    background: #e8e8e8;
    transform: translateY(-2px);
}

.inventory-skin-item.active {
    background: #FFE8E5;
    border-color: #DA3732;
}

.inventory-skin-item.locked {
    background: #e0e0e0;
    opacity: 0.6;
    cursor: not-allowed;
}

.inventory-skin-icon {
    width: 50px;
    height: 50px;
    object-fit: contain;
    margin-bottom: 5px;
}

.inventory-skin-icon-placeholder {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #f8f8f8 0%, #e8e8e8 100%);
    border: 2px solid #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Prompt', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #888;
    margin-bottom: 5px;
}

.inventory-skin-name {
    font-family: 'Prompt', sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: #333;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.inventory-skin-item.locked .inventory-skin-name {
    color: #888;
}

.inventory-skin-check {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    background: #DA3732;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* Skin highlight animation */
.inventory-skin-item.success-highlight {
    animation: skinPulse 0.8s ease-out;
}

@keyframes skinPulse {
    0% {
        transform: scale(1);
        box-shadow: none;
    }
    25% {
        transform: scale(1.05);
        box-shadow: 0 0 15px rgba(40, 167, 69, 0.5);
    }
    50% {
        background-color: #c3e6cb;
    }
    100% {
        transform: scale(1);
        box-shadow: none;
    }
}

/* Mobile: 3 columns */
@media screen and (max-width: 480px) {
    .inventory-skin-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .inventory-skin-item {
        padding: 10px 5px;
    }

    .inventory-skin-icon,
    .inventory-skin-icon-placeholder {
        width: 40px;
        height: 40px;
    }

    .inventory-skin-icon-placeholder {
        font-size: 12px;
    }

    .inventory-skin-name {
        font-size: 10px;
    }

    .inventory-section-title {
        font-size: 14px;
    }
}
