@import url('https://fonts.googleapis.com/css2?family=Bungee&display=swap');

.chem-neo-wrapper {
    font-family: system-ui, -apple-system, sans-serif;
    max-width: 1000px; margin: 20px auto;
    border: 3px solid #000; border-radius: 12px;
    box-shadow: 8px 8px 0px #000; padding: 25px;
    background: #fff; color: #000; box-sizing: border-box;
}

.chem-neo-wrapper * { box-sizing: border-box; }

.chem-header {
    background: #cbaacb; padding: 15px 20px; border-radius: 12px;
    border: 3px solid #000; box-shadow: 4px 4px 0px #000; margin-bottom: 25px; text-align: center;
}
.chem-header h2 { margin: 0 0 5px 0; font-size: 1.8rem; font-weight: 900; text-transform: uppercase; color: #000; }
.chem-header p { margin: 0; font-weight: 800; font-size: 0.95rem; }

.info-banner {
    background: #e2f0cb; padding: 15px 20px; border: 3px dashed #000; border-radius: 8px;
    font-weight: 800; font-size: 1.05rem; color: #000; margin-bottom: 20px; line-height: 1.4;
}

.chem-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 15px; }
.chem-group label { font-weight: 900; font-size: 1.2rem; color: #000; text-transform: uppercase; }

/* AUTOCOMPLETE WRAPPER */
.autocomplete-wrapper { position: relative; }
.chem-neo-input {
    width: 100%; padding: 20px; font-size: 1.3rem; font-weight: 900; font-family: 'Courier New', Courier, monospace;
    border-radius: 8px; border: 3px solid #000; background: #f4f4f4; color: #000;
    outline: none; box-shadow: inset 4px 4px 0px rgba(0,0,0,0.05); transition: 0.1s; letter-spacing: 1px;
}
.chem-neo-input:focus { border-color: #ff595e; background: #fff; }

/* DROPDOWN GỢI Ý */
.autocomplete-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 1000;
    background: #fff; border: 3px solid #000; border-radius: 8px; box-shadow: 5px 5px 0px #000;
    margin-top: 5px; padding: 0; list-style: none; max-height: 300px; overflow-y: auto;
}
.autocomplete-dropdown.hidden { display: none; }
.autocomplete-dropdown li {
    padding: 15px; border-bottom: 2px dashed #ccc; font-family: 'Courier New', monospace; font-weight: 800;
    font-size: 1.1rem; cursor: pointer; color: #333; transition: 0.1s;
}
.autocomplete-dropdown li:hover { background: #b5ead7; color: #000; }
.autocomplete-dropdown li:last-child { border-bottom: none; }

/* VÍ DỤ NHANH */
.quick-examples { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 25px; }
.ex-label { font-weight: 900; font-size: 1rem; color: #000; background: #ffdac1; padding: 5px 10px; border: 2px solid #000; border-radius: 6px; }
.ex-btn {
    cursor: pointer; padding: 6px 12px; font-weight: 800; font-family: monospace; font-size: 1rem;
    background: #fff; border: 2px solid #000; border-radius: 6px; box-shadow: 2px 2px 0px #000; transition: 0.1s;
}
.ex-btn:active { transform: translate(2px, 2px); box-shadow: 0px 0px 0px #000; }

/* NÚT TÍNH TOÁN */
.action-row { display: flex; gap: 15px; margin-bottom: 25px; }
.chem-btn-primary {
    flex: 3; cursor: pointer; font-size: 1.5rem; font-weight: 900; padding: 15px;
    background-color: #ffca3a; border: 3px solid #000; border-radius: 8px; box-shadow: 5px 5px 0px #000;
    text-transform: uppercase; color: #000; transition: 0.1s;
}
.chem-btn-primary:active { transform: translate(5px, 5px); box-shadow: 0px 0px 0px #000; }

.chem-btn-secondary {
    flex: 1; cursor: pointer; font-size: 1.2rem; font-weight: 900; padding: 15px;
    background-color: #fff; border: 3px solid #000; border-radius: 8px; box-shadow: 4px 4px 0px #000;
    text-transform: uppercase; color: #000; transition: 0.1s;
}
.chem-btn-secondary:active { transform: translate(4px, 4px); box-shadow: 0px 0px 0px #000; }

/* KẾT QUẢ CÂN BẰNG */
.result-area { background-color: #fdfd96; border: 3px solid #000; border-radius: 8px; padding: 25px; }
.result-area.hidden { display: none; }

.result-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px dashed #000; padding-bottom: 10px; margin-bottom: 20px; }
.result-header h3 { margin: 0; font-size: 1.4rem; font-weight: 900; color: #000; }
.btn-copy-chem { background: #b5ead7; border: 3px solid #000; border-radius: 6px; padding: 8px 15px; font-weight: 900; cursor: pointer; box-shadow: 3px 3px 0px #000; transition: 0.1s; }
.btn-copy-chem:active { transform: translate(3px, 3px); box-shadow: 0px 0px 0px #000; }

.alert-box { background: #ffb7b2; padding: 15px; border: 3px solid #000; border-radius: 8px; font-weight: 900; font-size: 1.1rem; margin-bottom: 15px; color: #000; line-height: 1.4;}
.alert-box.hidden { display: none; }

.balanced-output {
    font-family: 'Consolas', 'Courier New', monospace; font-size: 2.2rem; font-weight: 900;
    color: #000; background: #fff; padding: 25px; border: 3px solid #000; border-radius: 8px;
    box-shadow: inset 4px 4px 0px rgba(0,0,0,0.05); text-align: center; word-break: break-word; line-height: 1.5;
}
.chem-coef { color: #ff595e; font-size: 2.8rem; margin-right: 2px; } 
.chem-plus, .chem-arrow { color: #000; margin: 0 15px; }

.element-list { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.el-badge { background: #fff; border: 2px solid #000; padding: 5px 15px; border-radius: 20px; font-weight: 900; font-size: 1.1rem; box-shadow: 2px 2px 0px #000; }

/* THÔNG TIN CHUYÊN SÂU (EXTRA INFO) */
.extra-info-area { margin-top: 25px; border-top: 3px dashed #000; padding-top: 25px; }
.extra-info-area.hidden { display: none; }

.details-box { background: #fff; border: 3px solid #000; border-radius: 8px; padding: 20px; box-shadow: 4px 4px 0px #000; margin-bottom: 20px; }
.details-box p { margin: 0 0 10px 0; font-size: 1.1rem; line-height: 1.5; font-weight: 600; color: #333; }
.details-box p b { color: #000; font-weight: 900; text-transform: uppercase; }
.details-box p:last-child { margin-bottom: 0; }

.substances-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.sub-card { background: #fff; border: 3px solid #000; border-radius: 8px; box-shadow: 4px 4px 0px #000; overflow: hidden; display: flex; flex-direction: column; }
.sub-role { padding: 8px 15px; font-weight: 900; font-size: 0.95rem; text-transform: uppercase; border-bottom: 3px solid #000; }
.role-re { background: #ffdac1; } /* Chất tham gia */
.role-pr { background: #b5ead7; } /* Sản phẩm */

.sub-header { padding: 15px; border-bottom: 2px dashed #000; display: flex; justify-content: space-between; align-items: center; }
.sub-name { font-weight: 900; font-size: 1.2rem; color: #000; }
.sub-formula { font-family: monospace; font-size: 1.3rem; font-weight: 900; color: #ff595e; background: #f4f4f4; padding: 4px 10px; border-radius: 6px; border: 2px solid #000; }

.sub-props { list-style: none; margin: 0; padding: 0; }
.sub-props li { padding: 10px 15px; border-bottom: 1px solid #eee; font-size: 1.05rem; }
.sub-props li b { color: #000; font-weight: 800; }
.sub-desc { padding: 15px; font-size: 1rem; color: #444; margin: 0; line-height: 1.5; font-style: italic; background: #fcfcfc; flex-grow: 1; }

#toastChem { visibility: hidden; min-width: 200px; background-color: #000; color: #fff; text-align: center; border-radius: 8px; padding: 12px; position: fixed; z-index: 9999; bottom: 30px; left: 50%; transform: translateX(-50%); font-weight: bold; opacity: 0; transition: opacity 0.3s, bottom 0.3s; }
#toastChem.show { visibility: visible; opacity: 1; bottom: 50px; }

@media (max-width: 600px) {
    .action-row { flex-direction: column; }
    .balanced-output { font-size: 1.5rem; }
    .chem-coef { font-size: 2rem; }
    .sub-header { flex-direction: column; align-items: flex-start; gap: 10px; }
}