/* Reset & Base */
:root {
    /* Updated Palette - Darker Warm Theme */
    --fc-bg: #121212;
    --fc-panel-bg: #1e1e1e;
    --fc-accent: #ffae00; /* Orange/Gold */
    --fc-text: #ffffff;
    --fc-text-muted: #b0b0b0;
    --fc-border: #333333;
    --fc-input-bg: #252525;
    
    /* Rarity Colors */
    --rarity-common: #94a3b8;
    --rarity-uncommon: #4ade80;
    --rarity-rare: #60a5fa;
    --rarity-epic: #c084fc;
    --rarity-legendary: #facc15;
    --rarity-mythical: #f87171;
    --rarity-divine: #f472b6;
    --rarity-unknown: #475569;
}

/* Global box-sizing to prevent layout expansion on mobile */
*,
*::before,
*::after {
    box-sizing: border-box;
}


/* Container */
.fc-container {
    max-width: 1200px;
    margin: 0 auto;
    /* Add some padding to prevent edge-hugging */
    padding: 0 10px;
}

/* Header */
.fc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.fc-title {
    margin: 0;
    font-size: 1.8rem;
    color: var(--fc-accent);
    /* Add subtle text shadow */
    text-shadow: 0 0 10px rgba(255, 174, 0, 0.2);
}

.fc-mode-toggle {
    display: flex;
    background: var(--fc-input-bg);
    border: 1px solid var(--fc-border);
    border-radius: 8px;
    padding: 4px;
}

.fc-toggle-btn {
    background: transparent;
    border: none;
    color: var(--fc-text-muted);
    padding: 8px 20px;
    cursor: pointer;
    font-weight: 600;
    border-radius: 6px;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

.fc-toggle-btn:hover {
    color: var(--fc-text);
}

.fc-toggle-btn.active {
    background: var(--fc-accent);
    color: #000;
}

/* Main Grid */
.fc-main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.fc-right-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Panels */
.fc-panel {
    background: var(--fc-panel-bg);
    border-radius: 12px;
    padding: 20px;
    /* Use orange border for specific panels or hover if desired, 
       but for base, use subtle border */
    border: 1px solid var(--fc-border);
    /* Add subtle shadow */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.fc-collapse {
    border: 1px solid var(--fc-border);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    background: var(--fc-panel-bg);
}
.fc-collapse > summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 16px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--fc-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--fc-border);
}
.fc-collapse > summary::after {
    content: '▾';
    color: var(--fc-text-muted);
    transition: transform 0.2s ease;
}
.fc-collapse[open] > summary::after {
    transform: rotate(180deg);
}

.fc-panel:hover {
    border-color: #555;
}

.fc-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--fc-border);
    padding-bottom: 10px;
}

.fc-panel-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--fc-text);
}

/* Search & Filter */
#ore-search {
    background: var(--fc-input-bg);
    border: 1px solid var(--fc-border);
    color: var(--fc-text);
    padding: 8px 12px;
    border-radius: 6px;
    width: 150px;
    outline: none;
}
#ore-search:focus {
    border-color: var(--fc-accent);
}

.fc-rarity-filters {
    display: flex;
    gap: 3px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 12px;
    scrollbar-width: none; /* Hide scrollbar Firefox */
    -ms-overflow-style: none; /* Hide scrollbar IE */
}
.fc-rarity-filters::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome */
}

.fc-filter-chip {
    background: transparent;
    border: 1px solid var(--fc-border);
    color: var(--fc-text-muted);
    padding: 2px 5px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-weight: 500;
}

.fc-filter-chip:hover {
    background: rgba(255, 255, 255, 0.05);
}

.fc-filter-chip.active {
    /* Styles handled by JS inline mostly, but default fallback */
    background: #fff;
    color: #000;
    font-weight: bold;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255,255,255,0.2);
}

/* Ore Grid */
.fc-ore-grid {
    display: grid;
    /* Increased min-width from 70px to 100px for larger items */
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    max-height: 600px; /* Slightly taller */
    overflow-y: auto;
    padding-right: 5px;
    padding-bottom: 10px;
}

.fc-ore-item {
    background: var(--fc-input-bg);
    border: 1px solid var(--fc-border);
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 110px;
    position: relative;
    overflow: hidden;
}

.fc-ore-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.03), transparent);
    pointer-events: none;
}

.fc-ore-item:hover {
    border-color: var(--fc-accent);
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.fc-ore-item:active {
    transform: scale(0.96);
}

.fc-ore-item.disabled {
    opacity: 0.4;
    filter: grayscale(60%);
    pointer-events: none;
}

.fc-ore-img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    margin-bottom: 10px;
}
.fc-mini-img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.fc-ore-diamond {
    width: 42px;
    height: 42px;
    transform: rotate(45deg);
    margin-bottom: 10px;
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    position: relative;
    box-shadow: none;
}
.fc-ore-diamond::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(255,255,255,0.25), rgba(0,0,0,0.2));
    mix-blend-mode: overlay;
}
.fc-mini-diamond {
    width: 16px;
    height: 16px;
    transform: rotate(45deg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
}

.fc-ore-name {
    font-size: 0.85rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 4px;
    font-weight: 600;
    color: var(--fc-text);
}

.fc-limit-note {
    color: var(--fc-text-muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
    padding: 6px 10px;
    border: 1px dashed var(--fc-border);
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
}

/* Mixing List */
.fc-mixing-list {
    max-height: 350px;
    overflow-y: auto;
}

.fc-mix-row {
    display: flex;
    align-items: center;
    background: var(--fc-input-bg);
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 8px;
    gap: 10px;
    border: 1px solid transparent;
}
.fc-mix-row:hover {
    border-color: var(--fc-border);
}

.fc-mix-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
}

.fc-mix-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fc-qty-btn {
    background: var(--fc-panel-bg);
    color: var(--fc-text);
    border: 1px solid var(--fc-border);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fc-qty-btn:hover {
    border-color: var(--fc-accent);
    color: var(--fc-accent);
}

.fc-qty-input {
    width: 80px; /* Increased from 60px for 3 digits */
    /* Ensure dark background and white text */
    background-color: var(--fc-input-bg) !important; 
    color: var(--fc-text) !important;
    border: 1px solid var(--fc-border) !important;
    text-align: center;
    padding: 6px;
    border-radius: 4px;
    font-size: 1rem;
    -moz-appearance: textfield; /* Hide spinners in Firefox */
    appearance: textfield;
}

/* Hide spinners in Chrome/Safari/Edge */
.fc-qty-input::-webkit-outer-spin-button,
.fc-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.fc-qty-input:focus {
    outline: none;
    border-color: var(--fc-accent) !important;
}

.fc-remove-btn {
    background: transparent;
    border: none;
    color: #ff5555; /* Keep red for delete */
    cursor: pointer;
    margin-left: 8px;
    font-size: 1.2rem;
    opacity: 0.8;
    transition: 0.2s;
}
.fc-remove-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Results */
.fc-stats-summary {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.fc-stat-box {
    background: var(--fc-input-bg);
    padding: 15px;
    border-radius: 8px;
    flex: 1;
    text-align: center;
    border: 1px solid var(--fc-border);
}

.fc-stat-box .label {
    display: block;
    font-size: 0.85rem;
    color: var(--fc-text-muted);
    margin-bottom: 5px;
}

.fc-stat-box .value {
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--fc-accent);
}

.fc-section-title {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--fc-text-muted);
    margin-top: 20px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--fc-border);
    padding-bottom: 6px;
}

.fc-odds-bar {
    margin-bottom: 12px;
}

.fc-odds-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.fc-progress-bg {
    background: var(--fc-input-bg);
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--fc-border);
}

.fc-progress-fill {
    height: 100%;
    background: var(--fc-accent);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(255, 174, 0, 0.4); /* Glow effect */
}

.fc-trait-row {
    font-size: 0.9rem;
    margin-bottom: 6px;
    color: #b0e0ff;
    padding: 4px 8px;
    background: rgba(176, 224, 255, 0.05);
    border-radius: 4px;
}

.fc-badge {
    background: var(--fc-accent);
    color: #000;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.8rem;
    margin-left: 5px;
}

.fc-btn-clear {
    background: transparent;
    border: 1px solid var(--fc-border);
    color: var(--fc-text-muted);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.fc-btn-clear:hover {
    color: #ff5555;
    border-color: #ff5555;
}

/* Item Previews */
.fc-item-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.fc-item-card {
    background: var(--fc-input-bg);
    border: 1px solid var(--fc-border);
    padding: 8px;
    border-radius: 6px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
}

.fc-item-details {
    flex: 1;
}

.fc-item-name {
    font-weight: bold;
    font-size: 0.9rem;
}

.fc-item-stat {
    font-size: 0.8rem;
    color: var(--fc-text-muted);
}

/* --- Mobile Navigation (Hidden by default) --- */
.fc-mobile-nav {
    display: none;
}

/* --- Mobile Optimizations --- */
@media (max-width: 768px) {
    body {
        padding: 10px;
        padding-bottom: 10px;
    }

    .fc-main-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .fc-right-stack {
        gap: 10px;
    }

    /* Mobile Tab Logic */
    .fc-mobile-nav {
        display: none !important;
    }

    .fc-nav-btn {
        background: transparent;
        border: none;
        color: var(--fc-text-muted);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        cursor: pointer;
        position: relative;
        transition: color 0.2s;
    }

    .fc-nav-btn.active {
        color: var(--fc-accent);
    }

    .fc-nav-btn.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 30%;
        height: 3px;
        background: var(--fc-accent);
        border-radius: 0 0 4px 4px;
        box-shadow: 0 2px 8px var(--fc-accent);
    }

    .nav-icon {
        font-size: 1.5rem;
        margin-bottom: 4px;
        transition: transform 0.2s;
    }
    
    .fc-nav-btn.active .nav-icon {
        transform: translateY(-2px);
    }

    .nav-label {
        font-size: 0.7rem;
        font-weight: 600;
        letter-spacing: 0.5px;
        text-transform: uppercase;
    }

    .fc-nav-badge {
        position: absolute;
        top: 5px;
        right: 25%; /* Adjust based on icon position */
        background: var(--fc-accent);
        color: #000;
        border-radius: 10px;
        padding: 2px 6px;
        font-size: 0.7rem;
        font-weight: bold;
        box-shadow: 0 2px 5px rgba(0,0,0,0.3);
        border: 1px solid rgba(0,0,0,0.1);
        min-width: 14px;
        text-align: center;
    }
    
    .fc-nav-badge:empty, .fc-nav-badge.hidden {
        display: none;
    }

    .fc-mobile-hidden { display: initial; }

    /* Compact Header - Box Style */
    .fc-header {
        position: sticky;
        top: 10px;
        background: #1e1e1e;
        border: 1px solid var(--fc-border);
        border-radius: 12px;
        padding: 15px;
        margin-bottom: 20px;
        z-index: 900;
        box-shadow: 0 4px 15px rgba(0,0,0,0.5);
        
        /* Flex Layout for Mobile */
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .fc-title {
        font-size: 1.8rem;
        font-weight: 900;
        color: #000000;
        letter-spacing: 1px;
        /* White Outline */
        text-shadow: 
            -1px -1px 0 #fff,  
             1px -1px 0 #fff,
            -1px  1px 0 #fff,
             1px  1px 0 #fff,
             0 2px 5px rgba(0,0,0,0.5);
        margin: 0;
    }

    .fc-mode-toggle {
        width: 100%;
        display: flex;
        justify-content: center;
        padding: 4px;
        background: #121212;
    }

    .fc-toggle-btn {
        flex: 1;
        justify-content: center;
        padding: 10px;
        font-size: 1rem;
    }

    /* Compact Ore Grid */
    .fc-ore-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }

    .fc-ore-item {
        padding: 8px;
        min-height: 90px;
    }

    .fc-ore-img {
        width: 36px;
        height: 36px;
    }

    .fc-ore-name {
        font-size: 0.75rem;
    }

    /* Mixing List Compact */
    .fc-mix-row {
        padding: 8px;
    }
    
    .fc-mix-info {
        font-size: 0.9rem;
    }
    
    .fc-qty-btn {
        width: 24px;
        height: 24px;
    }
    
    .fc-qty-input {
        width: 60px; /* Increased for mobile 3-digits */
        padding: 4px;
        font-size: 16px; /* Prevent iOS zoom on focus */
        line-height: 20px;
    }

    /* Search Bar Full Width */
    .fc-panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    #ore-search {
        width: 100%;
        font-size: 16px; /* Prevent iOS zoom on focus */
        line-height: 20px;
        box-sizing: border-box; /* Fix width issue */
    }
}
/* --- Heading Style: Brown with White Outline --- */
.forge-title {
    color: #5D4037; /* Deep Brown */
    font-size: 2.5rem;
    font-weight: 900;
    text-align: center;
    margin-bottom: 25px;
    text-transform: uppercase;
    /* This creates the high-quality white outline */
    text-shadow: 
        -1px -1px 0 #fff,  
         1px -1px 0 #fff,
        -1px  1px 0 #fff,
         1px  1px 0 #fff,
         0px  2px 4px rgba(0,0,0,0.5); /* Adds a subtle drop shadow for depth */
}

/* --- Mobile Header Fix --- */
.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    width: 100%;
}

@media (max-width: 600px) {
    .forge-container {
        padding: 10px; /* Reduces padding on small screens to save space */
    }
    
    .controls-row {
        flex-direction: column; /* Stacks Weapons/Armor above Reset button */
        align-items: stretch;
        gap: 12px;
    }

    .mode-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr; /* Ensures buttons stay side-by-side even on small screens */
        width: 100%;
    }

    .tab-btn {
        padding: 12px 5px; /* Makes buttons easier to tap on mobile */
        font-size: 0.9rem;
    }

    .clear-btn {
        width: 100%;
        justify-content: center; /* Centers the text/icon in the full-width button */
    }
}
