/* ===== Reset & Cơ bản (Dark Mode) ===== */
* {
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: #121212;
    display: flex;
    justify-content: center;
    padding: 20px;
    margin: 0;
    color: #e0e0e0;
}

.container {
    max-width: 1400px;
    width: 100%;
    background: #1e1e1e;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    padding: 25px;
}

h1 {
    text-align: center;
    color: #bb86fc;
    margin-top: 0;
    font-weight: 300;
    letter-spacing: 1px;
}

.subtitle {
    text-align: center;
    color: #aaa;
    margin-bottom: 25px;
    font-style: italic;
}

/* ===== Table wrapper (cuộn ngang) ===== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
    border-radius: 12px;
    border: 1px solid #333;
}

#table-container {
    display: inline-block;
    min-width: 100%;
}

/* ===== Bảng ===== */
table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
    background: #1a1a1a;
}

th,
td {
    border: 1px solid #333;
    padding: 6px 4px;
    text-align: center;
    position: relative;
    transition: background 0.15s;
    color: #ddd;
}

th {
    background: #2a2a2a;
    font-weight: 600;
    color: #bb86fc;
    white-space: nowrap;
}

.header-cation {
    background: #2a2a3a;
}

.header-anion {
    background: #2a2a3a;
}

.corner {
    background: #1f1f2f;
    font-weight: bold;
    color: #bb86fc;
}

/* ===== Màu nền theo trạng thái (tối) ===== */
.status-T {
    background: #1e3a2a;
} /* Tan */
.status-I {
    background: #3a3a1a;
} /* Ít tan */
.status-K {
    background: #3a1a1a;
} /* Không tan */
.status-R {
    background: #2a2a2a;
} /* Phản ứng / không tồn tại */
.status-X {
    background: #1a2a3a;
} /* Bay hơi / phân hủy */
.status-U {
    background: #222;
} /* Chưa rõ */

td:hover {
    filter: brightness(1.3);
    cursor: default;
}

/* ===== Tooltip ===== */
.tooltip {
    display: none;
    position: fixed;
    background: #2a2a3a;
    color: #f0f0f0;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 15px;
    line-height: 1.6;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    z-index: 1000;
    max-width: 300px;
    white-space: nowrap;
    border-left: 5px solid #bb86fc;
}

.tooltip .formula {
    font-weight: 700;
    font-size: 1.2em;
    color: #ffd966;
}

.tooltip .name {
    font-weight: 400;
    color: #cfd8e6;
}

.tooltip .status-badge {
    display: inline-block;
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    margin-top: 4px;
}

.tooltip .status-tan {
    background: #28a745;
    color: white;
}
.tooltip .status-it {
    background: #ffc107;
    color: #212529;
}
.tooltip .status-khong {
    background: #dc3545;
    color: white;
}
.tooltip .status-khongton {
    background: #6c757d;
    color: white;
}
.tooltip .status-bayhoi {
    background: #17a2b8;
    color: white;
}
.tooltip .status-chua {
    background: #6c757d;
    color: white;
}

/* ===== Chú thích ===== */
.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px 25px;
    margin: 20px 0 10px;
    font-size: 13px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ccc;
}

.legend-color {
    width: 20px;
    height: 20px;
    border: 1px solid #555;
    border-radius: 4px;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    margin-top: 25px;
    color: #777;
    font-size: 13px;
    border-top: 1px solid #333;
    padding-top: 15px;
}

footer a {
    color: #bb86fc;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ===== Responsive ===== */
@media (max-width: 800px) {
    table {
        font-size: 11px;
    }
    th,
    td {
        padding: 4px 3px;
    }
    .tooltip {
        font-size: 13px;
        padding: 8px 12px;
        max-width: 220px;
    }
    .container {
        padding: 15px;
    }
}