/* ==========================================
   🎒 INVENTARIO GRÁFICO — DISEÑO INTEGRAL
   ========================================== */

/* === OVERLAY BASE === */
.inv-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(10, 8, 15, 0.35) 0%, rgba(0, 0, 0, 0.8) 100%);
    backdrop-filter: blur(10px);
    z-index: 20000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #e0d5c0;
    animation: invFadeIn 0.3s ease-out;
}

/* === VENTANA PRINCIPAL === */
.inv-window {
    width: 1200px;
    max-width: 95vw;
    height: 800px;
    max-height: 90vh;
    background: #0d0a08;
    border: 2px solid #5a4632;
    box-shadow: 0 0 80px rgba(0, 0, 0, 1), inset 0 0 40px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
}

/* Esquinas doradas */
.inv-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 2px solid #ccaa4b;
    z-index: 10;
    pointer-events: none;
}
.inv-corner.tl { top: -3px; left: -3px; border-right: none; border-bottom: none; }
.inv-corner.tr { top: -3px; right: -3px; border-left: none; border-bottom: none; }
.inv-corner.bl { bottom: -3px; left: -3px; border-right: none; border-top: none; }
.inv-corner.br { bottom: -3px; right: -3px; border-left: none; border-top: none; }

/* === HEADER === */
.inv-header {
    padding: 14px 22px;
    background: linear-gradient(to bottom, #1a120b, #0d0a08);
    border-bottom: 2px solid #ccaa4b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.inv-title {
    color: #ccaa4b;
    font-size: 1.5rem;
    letter-spacing: 3px;
    text-shadow: 0 0 8px rgba(204, 170, 75, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    font-weight: bold;
}

.inv-title-icon {
    width: 28px;
    height: 28px;
    opacity: 0.9;
}

.inv-gold-display {
    color: #ccaa4b;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 20px;
}

.inv-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inv-btn-close {
    background: none;
    border: none;
    color: #5a4632;
    font-size: 2rem;
    cursor: pointer;
    transition: 0.3s;
    line-height: 1;
    padding: 0 4px;
}

.inv-btn-close:hover {
    color: #ff4d4d;
    transform: rotate(90deg);
}

/* === TABS DE SECCIONES === */
.inv-tabs {
    display: flex;
    background: #0a0705;
    border-bottom: 1px solid #332518;
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.inv-tabs::-webkit-scrollbar {
    display: none;
}

.inv-tab {
    padding: 10px 16px;
    color: #666;
    cursor: pointer;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.inv-tab:hover {
    color: #ccaa4b;
    background: rgba(204, 170, 75, 0.05);
}

.inv-tab.active {
    color: #ccaa4b;
    border-bottom-color: #ccaa4b;
    background: rgba(204, 170, 75, 0.08);
}

.inv-tab-icon {
    font-size: 1rem;
}

.inv-tab-count {
    font-size: 0.65rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 1px 5px;
    border-radius: 8px;
    color: #888;
}

.inv-tab.active .inv-tab-count {
    background: rgba(204, 170, 75, 0.2);
    color: #ccaa4b;
}

/* === BODY (GRID + DETAIL) === */
.inv-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* --- Panel izquierdo: Grid de items --- */
.inv-grid-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #332518;
    min-width: 0;
}

.inv-grid-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    scrollbar-width: thin;
    scrollbar-color: #4b3621 rgba(0, 0, 0, 0.2);
}

.inv-grid-scroll::-webkit-scrollbar {
    width: 6px;
}
.inv-grid-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
.inv-grid-scroll::-webkit-scrollbar-thumb {
    background: #4b3621;
    border-radius: 3px;
}

.inv-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

/* --- Card de item --- */
.inv-item-card {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid #2a1f14;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
    min-height: 90px;
}

.inv-item-card:hover {
    background: rgba(204, 170, 75, 0.08);
    border-color: #5a4632;
    transform: translateY(-2px);
}

.inv-item-card.selected {
    border-color: #ccaa4b;
    background: rgba(204, 170, 75, 0.12);
    box-shadow: 0 0 12px rgba(204, 170, 75, 0.2);
}

/* Bordes por rareza */
.inv-item-card.rarity-common { border-color: #555; }
.inv-item-card.rarity-uncommon { border-color: #1eff00; }
.inv-item-card.rarity-rare { border-color: #0070ff; }
.inv-item-card.rarity-epic { border-color: #a335ee; }
.inv-item-card.rarity-legendary { border-color: #ff8000; }

.inv-item-card.rarity-uncommon:hover { box-shadow: 0 0 8px rgba(30, 255, 0, 0.15); }
.inv-item-card.rarity-rare:hover { box-shadow: 0 0 8px rgba(0, 112, 255, 0.15); }
.inv-item-card.rarity-epic:hover { box-shadow: 0 0 8px rgba(163, 53, 238, 0.15); }
.inv-item-card.rarity-legendary:hover { box-shadow: 0 0 10px rgba(255, 128, 0, 0.2); }

.inv-item-card.selected.rarity-uncommon { border-color: #1eff00; box-shadow: 0 0 12px rgba(30, 255, 0, 0.25); }
.inv-item-card.selected.rarity-rare { border-color: #0070ff; box-shadow: 0 0 12px rgba(0, 112, 255, 0.25); }
.inv-item-card.selected.rarity-epic { border-color: #a335ee; box-shadow: 0 0 12px rgba(163, 53, 238, 0.25); }
.inv-item-card.selected.rarity-legendary { border-color: #ff8000; box-shadow: 0 0 14px rgba(255, 128, 0, 0.3); }

/* === SPRITE SISTEMA === */
.inv-item-img-wrap {
    width: 72px;
    height: 75px;
    overflow: hidden;
    position: relative;
    border-radius: 6px;
    background: rgba(0,0,0,0.3);
    border: 2px solid rgba(65, 65, 65, 0.05);
    flex-shrink: 0;
}

.inv-detail-img-wrap {
    width: 95px;
    height: 100px;
    overflow: hidden;
    position: relative;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #2a1f14;
    margin: 0 auto;
}

.inv-sprite {
    background-image: url('../../assets/img/game/items/items.webp');
    background-size: 900% 500%;
    position: absolute;
}

.inv-item-img-wrap .inv-sprite {
    width: 80px;
    height: 80px;
    top: -5px;
    left: -8px;
}

.inv-detail-img-wrap .inv-sprite {
    width: 106px;
    height: 106px;
    top: -2px;
    left: -10px;
}

/* Fallback img si no usa sprite */
.inv-item-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 4px;
    image-rendering: pixelated;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.05);
}

.inv-item-name {
    font-size: 0.85rem;
    text-align: center;
    color: #ccc;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.inv-item-count {
    position: absolute;
    top: 4px;
    right: 5px;
    font-size: 0.65rem;
    color: #ccaa4b;
    background: rgba(0, 0, 0, 0.7);
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: bold;
}

/* Colores de nombre por rareza */
.inv-item-card.rarity-uncommon .inv-item-name { color: #1eff00; }
.inv-item-card.rarity-rare .inv-item-name { color: #0070ff; }
.inv-item-card.rarity-epic .inv-item-name { color: #a335ee; }
.inv-item-card.rarity-legendary .inv-item-name { color: #ff8000; }

/* --- Panel derecho: Detalle --- */
.inv-detail {
    width: 400px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.3);
    overflow-y: auto;
}

.inv-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #555;
    text-align: center;
    padding: 20px;
    gap: 10px;
}

.inv-detail-empty-icon {
    font-size: 2.5rem;
    opacity: 0.4;
}

.inv-detail-content {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
}

.inv-detail-img-wrap {
    text-align: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    border: 1px solid #2a1f14;
}

.inv-detail-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    image-rendering: pixelated;
    border-radius: 4px;
}

.inv-detail-name {
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    line-height: 1.2;
}

/* Colores de nombre en detalle */
.inv-detail-name.rarity-common { color: #ccc; }
.inv-detail-name.rarity-uncommon { color: #1eff00; }
.inv-detail-name.rarity-rare { color: #0070ff; }
.inv-detail-name.rarity-epic { color: #a335ee; }
.inv-detail-name.rarity-legendary { color: #ff8000; }

.inv-detail-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #888;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.inv-detail-type {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inv-detail-rarity {
    font-weight: bold;
}

.inv-detail-rarity.rarity-common { color: #888; }
.inv-detail-rarity.rarity-uncommon { color: #1eff00; }
.inv-detail-rarity.rarity-rare { color: #0070ff; }
.inv-detail-rarity.rarity-epic { color: #a335ee; }
.inv-detail-rarity.rarity-legendary { color: #ff8000; }

.inv-detail-desc {
    font-size: 0.82rem;
    color: #aaa;
    line-height: 1.5;
    padding: 8px 0;
    border-top: 1px solid #1a1510;
}

.inv-detail-value {
    font-size: 0.8rem;
    color: #ccaa4b;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* === ACTION BUTTONS === */
.inv-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid #1a1510;
}

.inv-action-btn {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid #332518;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: #ccc;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}

.inv-action-btn:hover {
    background: rgba(204, 170, 75, 0.12);
    border-color: #ccaa4b;
    color: #ccaa4b;
}

.inv-action-btn.btn-use {
    border-color: #2a6e3f;
    color: #5cff5c;
}
.inv-action-btn.btn-use:hover {
    background: rgba(46, 204, 113, 0.12);
    border-color: #2ecc71;
}

.inv-action-btn.btn-drop {
    border-color: #6e2a2a;
    color: #ff5c5c;
}
.inv-action-btn.btn-drop:hover {
    background: rgba(255, 77, 77, 0.1);
    border-color: #ff4d4d;
}

.inv-action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.inv-action-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* === EMPTY STATE === */
.inv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #555;
    text-align: center;
    gap: 8px;
    grid-column: 1 / -1;
}

.inv-empty-icon {
    font-size: 2.5rem;
    opacity: 0.35;
}

.inv-empty-text {
    font-size: 0.85rem;
}

/* === PAGINATION === */
.inv-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-top: 1px solid #1a1510;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
}

.inv-page-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #332518;
    color: #888;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 0.8rem;
    border-radius: 3px;
    font-family: inherit;
    transition: all 0.2s;
}

.inv-page-btn:hover {
    border-color: #ccaa4b;
    color: #ccaa4b;
}

.inv-page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.inv-page-info {
    font-size: 0.75rem;
    color: #666;
}

/* === COMBAT MODE === */
.inv-window.combat-mode {
    border-color: #6e2a2a;
    box-shadow: 0 0 80px rgba(100, 0, 0, 0.3), inset 0 0 40px rgba(0, 0, 0, 0.6);
}

.inv-window.combat-mode .inv-header {
    border-bottom-color: #ff4d4d;
}

.inv-window.combat-mode .inv-title {
    color: #ff6b6b;
    text-shadow: 0 0 8px rgba(255, 77, 77, 0.3);
}

.inv-combat-hint {
    font-size: 0.7rem;
    color: #ff6b6b;
    text-align: center;
    padding: 6px;
    background: rgba(255, 0, 0, 0.05);
    border-bottom: 1px solid #332518;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* === DROP CONFIRM MODAL === */
.inv-confirm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    animation: invFadeIn 0.15s ease-out;
}

.inv-confirm-box {
    background: #1a120b;
    border: 2px solid #ccaa4b;
    padding: 28px;
    width: 350px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 0, 0, 1);
    border-radius: 4px;
}

.inv-confirm-title {
    color: #ccaa4b;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.inv-confirm-text {
    color: #aaa;
    font-size: 0.85rem;
    margin-bottom: 18px;
    line-height: 1.4;
}

.inv-confirm-actions {
    display: flex;
    gap: 10px;
}

.inv-confirm-btn {
    flex: 1;
    padding: 10px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: bold;
    border-radius: 3px;
    transition: 0.2s;
}

.inv-confirm-yes {
    background: #ff4d4d;
    color: #fff;
}
.inv-confirm-yes:hover {
    background: #ff6b6b;
}

.inv-confirm-no {
    background: #333;
    color: #888;
}
.inv-confirm-no:hover {
    background: #444;
    color: #ccc;
}

/* === RELIQUIAS PANEL (REDESIGNED) === */
.inv-relics-layout {
    padding: 4px;
}

.inv-relics-title {
    color: #ccaa4b;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #332518;
    display: flex;
    align-items: center;
    gap: 8px;
}

.inv-relics-count {
    font-size: 0.7rem;
    background: rgba(204, 170, 75, 0.15);
    color: #ccaa4b;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
}

/* Equipped slots row — 2 cards side by side */
.inv-relic-slots-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Inventory relics grid */
.inv-relic-inv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

/* Relic card base */
.inv-relic-card {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid #2a1f14;
    border-radius: 8px;
    padding: 14px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    min-height: 100px;
}

.inv-relic-card:hover {
    background: rgba(163, 53, 238, 0.06);
    border-color: #5a3a7e;
    transform: translateY(-2px);
}

.inv-relic-card.selected {
    border-color: #a335ee;
    background: rgba(163, 53, 238, 0.12);
    box-shadow: 0 0 14px rgba(163, 53, 238, 0.25);
}

.inv-relic-card.equipped {
    border-color: #a335ee;
    background: rgba(163, 53, 238, 0.06);
    border-style: solid;
}

.inv-relic-card.equipped:hover {
    box-shadow: 0 0 12px rgba(163, 53, 238, 0.2);
}

.inv-relic-card.empty-slot {
    border-style: dashed;
    border-color: #332518;
    cursor: default;
    opacity: 0.6;
}

.inv-relic-card.empty-slot:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.03);
}

.inv-relic-card-slot {
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 0.65rem;
    color: #555;
    background: rgba(0, 0, 0, 0.5);
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: bold;
}

.inv-relic-card-img-wrap {
    width: 60px;
    height: 60px;
    overflow: hidden;
    position: relative;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(163, 53, 238, 0.2);
    flex-shrink: 0;
}

.inv-relic-card-img-wrap .inv-sprite {
    width: 80px;
    height: 80px;
    top: -5px;
    left: -10px;
}

.inv-relic-card-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 6px;
    image-rendering: pixelated;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(163, 53, 238, 0.2);
}

.inv-relic-card-empty-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #332518;
    border: 2px dashed #332518;
    border-radius: 6px;
}

.inv-relic-card-name {
    font-size: 0.8rem;
    text-align: center;
    color: #a335ee;
    font-weight: bold;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.inv-relic-card-badge {
    font-size: 0.55rem;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: bold;
}

.equipped-badge {
    background: rgba(163, 53, 238, 0.2);
    color: #c97aff;
    border: 1px solid rgba(163, 53, 238, 0.3);
}

.rarity-badge {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #332518;
}
.rarity-badge.rarity-epic { color: #a335ee; border-color: rgba(163,53,238,0.3); }
.rarity-badge.rarity-legendary { color: #ff8000; border-color: rgba(255,128,0,0.3); }
.rarity-badge.rarity-rare { color: #0070ff; border-color: rgba(0,112,255,0.3); }

/* Passive info in detail panel */
.inv-relic-passive-info {
    padding: 8px 10px;
    background: rgba(163, 53, 238, 0.06);
    border: 1px solid rgba(163, 53, 238, 0.15);
    border-radius: 4px;
}

.inv-relic-passive-label {
    font-size: 0.7rem;
    color: #a335ee;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: bold;
}

.inv-relic-passive-text {
    font-size: 0.8rem;
    color: #c9a0e8;
    line-height: 1.4;
}

/* No items state */
.inv-relic-no-items {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px;
    color: #555;
    font-size: 0.85rem;
}

/* Swap option UI */
.inv-relic-swap-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #332518;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.inv-relic-swap-option:hover {
    background: rgba(163, 53, 238, 0.08);
    border-color: #a335ee;
    transform: translateX(4px);
}

/* === ANIMATIONS === */
@keyframes invFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .inv-window {
        height: 95vh;
        max-height: 95vh;
        width: 100vw;
        max-width: 100vw;
        border-radius: 0;
    }

    .inv-body {
        flex-direction: column;
    }

    .inv-detail {
        width: 100%;
        max-height: 220px;
        border-top: 1px solid #332518;
        border-right: none;
    }

    .inv-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .inv-grid-panel {
        border-right: none;
    }

    .inv-corner {
        display: none;
    }
}

@media (max-width: 480px) {
    .inv-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .inv-tab {
        padding: 8px 10px;
        font-size: 0.7rem;
    }
}
