/* waifu-wars/css/guildStore.css - Styles for the Guild Store screen */

/* Main container */
#guild-store-container {
    position: absolute;
    top: 85px; /* Below player info */
    bottom: 65px; /* Above taskbar */
    left: 10px;
    right: 10px;
    background: var(--theme-bg-color);
    border-radius: 8px;
    border: 1px solid var(--theme-border-color);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(5px);
}

/* Tabs */
#guild-store-tabs {
    display: flex;
    justify-content: center;
    padding: 10px;
    gap: 10px;
    border-bottom: 1px solid var(--theme-border-color);
    flex-shrink: 0;
}

.store-tab-btn.active-tab {
    background: var(--theme-button-active-bg);
    box-shadow: 0 0 8px var(--theme-primary-text-color);
}

/* Content area */
#guild-store-content {
    flex-grow: 1;
    position: relative;
    overflow: hidden; /* Important for positioning elements inside */
    display: flex;
    flex-direction: column; /* Changed for blacksmith layout */
    justify-content: center;
    align-items: center;
}

/* Merchant Tab */
.merchant-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.merchant-sub-tabs, .blacksmith-sub-tabs {
    display: flex;
    justify-content: center;
    padding: 8px;
    gap: 10px;
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}
.merchant-sub-tab-btn.active-sub-tab, .blacksmith-sub-tab-btn.active-sub-tab {
    background: var(--theme-button-active-bg);
}

/* Blacksmith Tab */
.blacksmith-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
}

#blacksmith-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: var(--theme-panel-bg-color);
    border-radius: 8px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
#blacksmith-level-info {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}
#blacksmith-level {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--theme-primary-text-color);
    white-space: nowrap;
}
#blacksmith-xp-bar-container {
    flex-grow: 1;
    height: 20px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #555;
    position: relative;
}
#blacksmith-xp-bar {
    height: 100%;
    background: linear-gradient(to right, #a08c6d, #e6c891);
    transition: width 0.5s ease;
}
#blacksmith-xp-text {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    line-height: 20px;
    font-size: 12px;
    color: white;
    text-shadow: 1px 1px 2px black;
}
#blacksmith-parts-tracker {
    flex-shrink: 0;
    padding: 8px 12px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--theme-button-wrapper-border);
    border-radius: 5px;
    text-align: right;
}

#blacksmith-parts-tracker h4 {
    margin: 0 0 5px 0;
    font-size: 0.9em;
    color: var(--theme-secondary-text-color);
    text-align: center;
}

#parts-list-tracker {
    display: grid;
    grid-template-columns: auto auto;
    gap: 2px 15px;
    font-size: 0.9em;
}
.part-count.rarity-Common { color: #90ee90; }
.part-count.rarity-Rare { color: #5b92e5; }
.part-count.rarity-Epic { color: #9400d3; }
.part-count.rarity-Legendary { color: #ff8c00; }
.part-count.rarity-Mythic { color: #ffd700; }

#blacksmith-main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--theme-panel-bg-color);
    border-radius: 8px;
    margin-top: 10px;
    overflow: hidden;
}

/* === NEW Blacksmith Upgrade Tab Layout === */
.upgrade-tab-layout {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 450px 1fr 450px;
    gap: 15px;
    padding: 15px;
    box-sizing: border-box;
}

#blacksmith-item-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end; /* PUSH TO BOTTOM */
    text-align: center;
    position: relative;
    overflow: visible;
    padding-bottom: 20px;
}
#anvil-station {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}
#upgrade-anvil {
    width: 800px;
    height: auto;
    position: relative;
    z-index: 1;
}
#upgrade-hammer {
    width: 360px; /* Half size */
    height: auto;
    position: absolute;
    bottom: 395px;
    right: 100px;
    transform-origin: 85% 95%;
    transform: rotate(25deg);
    z-index: 3; /* Above item */
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
}
#item-on-anvil {
    position: absolute;
    width: 300px;
    height: 300px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 2;
    top: -200px; /* Position above anvil */
    left: 53%;
    transform: translate(-50%, 0);
    transition: transform 0.4s ease-in-out;
}
#item-on-anvil.upgrading {
    transform: translate(-50%, 155px) scaleY(0.05) rotateX(80deg);
}

#upgrade-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    min-height: 80px; /* Stabilize layout */
}

.upgrade-actions-wrapper {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 350px; /* Adjust as needed */
    margin-top: 10px;
}
.upgrade-actions-wrapper .button-wrapper {
    grid-column: 2;
}
.upgrade-actions-wrapper .auto-upgrade-container {
    grid-column: 3;
    justify-self: start;
}

.auto-upgrade-container {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--theme-secondary-text-color);
}
.auto-upgrade-container label {
    cursor: pointer;
}
.auto-upgrade-container input {
    cursor: pointer;
}


#upgrade-stats-panel {
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}
#upgrade-stats-art {
    width: 360px;  /* 3x bigger */
    height: 360px; /* 3x bigger */
    margin: 0 auto 15px;
    border-radius: 8px;
    background-color: rgba(0,0,0,0.3);
    border: 1px solid var(--theme-border-color);
    object-fit: contain;
}
#upgrade-stats-panel .placeholder-text {
    font-size: 1.2em;
    color: #888;
}

.detail-stats-comparison {
    background: rgba(0,0,0,0.5);
    padding: 15px;
    border-radius: 8px;
    min-width: 250px;
    margin-top: 10px;
}
.upgrade-failure-chance {
    color: #ff8c00;
    font-style: italic;
    margin-top: 10px;
}

/* === NEW Upgrade Animation Styles === */
#upgrade-hammer.animating {
    animation: hammer-multi-strike 3.5s ease-in-out forwards;
}

#impact-flash {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(255, 223, 150, 0.9) 0%, rgba(255, 200, 50, 0) 70%);
    border-radius: 50%;
    display: none;
    z-index: 4;
}

#impact-flash.playing {
    display: block;
    animation: impact-flash-anim 0.3s ease-out;
}

#upgrade-hammer.auto-striking {
    animation: hammer-single-strike 0.5s ease-in-out forwards;
    opacity: 1; /* Keep it visible during auto-upgrade loop */
}

@keyframes hammer-single-strike {
    0%   { transform: rotate(25deg); }
    30%  { transform: rotate(55deg) translateY(-30px); } /* Backswing */
    60% { transform: rotate(-20deg) translateY(10px); } /* Strike */
    100% { transform: rotate(25deg); } /* Back to rest */
}

@keyframes hammer-multi-strike {
    0%   { transform: rotate(25deg); opacity: 0; }
    3%   { transform: rotate(25deg); opacity: 1; } /* Fade in */

    7%  { transform: rotate(55deg) translateY(-30px); } /* Backswing 1 */
    14% { transform: rotate(-20deg) translateY(10px); } /* Strike 1 */
    28% { transform: rotate(-20deg) translateY(10px); } /* Pause 1 (0.5s) */
    
    35% { transform: rotate(55deg) translateY(-30px); } /* Backswing 2 */
    42% { transform: rotate(-20deg) translateY(10px); } /* Strike 2 */
    57% { transform: rotate(-20deg) translateY(10px); } /* Pause 2 (0.5s) */

    64% { transform: rotate(55deg) translateY(-30px); } /* Backswing 3 */
    71% { transform: rotate(-20deg) translateY(10px); } /* Strike 3 */
    85% { transform: rotate(-20deg) translateY(10px); } /* Pause 3 (0.5s) */

    97% { transform: rotate(25deg); opacity: 1; } /* Back to rest */
    100% { transform: rotate(25deg); opacity: 0; } /* Fade out */
}


@keyframes impact-flash-anim {
    0% { transform: translateX(-50%) scale(0); opacity: 1; }
    50% { opacity: 0.8; }
    100% { transform: translateX(-50%) scale(2.5); opacity: 0; }
}


/* Generic store grid styles for Merchant */
.store-grid {
    width: 100%;
    height: 100%;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    overflow-y: auto;
    align-content: start;
    box-sizing: border-box;
}
.store-item {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--theme-button-wrapper-border);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: white;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.store-item .item-icon {
    width: 100px;
    height: 100px;
    background-color: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 5px;
    margin-bottom: 10px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}
.item-name {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--theme-primary-text-color);
}
.item-stats {
    font-size: 0.9em;
    color: #a0e8ff;
    margin: 5px 0 10px 0;
    min-height: 2.7em; /* 3 lines of text */
    line-height: 1.3;
}
.item-stats .stat-increase {
    color: #98fb98; /* Light green for positive changes */
}
.item-req-unmet {
    font-size: 0.9em;
    color: #ff8c00; /* Dark Orange / Amber */
    font-style: italic;
    margin-top: auto; /* Push to bottom */
    padding-top: 10px;
    align-self: center;
}

/* For purchase quantity */
.purchase-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: auto; /* Push to bottom */
    padding-top: 10px;
}
.quantity-input {
    width: 50px;
    padding: 8px;
    text-align: center;
    border-radius: 5px;
    border: 1px solid var(--theme-border-color);
    background: var(--theme-panel-bg-color);
    color: var(--theme-body-text-color);
    font-size: 14px;
}
/* Hide number input spinners */
.quantity-input::-webkit-inner-spin-button,
.quantity-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.quantity-input {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Blacksmith Dismantle Tab */
#blacksmith-content.dismantle-layout {
    display: flex;
    flex-direction: column;
    padding: 15px;
    box-sizing: border-box;
    height: 100%;
}
#dismantle-all-container {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
#dismantle-all-container h4 {
    margin: 0 10px 0 0;
    color: var(--theme-secondary-text-color);
}
#dismantle-all-container label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}
#dismantle-all-container .part-count {
    font-weight: bold;
}

#dismantle-selected-wrapper {
    margin: 15px auto 0;
    flex-shrink: 0;
}
#dismantle-selected-btn {
    padding: 10px 20px;
}


/* Blacksmith specific styles */
.item-level {
    font-size: 0.9em;
    color: #ccc;
    margin-bottom: 5px;
}

.item-cost, .item-sell-price {
    font-size: 1em;
    color: var(--theme-secondary-text-color);
    margin-bottom: 10px;
}

/* Blacksmith Crafting Tab */
#gear-parts-display {
    padding: 15px;
    text-align: center;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--theme-border-color);
    flex-shrink: 0;
}
#gear-parts-display h4 {
    margin: 0 0 10px 0;
    color: var(--theme-secondary-text-color);
}
#parts-list {
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 1.1em;
    flex-wrap: wrap;
}
#crafting-recipes {
    flex-grow: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    overflow-y: auto;
}
.crafting-recipe {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--theme-border-color);
    width: 350px;
    max-width: 90%;
    text-align: center;
}
.crafting-recipe p {
    margin: 5px 0;
}
.crafting-recipe .crafting-reqs {
    font-size: 0.85em;
    color: #ffc107; /* Amber for requirements */
    margin-top: 10px;
}
.crafting-recipe .crafting-reqs.unmet {
    color: #ff4500;
}
.popup.crafting-result-popup img {
    max-width: 100px;
    max-height: 100px;
    margin: 10px auto;
    display: block;
    border-radius: 5px;
    background: rgba(0,0,0,0.3);
}

.rarity-Common { color: #90ee90; }
.rarity-Rare { color: #5b92e5; }
.rarity-Epic { color: #9400d3; }
.rarity-Legendary { color: #ff8c00; }
.rarity-Mythic { color: #ffd700; }

/* Placeholder for new tabs */
.placeholder-text {
    font-size: 1.5em;
    color: #888;
    margin: auto;
}

/* --- Mobile Optimizations --- */
@media (max-width: 1200px) {
    .upgrade-tab-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(300px, 1fr) auto;
        overflow-y: auto;
    }
    #blacksmith-upgrade-grid {
        grid-row: 1;
        grid-column: 1;
        max-height: 200px;
    }
    #blacksmith-item-details {
        grid-row: 2;
        grid-column: 1;
    }
    #upgrade-stats-panel {
        grid-row: 3;
        grid-column: 1;
    }
}

@media (max-width: 768px) {
    #blacksmith-info {
        flex-direction: column;
        align-items: stretch;
    }
    .upgrade-tab-layout {
        padding: 5px;
        gap: 5px;
    }
}