/* --- CẤU TRÚC CHÍNH --- */
#kth-pt-app {
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    max-width: 1300px;
    margin: 0 auto;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

[v-cloak] { display: none; }

/* --- 1. TABS (MENU TRÊN CÙNG) --- */
.pt-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #00aeef; /* Màu xanh giống mẫu */
    padding-bottom: 5px;
}

.pt-tabs button {
    background: #e0e0e0;
    border: none;
    padding: 8px 20px;
    cursor: pointer;
    font-weight: 600;
    color: #333;
    transition: all 0.2s;
    font-size: 14px;
    text-transform: uppercase;
}

.pt-tabs button:hover {
    background: #d0d0d0;
}

.pt-tabs button.active {
    background: #00aeef; /* Active màu xanh */
    color: #fff;
}

/* --- 2. BẢNG ĐIỀU KHIỂN CHI TIẾT (PANEL TRÊN) --- */
.pt-controls {
    min-height: 180px;
    margin-bottom: 20px;
    background: #fdfdfd;
    border: 1px solid #eee;
    padding: 15px;
    border-radius: 4px;
}

.element-detail-box {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

/* Khối hiển thị ký hiệu lớn (Khắc phục lỗi dính chùm) */
.element-big-symbol {
    width: 120px;
    height: 140px;
    border: 2px solid #333;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #fff;
    padding: 10px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    flex-shrink: 0; /* Không bị co lại */
}

/* Màu nền cho ô lớn dựa theo nhóm */
.element-detail-box.alkali .element-big-symbol { background-color: #FF6666; }
.element-detail-box.alkaline-earth .element-big-symbol { background-color: #FFDEAD; }
.element-detail-box.transition .element-big-symbol { background-color: #FFC0C0; }
.element-detail-box.post-transition .element-big-symbol { background-color: #CCCCCC; }
.element-detail-box.metalloid .element-big-symbol { background-color: #CCCC99; }
.element-detail-box.nonmetal .element-big-symbol { background-color: #E7FF8F; }
.element-detail-box.halogen .element-big-symbol { background-color: #FFFF99; }
.element-detail-box.noble-gas .element-big-symbol { background-color: #C0FFFF; }
.element-detail-box.lanthanoid .element-big-symbol { background-color: #FFBFFF; }
.element-detail-box.actinoid .element-big-symbol { background-color: #FF99CC; }

/* Typography trong ô lớn */
.atom-number {
    font-size: 14px;
    align-self: flex-start; /* Số hiệu nằm góc trái */
    margin-bottom: 5px;
}
.atom-symbol {
    font-size: 48px;
    font-weight: bold;
    line-height: 1;
}
.atom-name {
    font-size: 14px;
    margin-top: 5px;
    font-weight: 600;
}
.atom-mass {
    font-size: 12px;
    margin-top: 2px;
}

/* Nội dung text bên phải */
.element-info-content {
    flex-grow: 1;
}
.element-info-content h4 { margin-top: 0; color: #00aeef; }
.guide-text { color: #888; font-style: italic; margin-top: 10px; }

/* --- 3. BẢNG TUẦN HOÀN (GRID) --- */
.pt-wrapper-scroll {
    overflow-x: auto;
    padding-bottom: 20px;
}

.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, 55px); /* Chỉnh lại kích thước ô */
    grid-template-rows: repeat(10, 55px);
    gap: 4px;
    min-width: 1050px;
    margin-top: 10px;
}

.element-card {
    border: 1px solid rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2px 4px;
    cursor: pointer;
    transition: transform 0.1s;
    background-color: #f9f9f9;
    user-select: none;
    position: relative;
}

.element-card:hover {
    transform: scale(1.4);
    z-index: 100;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border: 1px solid #000;
}

/* Đang được chọn */
.element-card.selected {
    border: 2px solid #000;
    transform: scale(1.1);
    z-index: 50;
}

/* Làm mờ khi filter */
.element-card.dimmed {
    opacity: 0.15;
    filter: grayscale(100%);
}

.el-number { font-size: 9px; color: #444; }
.el-symbol { font-size: 16px; font-weight: bold; text-align: center; display: block; margin-top: -2px;}
.el-name { font-size: 8px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display:none;} /* Ẩn tên ở ô nhỏ cho gọn */

/* Label Lantan/Actini */
.period-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #00aeef;
    border: 1px solid #00aeef;
}

/* --- 4. CHÚ THÍCH & FILTER (Mũi tên đỏ dưới) --- */
.pt-footer-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    justify-content: center;
}

.legend-item {
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 15px;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.legend-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* MÀU SẮC (Dùng chung cho Card và Legend) */
.alkali, .legend-item.alkali { background-color: #FF6666; }
.alkaline-earth, .legend-item.alkaline-earth { background-color: #FFDEAD; }
.transition, .legend-item.transition { background-color: #FFC0C0; }
.post-transition, .legend-item.post-transition { background-color: #CCCCCC; }
.metalloid, .legend-item.metalloid { background-color: #CCCC99; }
.nonmetal, .legend-item.nonmetal { background-color: #E7FF8F; }
.halogen, .legend-item.halogen { background-color: #FFFF99; }
.noble-gas, .legend-item.noble-gas { background-color: #C0FFFF; }
.lanthanoid, .legend-item.lanthanoid { background-color: #FFBFFF; }
.actinoid, .legend-item.actinoid { background-color: #FF99CC; }

/* --- STYLE CHO TAB LỊCH SỬ --- */
.history-panel {
    animation: fadeIn 0.3s ease;
}

.history-header h4 {
    margin: 0 0 15px 0;
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
    font-size: 16px;
    text-transform: uppercase;
}

.history-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
    background: #f4f4f4;
    padding: 10px;
    border-radius: 4px;
}

.history-item {
    display: flex;
    flex-direction: column;
}

.h-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    font-weight: 600;
}

.h-value {
    font-size: 15px;
    font-weight: bold;
    color: #000;
}

.h-value.year { color: #d35400; } /* Màu cam đất cho năm */
.h-value.discoverer { color: #2980b9; } /* Màu xanh cho tên người */

.history-content {
    font-size: 14px;
    line-height: 1.5;
    color: #444;
    background: #fff;
    border-left: 3px solid #00aeef;
    padding: 10px 15px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- STYLE CHO TAB TÍNH CHẤT --- */
.properties-panel {
    animation: fadeIn 0.3s ease;
}

.prop-header h4 {
    margin: 0 0 15px 0;
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
    font-size: 16px;
    text-transform: uppercase;
}

.prop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Tự động chia cột */
    gap: 15px;
}

.prop-card {
    background: #f9f9f9;
    padding: 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #eee;
    transition: transform 0.2s;
}

.prop-card.full-width {
    grid-column: 1 / -1; /* Chiếm toàn bộ chiều rộng */
    background: #eefbff;
    border-color: #bde0ff;
}

.prop-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
}

.prop-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.prop-info {
    display: flex;
    flex-direction: column;
}

.prop-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #777;
    margin-bottom: 2px;
    font-weight: 600;
}

.prop-value {
    font-size: 15px;
    font-weight: bold;
    color: #222;
}

.prop-value.config {
    font-family: 'Courier New', monospace; /* Font chữ cho cấu hình e */
    color: #d35400;
}

/* Màu trạng thái */
.prop-value.state.solid { color: #555; }
.prop-value.state.liquid { color: #2980b9; font-style: italic; } /* Màu xanh, nghiêng cho lỏng */
.prop-value.state.gas { color: #e74c3c; } /* Màu đỏ cho khí */

/* --- STYLE CHO TAB OBITAN --- */
.orbital-panel {
    animation: fadeIn 0.3s ease;
}

.orbital-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.orbital-info {
    flex: 1;
    min-width: 200px;
    background: #fdfdfd;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #eee;
}

.orb-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed #eee;
    align-items: center;
}

.orb-label { font-size: 12px; color: #666; font-weight: 600; }
.orb-value { font-weight: bold; color: #333; }
.block-tag { 
    text-transform: uppercase; 
    background: #333; 
    color: #fff; 
    padding: 2px 8px; 
    border-radius: 4px; 
    font-size: 12px;
}
.shells-text { font-family: monospace; color: #00aeef; letter-spacing: 1px; }
.config-text { color: #d35400; font-family: 'Courier New', monospace; font-size: 13px; }

/* Mô hình Bohr Visual */
.orbital-visual {
    flex: 1;
    min-width: 250px;
    height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f0f4f8;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.bohr-model {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nucleus {
    width: 30px;
    height: 30px;
    background: #e74c3c;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    color: white;
    font-weight: bold;
    font-size: 10px;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

.electron-shell {
    position: absolute;
    border: 1px solid #999;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Để số e nằm trên đỉnh vòng tròn */
}

.shell-count {
    background: #fff;
    font-size: 9px;
    padding: 0 4px;
    border-radius: 4px;
    margin-top: -6px; /* Đẩy lên trùm lên viền */
    color: #00aeef;
    font-weight: bold;
}

/* --- STYLE CHO TAB ĐỒNG VỊ --- */
.isotope-panel {
    animation: fadeIn 0.3s ease;
}

.iso-header h4 {
    margin: 0 0 15px 0;
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
    font-size: 16px;
    text-transform: uppercase;
}

.iso-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.iso-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.iso-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    background: #f4f4f4;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.iso-info {
    display: flex;
    flex-direction: column;
}

.iso-label {
    font-size: 12px;
    text-transform: uppercase;
    color: #888;
    font-weight: 700;
    margin-bottom: 5px;
}

.iso-value {
    font-size: 15px;
    color: #333;
    line-height: 1.5;
}

/* Màu sắc riêng cho từng loại thẻ */
.iso-card.stable-card {
    border-left: 4px solid #2ecc71; /* Xanh lá */
}
.iso-card.radio-card {
    border-left: 4px solid #f39c12; /* Cam */
}
.iso-card.note-card {
    border-left: 4px solid #3498db; /* Xanh dương */
    background: #f0f8ff;
}

.note-text {
    font-style: italic;
    color: #555;
}

.pt-scroll-hint {
    display: none; /* Ẩn trên Desktop */
    text-align: center;
    font-size: 11px;
    color: #888;
    margin-bottom: 5px;
    font-style: italic;
    animation: pulse 2s infinite;
}

@media (max-width: 768px) {
    .pt-scroll-hint {
        display: block; /* Hiện trên Mobile */
    }
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* =========================================
   RESPONSIVE MOBILE & TABLET (< 768px)
   ========================================= */
@media (max-width: 768px) {

    /* 1. TỐI ƯU CONTAINER */
    #kth-pt-app {
        padding: 10px;
        margin: 0 -10px; /* Tràn viền nhẹ để tận dụng diện tích */
        border-radius: 0;
        box-shadow: none;
    }

    /* 2. MENU TABS TRƯỢT NGANG */
    .pt-tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 10px;
        border-bottom: 1px solid #eee;
        -webkit-overflow-scrolling: touch; /* Cuộn mượt trên iOS */
        scrollbar-width: none; /* Ẩn thanh cuộn trên Firefox */
    }
    .pt-tabs::-webkit-scrollbar { display: none; /* Ẩn thanh cuộn trên Chrome/Safari */ }
    
    .pt-tabs button {
        padding: 6px 12px;
        font-size: 12px;
        flex-shrink: 0; /* Không cho nút bị co lại */
    }

    /* 3. BẢNG ĐIỀU KHIỂN (DETAIL BOX) */
    .pt-controls {
        padding: 10px;
        min-height: auto; /* Bỏ chiều cao tối thiểu để đỡ tốn chỗ */
    }

    .element-detail-box {
        flex-direction: column; /* Xếp chồng dọc */
        gap: 15px;
    }

    /* Biến ô ký hiệu lớn thành nằm ngang cho gọn trên mobile */
    .element-big-symbol {
        width: 100%;
        height: auto;
        flex-direction: row; /* Chuyển số liệu sang ngang */
        justify-content: space-between;
        padding: 10px 20px;
        box-sizing: border-box;
        border-width: 1px;
    }

    .atom-symbol { font-size: 32px; margin: 0 15px; } /* Giảm cỡ chữ */
    .atom-number, .atom-mass { font-size: 12px; }
    .atom-name { font-size: 14px; }

    /* Nội dung chi tiết */
    .element-info-content h4 { font-size: 14px; margin-bottom: 5px; }
    .element-info-content p, .element-info-content li { font-size: 13px; }

    /* 4. GRID LAYOUT & SCROLLING */
    .pt-wrapper-scroll {
        position: relative;
        /* Tạo hiệu ứng shadow 2 bên để biết là cuộn được */
        background: 
            linear-gradient(to right, white 30%, rgba(255,255,255,0)),
            linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
            radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.2), rgba(0,0,0,0)),
            radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)) 0 100%;
        background-repeat: no-repeat;
        background-color: white;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-position: 0 0, 100%, 0 0, 100%;
        background-attachment: local, local, scroll, scroll;
    }

    .periodic-table {
        /* Giữ nguyên kích thước ô, ép người dùng cuộn ngang */
        /* Không dùng % ở đây vì sẽ làm ô quá bé */
        zoom: 0.9; /* Thu nhỏ nhẹ toàn bộ bảng (chỉ hoạt động trên một số trình duyệt) */
    }

    /* 5. CÁC THẺ CARD (TÍNH CHẤT/ĐỒNG VỊ) */
    .prop-grid, .iso-grid, .history-grid {
        grid-template-columns: 1fr; /* 1 cột duy nhất */
    }
    
    .prop-card, .iso-card {
        padding: 8px;
    }
    
    .prop-icon, .iso-icon {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }

    /* 6. MÔ HÌNH BOHR */
    .orbital-container {
        flex-direction: column;
    }
    .orbital-visual {
        height: 200px; /* Giảm chiều cao */
    }
}