/* ========================================= */
/* I. CSS VARIABLES & NEON REFINEMENT */
/* ========================================= */
:root {
    --color-neon-blue: #00e5ff; 
    --color-accent-orange: #ff7f2a; 
    --color-highlight-yellow: #ffea5a;
    --color-dark-bg: rgba(3, 5, 8, 1); 
    --color-panel: rgba(12, 18, 25, 0.95); 
    --color-text: #e0e6f0; 
    --color-text-dim: #99a2b5;
    --color-missing: #e9546d; 
    --color-enough: #4caf50; 
    
    --neon-glow-blue-sm: 0 0 4px var(--color-neon-blue);
    --neon-glow-blue-lg: 0 0 8px var(--color-neon-blue), 0 0 16px rgba(0, 229, 255, 0.4);
    --neon-glow-orange: 0 0 6px var(--color-accent-orange);
    --neon-glow-yellow-sm: 0 0 3px var(--color-highlight-yellow);
    --shadow-inset: inset 0 0 10px rgba(0, 229, 255, 0.05);
    --border-panel: 1px solid var(--color-neon-blue);
}

/* ========================================= */
/* II. BASE STYLES & LAYOUT */
/* ========================================= */

/* Масштаб 80% через уменьшение шрифта */
html {
    font-size: 13px; 
}

body {
    margin: 0;
    padding: 0;
    background-image: url('bg.png'); 
    background-size: cover;
    background-position: center center;
    background-attachment: fixed;
    background-color: #05070a; 
    font-family: 'Share Tech Mono', monospace;
    color: var(--color-text);
    min-height: 100vh;
}

body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 4px
    );
    pointer-events: none;
    z-index: 10;
}

.container {
    max-width: 1100px; 
    margin: 30px auto; 
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px; 
    position: relative;
    z-index: 20; 
}

h1, h2, h3 {
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    letter-spacing: 2px;
}

h1.main-title {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 2.6rem; 
    font-weight: 900; 
    color: #ff9d00; 
    
    text-shadow: 
        3px 3px 0px #000000, 
        -1px -1px 0 #000,  
        0 0 15px rgba(255, 127, 42, 0.8),
        0 0 30px rgba(255, 127, 42, 0.4);
    
    margin-bottom: 20px;
    
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(0, 0, 0, 0.9) 20%, 
        rgba(0, 0, 0, 0.9) 80%, 
        transparent 100%
    );
    
    border-bottom: 2px solid var(--color-accent-orange);
    border-top: 1px solid rgba(255, 127, 42, 0.3);
    padding: 15px 0;
    
    position: relative;
    z-index: 50;
    letter-spacing: 4px;
}

/* ========================================= */
/* III. PANEL STYLING & STRUCTURE */
/* ========================================= */

.panel {
    background: var(--color-panel);
    border: var(--border-panel);
    padding: 20px; 
    box-shadow: var(--shadow-inset), 0 0 20px rgba(0, 0, 0, 0.5);
    position: relative;
    backdrop-filter: blur(6px);
    overflow: hidden; 
    display: flex;
    flex-direction: column;
    border-radius: 4px;
}

/* Ограничение высоты для обоих панелей */
#input-panel, #output-panel {
    max-height: 88vh; 
}

/* Скролл контента для обоих панелей */
#input-panel .panel-content, 
#output-panel .panel-content {
    overflow-y: auto;
    padding-right: 5px; 
    margin-right: -10px;
    flex: 1; 
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}
.panel-content::-webkit-scrollbar-thumb {
    background-color: var(--color-accent-orange);
    border-radius: 3px;
}
.panel-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.panel::before {
    content: ''; position: absolute; top: -4px; left: -4px; width: 12px; height: 12px;
    border-top: 2px solid var(--color-highlight-yellow); border-left: 2px solid var(--color-highlight-yellow);
}
.panel::after {
    content: ''; position: absolute; bottom: -4px; right: -4px; width: 12px; height: 12px;
    border-bottom: 2px solid var(--color-highlight-yellow); border-right: 2px solid var(--color-highlight-yellow);
}

h2.panel-title {
    font-size: 1.3rem; color: var(--color-neon-blue);
    border-bottom: 1px solid var(--color-neon-blue); padding-bottom: 8px; margin-top: 0;
    text-shadow: var(--neon-glow-blue-sm);
    flex-shrink: 0; 
}

h2.panel-title.total-header {
    font-size: 1.5rem; padding-bottom: 8px; margin-bottom: 12px; text-align: left;
}

/* ========================================= */
/* IV. TABS & SEARCH */
/* ========================================= */
.tabs {
    display: flex; margin-bottom: 15px; border-bottom: 1px solid rgba(0, 229, 255, 0.3);
    flex-shrink: 0; 
}
.tab-btn {
    background: rgba(0,0,0,0.6); color: var(--color-text-dim); border: 1px solid transparent; border-bottom: none;
    padding: 8px 15px; cursor: pointer; font-family: 'Orbitron', sans-serif; text-transform: uppercase;
    transition: all 0.2s; margin-right: 4px; font-size: 0.85rem;
}
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active {
    background: var(--color-panel); color: var(--color-accent-orange); border-color: var(--color-accent-orange);
    border-top-left-radius: 4px; border-top-right-radius: 4px; font-weight: bold;
    box-shadow: 0 -3px 10px rgba(255, 127, 42, 0.3); z-index: 1; position: relative; letter-spacing: 1px;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

#search-input {
    width: 100%; padding: 8px; margin-bottom: 12px; background: rgba(0,0,0,0.4);
    border: 1px solid var(--color-text-dim); color: var(--color-text);
    font-family: 'Share Tech Mono', monospace; font-size: 1rem; box-sizing: border-box; 
    box-shadow: 0 0 5px rgba(0,0,0,0.5); transition: border-color 0.2s;
    flex-shrink: 0;
}
#search-input:focus { outline: none; border-color: var(--color-neon-blue); box-shadow: 0 0 8px rgba(0, 229, 255, 0.5); }

/* Стиль для кнопки сброса крафта */
#reset-button {
     width: 100%; margin: 0 0 15px 0; display: block; height: 38px; 
     font-size: 1rem; font-family: 'Orbitron', sans-serif;
     border: 2px solid #d9534f; color: var(--color-text); text-shadow: 1px 1px 2px #000;
     background: rgba(217, 83, 79, 0.7); transition: all 0.2s; box-sizing: border-box; cursor: pointer;
}
#reset-button:hover { background: #d9534f; box-shadow: 0 0 15px #d9534f; }

/* НОВЫЙ СТИЛЬ: Кнопка сброса инвентаря */
#reset-inventory-btn {
     width: 100%; margin: 0 0 15px 0; display: block; height: 38px;
     font-size: 1rem; font-family: 'Orbitron', sans-serif;
     border: 2px solid #d9534f; color: var(--color-text); text-shadow: 1px 1px 2px #000;
     background: rgba(217, 83, 79, 0.7); transition: all 0.2s; box-sizing: border-box; cursor: pointer;
     flex-shrink: 0;
}
#reset-inventory-btn:hover { background: #d9534f; box-shadow: 0 0 15px #d9534f; }

#goals-controls, #goals-controls.active { padding: 0; display: block; flex-shrink: 0;}

/* ========================================= */
/* V. INPUT LISTS */
/* ========================================= */

.category-title {
    color: var(--color-highlight-yellow); margin: 10px 0 0 0; display: flex; align-items: center;
    font-size: 1rem; cursor: pointer; justify-content: space-between; transition: all 0.3s;
    padding: 8px 12px; background: rgba(255, 234, 90, 0.05); 
    border-left: 4px solid var(--color-highlight-yellow); border-bottom: 1px solid rgba(255, 234, 90, 0.2);
    user-select: none; font-family: 'Orbitron', sans-serif; text-shadow: var(--neon-glow-yellow-sm);
}
.category-title:hover { background: rgba(255, 234, 90, 0.1); box-shadow: 0 0 10px rgba(255, 234, 90, 0.2); }
.category-title.collapsed { border-bottom: 1px solid rgba(255, 234, 90, 0.1); }

.category-title .toggle-icon {
    font-size: 0.9rem; transition: transform 0.3s ease; transform: rotate(0deg); 
    color: var(--color-accent-orange); text-shadow: var(--neon-glow-orange);
}
.category-title:not(.collapsed) .toggle-icon { transform: rotate(90deg); }

.items-list-content {
    max-height: 2000px; overflow: hidden; transition: max-height 0.4s ease-in-out;
}
.items-list-content.collapsed { max-height: 0; }
.items-list-content-inner { padding: 5px 0 0 0; border-left: 1px dashed rgba(255, 255, 255, 0.05); }

.item-row {
    display: flex; justify-content: space-between; align-items: center; padding: 6px 10px;
    background: rgba(0,0,0,0.2); border-bottom: 1px dashed rgba(90, 221, 255, 0.1); 
    transition: background 0.3s; cursor: default;
}
.item-row:hover { background: rgba(0, 229, 255, 0.05); }

/* --- STYLES FOR ICONS & INFO --- */
.item-wrapper {
    display: flex;
    align-items: center;
}
/* Уменьшаем иконки с 32px до 28px */
.item-icon {
    width: 28px; height: 28px;
    margin-right: 10px;
    object-fit: contain;
    border-radius: 4px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(0, 229, 255, 0.1);
}

.item-info-col {
    display: flex;
    flex-direction: column;
}

/* Стили для индикаторов уровня (Tier Pips) */
.tier-pips {
    display: flex;
    gap: 3px;
    margin-top: 2px;
}
.tier-pip {
    width: 8px;
    height: 8px;
    border: 1px solid var(--color-text-dim);
    background: rgba(0,0,0,0.5);
    cursor: pointer;
    transition: all 0.2s;
}
.tier-pip:hover {
    border-color: var(--color-neon-blue);
    box-shadow: 0 0 3px var(--color-neon-blue);
}
.tier-pip.active {
    background: var(--color-neon-blue);
    border-color: var(--color-neon-blue);
    box-shadow: 0 0 5px var(--color-neon-blue);
}

.quantity-control {
    display: flex; align-items: center; border: 1px solid var(--color-neon-blue); box-shadow: 0 0 5px rgba(0, 229, 255, 0.3);
}

/* Уменьшаем кнопки +/- */
.qty-btn {
    background: rgba(0, 229, 255, 0.1); color: var(--color-neon-blue); border: none;
    width: 28px; height: 28px; font-weight: bold; font-size: 1.1rem;
    font-family: 'Orbitron', sans-serif; cursor: pointer; transition: all 0.2s; line-height: 1; padding: 0;
}
.qty-btn:hover { background: var(--color-neon-blue); color: var(--color-dark-bg); box-shadow: 0 0 8px var(--color-neon-blue); }

/* Уменьшаем инпуты */
.qty-input {
    width: 45px; height: 28px; background: var(--color-dark-bg); border: none;
    color: var(--color-highlight-yellow); text-align: center; font-family: 'Orbitron', sans-serif;
    font-size: 1rem; margin: 0; padding: 0; box-shadow: inset 0 0 3px rgba(255, 234, 90, 0.5);
    -moz-appearance: textfield; appearance: none;
}
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.inventory-input-container {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
    padding: 6px 12px; background: rgba(0,0,0,0.4); border-left: 3px solid var(--color-accent-orange);
    transition: background 0.2s;
}
.inventory-input-container:hover { background: rgba(255, 127, 42, 0.05); }
.inventory-input {
    width: 70px; height: 28px; background: var(--color-dark-bg); border: 1px solid var(--color-accent-orange);
    color: var(--color-highlight-yellow); text-align: center; font-family: 'Orbitron', sans-serif;
    font-size: 1rem; -moz-appearance: textfield; box-shadow: 0 0 3px rgba(255, 127, 42, 0.5);
}

/* ========================================= */
/* VI. OUTPUT LISTS */
/* ========================================= */
#base-total-list li {
    font-size: 1.15rem; padding: 10px 12px; border-bottom: 1px solid rgba(0, 229, 255, 0.15);
    background: rgba(0,0,0,0.25); margin-bottom: 4px; line-height: 1.4;
    display: flex; justify-content: space-between; align-items: center;
}
.res-name { font-weight: bold; color: var(--color-text); }
.missing-resource { color: var(--color-missing); font-weight: bold; font-size: 1.3rem; text-shadow: 0 0 8px var(--color-missing); margin-right: 12px; }
.enough-resource { color: var(--color-enough); font-weight: bold; font-size: 1.3rem; text-shadow: 0 0 8px var(--color-enough); margin-right: 12px; }
.base-total-label { font-size: 0.75rem; color: var(--color-text-dim); font-family: 'Share Tech Mono', monospace; display: block; text-align: right; }

#craft-total-list li {
    padding: 6px 12px; border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    display: flex; justify-content: space-between; background: rgba(0,0,0,0.1);
}
.res-qty { color: var(--color-accent-orange); font-family: 'Orbitron', sans-serif; }

.accordion-content {
    max-height: 3000px; overflow: hidden; transition: max-height 0.4s ease-in-out;
}
.accordion-content.collapsed { max-height: 0; }
.accordion-content-inner { padding: 8px 0; }

#recipe-breakdown-list ul { list-style: none; padding: 0; }
#recipe-breakdown-list h4 {
    color: var(--color-highlight-yellow); text-shadow: var(--neon-glow-yellow-sm);
    margin: 12px 0 4px 0; border-bottom: 1px dashed rgba(255, 234, 90, 0.3);
    padding-bottom: 4px; font-size: 1.1rem; font-family: 'Orbitron', sans-serif;
}

.craft-item-toggle {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 8px; border-left: 2px solid rgba(0, 229, 255, 0.5);
    font-size: 0.95rem; background: rgba(0,0,0,0.15); color: var(--color-text);
    cursor: pointer; user-select: none; transition: all 0.2s;
}
.craft-item-toggle.base-resource {
    border-left: 2px solid var(--color-accent-orange); color: var(--color-text-dim);
    background: rgba(255, 127, 42, 0.05); cursor: default;
}
.craft-item-toggle:hover { background: rgba(0, 229, 255, 0.1); }
.craft-item-toggle.base-resource:hover { background: rgba(255, 127, 42, 0.1); }
.craft-item-toggle.expanded { background: rgba(0, 229, 255, 0.2); border-left: 2px solid var(--color-neon-blue); }

/* Вложенные списки рецептов */
.recipe-item-children {
    max-height: 2000px; overflow: hidden; transition: max-height 0.4s ease-in-out;
    padding: 0; margin: 0;
}
.recipe-item-children.collapsed { max-height: 0; }
.recipe-item-children-inner {
    padding-left: 12px; margin: 4px 0 4px 4px; border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.craft-item-toggle .toggle-arrow {
    transition: transform 0.3s; display: inline-block; margin-right: 6px;
    color: var(--color-neon-blue); font-size: 0.75rem; transform: rotate(0deg);
}
.craft-item-toggle.expanded .toggle-arrow { transform: rotate(90deg); }
.craft-item-toggle.base-resource .toggle-arrow:before { content: '•'; margin-right: 6px; color: var(--color-accent-orange); font-size: 1.1rem; display: inline-block; }
.craft-item-toggle.base-resource .toggle-arrow { display: inline-block !important; transform: none !important; }

.accordion-title {
    color: var(--color-highlight-yellow); border-bottom: 1px solid var(--color-highlight-yellow);
    padding: 8px 0; margin-top: 20px; text-shadow: var(--neon-glow-yellow-sm);
    cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    user-select: none; transition: background 0.2s;
}
.accordion-title:hover { background: rgba(255, 234, 90, 0.05); }
.accordion-title .toggle-icon { font-size: 0.9rem; transition: transform 0.3s ease; transform: rotate(0deg); color: var(--color-neon-blue); text-shadow: var(--neon-glow-blue-sm); }
.accordion-title:not(.collapsed) .toggle-icon { transform: rotate(90deg); }

/* ========================================= */
/* VII. KO-FI WIDGET STYLES */
/* ========================================= */
.kofi-widget {
    position: fixed;
    top: 25px; 
    left: 25px; 
    z-index: 2000; 
    display: flex;
    align-items: center;
    gap: 15px; 
    
    background: rgba(12, 18, 25, 0.65); 
    padding: 12px 20px; 
    border: 1px solid rgba(0, 229, 255, 0.3); 
    border-radius: 6px;
    backdrop-filter: blur(5px);
    
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.kofi-widget::after {
    content: "SUPPORT DEV";
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem; 
    font-weight: 700; 
    color: var(--color-text-dim);
    letter-spacing: 1.5px;
    transition: color 0.3s ease;
}

.kofi-widget img {
    height: 38px !important; 
    width: auto;
    filter: grayscale(100%) opacity(0.8); 
    transition: all 0.3s ease;
    vertical-align: middle;
}

.kofi-widget:hover {
    background: rgba(12, 18, 25, 0.98);
    border-color: var(--color-neon-blue);
    box-shadow: var(--neon-glow-blue-lg); 
    transform: translateY(2px) scale(1.02); 
}

.kofi-widget:hover img {
    filter: grayscale(0%) opacity(1); 
    transform: scale(1.1) rotate(-5deg); 
}

.kofi-widget:hover::after {
    color: var(--color-neon-blue);
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.8);
}

/* ========================================= */
/* VIII. EXPORT BUTTON STYLES */
/* ========================================= */
.icon-btn {
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid var(--color-neon-blue);
    color: var(--color-neon-blue);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    padding: 4px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 1px;
    margin-left: 10px;
}

.icon-btn:hover {
    background: var(--color-neon-blue);
    color: var(--color-dark-bg);
    box-shadow: 0 0 10px var(--color-neon-blue);
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: translateY(1px);
}

/* Адаптив под мобильные */
@media (max-width: 992px) {
    .container { grid-template-columns: 1fr; gap: 20px; margin: 20px auto; padding: 10px; max-width: 100%; }
    h1.main-title { font-size: 2rem; }
    .panel { max-height: none; padding: 15px; }
    #input-panel, #output-panel { max-height: 80vh; }
    .tab-btn { padding: 10px 10px; font-size: 0.8rem; }
}

@media (max-width: 768px) {
    .kofi-widget {
        top: auto;
        bottom: 20px; 
        left: 20px;
        padding: 10px 15px; 
    }
    .kofi-widget img {
        height: 32px !important; 
    }
    .kofi-widget::after {
        display: none; 
    }
}

@media (max-width: 480px) {
    .panel-header-wrapper {
        flex-direction: row; /* Держим в одной строке */
    }
    .icon-btn {
        font-size: 0.7rem;
        padding: 4px 8px;
    }
}
