/* --- SHOP & INVENTORY STYLES --- */

/* Fix Layout for Shop/Inventory Overlays */
#screen-trade .overlay-content,
#screen-inventory .overlay-content {
    display: block;
    /* Disable flex centering */
    overflow-y: auto;
    /* Allow scrolling */
    padding: 10px;
    /* Padding for content */
    width: 100%;
    box-sizing: border-box;
}

#screen-trade .overlay-header,
#screen-inventory .overlay-header {
    flex-shrink: 0;
    /* Header doesn't shrink */
    z-index: 10;
    position: relative;
    background: #0d0e12;
    /* Match bg to handle transparency overlap */
}

/* Tab Navigation (Shop / Auction) */
.shop-tabs {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.shop-tab-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    padding: 5px 10px;
    cursor: pointer;
    transition: color 0.3s, border-bottom 0.3s;
    border-bottom: 2px solid transparent;
}

.shop-tab-btn.active {
    color: #fff;
    border-bottom: 2px solid var(--accent-gold);
}

.shop-subtitle {
    text-align: center;
    color: #aaa;
    font-size: 12px;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Categories Scroll */
.shop-categories {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 5px;
    padding-right: 20px;
    /* End padding */
    margin-bottom: 15px;
    scrollbar-width: none;
    max-width: 100%;
    /* Ensure it fits container */
    flex-wrap: nowrap;
    /* Force row */
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll on iOS */
    width: 100%;
    box-sizing: border-box;
    /* Handle padding */
}

/* Restored Category Styles */
.category-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.category-btn.active {
    background: rgba(255, 215, 0, 0.1);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.category-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 5px;
    opacity: 0.7;
    object-fit: contain;
}

.category-btn.active .category-icon {
    opacity: 1;
    filter: drop-shadow(0 0 5px var(--accent-gold));
}

.category-label {
    font-size: 10px;
    text-transform: uppercase;
}

/* Filters Bar */
.shop-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    /* Indent */
    overflow-x: auto;
}

.filter-select {
    background: #1a1f36;
    color: #ffd700;
    border: 1px solid #444;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    /* Custom Arrow */
    appearance: none;
    -moz-appearance: none;
    -webkit-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 10 6" fill="white" xmlns="http://www.w3.org/2000/svg"><path d="M0 0L5 6L10 0H0Z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
    padding-right: 30px;
}

/* Shop Grid */
.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    /* Responsive Grid */
    gap: 10px;
    padding-bottom: 80px;
    /* Space for bottom nav/footer */
}

/* Item Card */
.shop-item-card {
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid #444;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.shop-item-card:active {
    transform: scale(0.98);
}

.item-level-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #000;
    color: #888;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #333;
}

/* Rarities (Optional Borders) */
.shop-item-card.rare {
    border-color: #007bff;
}

.shop-item-card.legendary {
    border-color: #ffd700;
}

.item-icon-container {
    width: 64px;
    height: 64px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    margin: 20px 0 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-icon {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.item-name {
    font-size: 12px;
    text-align: center;
    color: #eee;
    margin-bottom: 10px;
    height: 30px;
    /* Limit height for 2 lines */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.buy-btn-small {
    width: 100%;
    background: linear-gradient(135deg, #444, #222);
    border: 1px solid #555;
    color: #fff;
    padding: 6px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.buy-btn-small:hover {
    background: linear-gradient(135deg, #555, #333);
}

.price-val {
    font-weight: bold;
}

/* Item Details Modal Specifics */
.modal-item-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 15px;
    display: block;
}

.modal-stats-list {
    text-align: left;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 8px;
}

.stat-row-detail {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 14px;
    color: #ccc;
}

/* --- INVENTORY SPECIFIC --- */

/* Paper Doll Container */
.inventory-paper-doll {
    position: relative;
    width: 300px;
    /* Base width */
    height: 380px;
    /* Enough for slots */
    margin: 0 auto 20px;
    background: url('assets/silhouette_male.png') no-repeat center center;
    background-size: contain;
    /* Optional: tint or border */
}

/* Slots Positioning */
.inv-slot {
    position: absolute;
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #444;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.inv-slot.active {
    border-color: var(--accent-gold);
    box-shadow: 0 0 8px var(--accent-gold);
}

.inv-slot img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.inv-slot-placeholder {
    opacity: 0.3;
    font-size: 20px;
}

/* Specific Positions (Relative to 300x380 container) */
/* Left Column */
.slot-helmet {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.slot-necklace {
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
}

/* Optional */

.slot-shoulder {
    top: 60px;
    left: 20px;
}

.slot-armor {
    top: 110px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 80px;
}

/* Big Body */
.slot-arm {
    top: 120px;
    right: 20px;
}

/* Bracers? */
.slot-gloves {
    top: 180px;
    right: 20px;
}

/* If distinct from Arm */

.slot-weapon {
    top: 120px;
    left: 30px;
    width: 56px;
    height: 56px;
}

/* Main Hand */
.slot-shield {
    top: 120px;
    right: 30px;
    width: 56px;
    height: 56px;
}

/* Off Hand */

.slot-legs {
    top: 200px;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 60px;
}

.slot-feet {
    top: 270px;
    left: 50%;
    transform: translateX(-50%);
}

/* Adjusting for simplification: 
   Left Side: Weapon, Shoulder, Arm
   Center: Helmet, Armor, Legs, Boots
   Right Side: Shield, Quiver (if archer), Amulet/Ring?
*/
/* Let's follow generate_items_sql slots: 
   weapon, shield, armor, helmet, feet, arm, shoulder, quiver.
*/

/* Revised Layout 300x400 */
.slot-helmet {
    top: 20px;
    left: 126px;
}

.slot-shoulder {
    top: 70px;
    left: 60px;
}

.slot-armor {
    top: 90px;
    left: 121px;
    width: 58px;
    height: 80px;
}

.slot-arm {
    top: 140px;
    left: 230px;
}

/* Right arm visual */
.slot-weapon {
    top: 140px;
    left: 20px;
    width: 56px;
    height: 56px;
}

.slot-shield {
    top: 170px;
    left: 230px;
    width: 56px;
    height: 56px;
}

/* Or Quiver */
.slot-legs {
    top: 180px;
    left: 126px;
}

/* Pants? Not in DB yet? Use for belt? */
.slot-feet {
    top: 280px;
    left: 126px;
}

/* Bag Grid */
.inventory-bag {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-bottom: 20px;
}

.bag-slot {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
}

.bag-slot.equipped {
    border-color: #00ff00;
}

.bag-slot img {
    width: 90%;
    height: 90%;
    object-fit: contain;
}

.bag-count {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 10px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}