body { 
    background-color: #f9fafc; /* Màu nền dự phòng khi ảnh tải chậm */
    background-image: url('/hinh/bg.jpg'); /* Link dẫn đến ảnh nền của bạn */
    background-size: cover; /* Ép ảnh giãn ra phủ kín toàn bộ màn hình */
    background-position: center; /* Luôn giữ tâm điểm của bức ảnh */
    background-repeat: no-repeat; /* Không để ảnh bị lặp lại nhiều lần */
    background-attachment: fixed; /* Khóa chặt ảnh nền, chỉ cho form trượt lên xuống */
    
    font-family: 'Segoe UI', sans-serif; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    min-height: 100dvh; /* Dùng min-height để web co giãn tốt hơn */
    margin: 0; 
    padding: 10px; 
    position: relative; 
    overflow-y: auto; 
    overflow-x: hidden; 
    overscroll-behavior-y: auto; 
}
@media (min-width: 1024px) { body { padding: 20px; } }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.form-container { 
    /* Đổi nền trắng thành nền đen trong suốt */
    background: rgba(0, 0, 0, 0.45); 
    
    
    /* Thêm viền trắng siêu mờ để tạo hiệu ứng khối kính */
    border: 1px solid rgba(255, 255, 255, 0.15); 
    
    /* Bóng đổ đậm hơn một chút để form nổi bật trên nền ảnh */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); 
    
    border-radius: 15px; 
    padding: 20px; 
    width: 100%; 
    max-width: 500px; 
    margin: auto; 
    overflow: visible; 
    z-index: 10; 
    position: relative; 
}
@media (min-width: 1024px) { .form-container { padding: 30px; } }

.input-field { border: 1px solid #e2e8f0; border-radius: 8px; padding: 11.5px 14px; width: 100%; outline: none; font-size: 14.5px; }
.submit-btn { 
    background: #004b93; 
    color: white; 
    font-weight: bold; 
    padding: 12px; 
    border-radius: 8px; 
    cursor: pointer; 
    text-transform: uppercase; 
    transition: 0.05s; 
    
    /* 🌟 ĐỒNG BỘ KHOẢNG CÁCH: Ép cứng lề trên cho cả 2 chế độ */
    margin-top: 10px !important; 
    display: block;
    margin-left: auto;
    margin-right: auto;
}
.submit-btn:hover { background: #003a75; }
.submit-btn-outline { background: transparent; color: #004b93; font-weight: bold; padding: 12px; border-radius: 8px; cursor: pointer; text-transform: uppercase; transition: 0.3s; text-decoration: underline; }
.submit-btn-outline:hover { color: #003a75; }

.autocomplete-list { position: absolute; bottom: 100%; margin-bottom: 6px; z-index: 9999; width: 100%; background: white; border: 1px solid #e2e8f0; border-radius: 8px; max-height: 338px; overflow-y: auto; display: none; box-shadow: 0 -10px 25px rgba(0,0,0,0.15); }

/* --- TRƯỚC ĐOẠN THAY: .autocomplete-list { ... } --- */

#result-container { 
    display: none; 
    width: 100%; 
    max-width: 1500px; 
    background: white; 
    padding: 15px; 
    border-radius: 12px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.05); 
    /* ÉP CỨNG: Bỏ height 100% và overflow-y để hết lỗi mảng trắng đáy */
    height: auto !important; 
    overflow: visible !important; 
    position: relative;
    margin-bottom: 60px; /* Tạo khoảng trống an toàn dưới đáy */
}

/* --- SAU ĐOẠN THAY: @media (min-width: 1024px) { #result-container { ... } } --- */
@media (min-width: 1024px) { #result-container { padding: 40px; border-radius: 15px; height: auto; max-height: 100%; } }

.chart-svg-wrapper { display: flex; justify-content: center; align-items: center; }
.chart-svg-wrapper svg { width: 100%; height: 650px; transform: scale(0.88); transform-origin: center center; }
@media (min-width: 1024px) { .chart-svg-wrapper svg { transform: scale(0.64); } }

.locked-overlay { background: #f8fafc; border: 1px dashed #004b93; padding: 12px; border-radius: 8px; text-align: center; color: #004b93; font-weight: bold; cursor: pointer; transition: color 0.3s ease; margin-top: 10px; margin-bottom: 20px; }
.locked-overlay:hover { color: #10b981; }

.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 1000; justify-content: center; align-items: center; padding: 20px; }
.modal-content { background: white; border-radius: 15px; padding: 30px; max-width: 500px; width: 100%; text-align: center; }
.spinner { border: 4px solid #f3f3f3; border-top: 4px solid #004b93; border-radius: 50%; width: 45px; height: 45px; animation: spin 1s linear infinite; margin: 20px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.card-content { text-align: justify; }
.card-content p { margin-bottom: 10px; } 
.card-content p:last-child { margin-bottom: 0; }
.card-content > br { display: none; }

@media (min-width: 1024px) { .custom-vertical-line::before { content: ''; position: absolute; left: 0; top: 17.5%; height: 65%; width: 1px; background-color: #e5e7eb; } }
.section-heading { font-size: 20px; font-weight: 900; color: #004b93; text-transform: uppercase; text-align: center; padding-bottom: 16px; margin-bottom: 24px; margin-top: 0; width: 100%; position: relative; }
.section-heading::after { content: ''; position: absolute; bottom: 0; left: 17.5%; width: 65%; height: 1px; background-color: #d1d5db; }
#properties-list > div:last-child { border-bottom: 0 !important; }
.tab-item { transition: all 0.3s ease; }

.charts-display { display: flex; flex-direction: column; gap: 40px; align-items: stretch; }
@media (min-width: 1024px) { .charts-display { display: grid; grid-template-columns: 1fr 1.05fr 1fr; gap: 20px; align-items: start; } }
.chart-card-cd { background: transparent; border: none; padding: 0; text-align: center; }
.svg-container-cd {
    width: 75% !important; /* Ép khung chứa về 85% */
    margin: 0 auto !important; /* Luôn luôn nằm giữa */
    display: block !important;
}

/* Đảm bảo hình SVG bên trong luôn lấp đầy cái khung 85% đó */
.svg-container-cd svg { 
    width: 100% !important; 
    height: auto !important; 
    max-height: 70vh; /* Giới hạn chiều cao theo màn hình để không bị quá dài */
}

/* Khi lên máy tính (Laptop/PC) thì trả về 100% như cũ */
@media (min-width: 1024px) { 
    .svg-container-cd { width: 100% !important; } 
}
/* ========================================================================= */
/* ĐỒNG NHẤT 100% TEXT FORM CẢ KHI CHƯA NHẬP VÀ ĐÃ NHẬP */
/* ========================================================================= */

/* 1. MÀU CHỮ SAU KHI ĐÃ NHẬP/CHỌN (Giảm thêm 20% đen cho dịu mắt) */
.input-field {
    color: #4b5563 !important; /* Xám vừa (Gray-600) - Sáng và mềm mại hơn */
    font-size: 14.5px !important; 
    font-weight: 500 !important; 
}

/* 2. MÀU CHỮ MỜ (PLACEHOLDER) - Dành cho ô gõ text */
.input-field::placeholder {
    color: #636871 !important; 
    font-weight: 400 !important;
    opacity: 1 !important;
}

/* 3. MÀU CHỮ MỜ (PLACEHOLDER) - Dành cho ô chọn (Ngày/Tháng/Năm...) chưa được chọn */
select.input-field:invalid {
    color: #636871 !important; 
    font-weight: 400 !important;
}

/* 4. MÀU CHỮ TRONG DANH SÁCH XỔ XUỐNG (Khi bấm vào xem) */
select.input-field option {
    color: #636871 !important; /* Đồng bộ màu xám vừa */
    font-weight: 500 !important;
}

/* 5. Chỉnh size và màu cho danh sách tỉnh thành (Nơi sinh) */
.autocomplete-item {
    font-size: 14.5px !important;
    color: #636871 !important; /* Đồng bộ màu xám vừa */
    padding: 10px 12px !important;
}

/* ========================================================================= */
/* ĐỒNG BỘ NỀN (BACKGROUND) CHO TẤT CẢ CÁC Ô ĐÃ NHẬP/CHỌN XONG */
/* ========================================================================= */

/* 1. Ép nền màu xanh xám siêu nhạt rất sang cho MỌI Ô khi đã nhập/chọn hợp lệ */
.input-field:valid {
    background-color: #f8fafc !important; /* Mã màu Slate-50 rất dịu và hiện đại */
}

/* 2. Đảm bảo nền trắng tinh khiết khi ô còn trống (chưa nhập gì) */
.input-field:invalid {
    background-color: #ffffff !important; 
}

/* 3. "Tiêu diệt" hoàn toàn màu nền xanh mặc định của tính năng Autofill trên Chrome/Cốc Cốc */
.input-field:-webkit-autofill,
.input-field:-webkit-autofill:hover, 
.input-field:-webkit-autofill:focus, 
.input-field:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #f8fafc inset !important; /* Ép nền autofill đồng bộ với nền ở trên */
    -webkit-text-fill-color: #374151 !important; /* Giữ đúng màu chữ xám đậm mà bạn vừa ưng ý */
    transition: background-color 5000s ease-in-out 0s;
}


/* ========================================================================= */
/* LÀM MỜ VÀ LÀM ĐẸP MŨI TÊN CHO CÁC Ô CHỌN (SELECT) */
/* ========================================================================= */
select.input-field {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    
    /* 1. Đẩy mũi tên bám sát mép phải (chỉ cách 6px thay vì 14px) */
    background-position: right 8px center; 
    
    /* 2. Thu nhỏ mũi tên lại một chút xíu cho thanh thoát */
    background-size: 13px; 
    
    /* 3. Giảm khoảng cách 2 bên để nhường đất cho chữ hiển thị */
    padding-left: 8px !important; 
    padding-right: 20px !important; 
    
    cursor: pointer;
}

select.input-field:focus {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* 1. Xóa bỏ hoàn toàn nền tròn và bóng đổ của nút Quay lại */
.back-arrow-btn, 
[onclick*="goBack"] {
    background: transparent !important; /* Xóa màu nền */
    border-radius: 0 !important;       /* Xóa hình tròn */
    box-shadow: none !important;      /* Xóa bóng đổ */
    border: none !important;          /* Xóa viền */
    padding: 0 !important;            /* Xóa khoảng đệm dư thừa */
    
    /* 2. Làm mờ 50% như bạn đã yêu cầu trước đó */
    opacity: 1 !important;
    
    /* 3. Đảm bảo mũi tên nằm ngang (căn giữa) so với vùng chứa */
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    
    transition: opacity 0.2s;
    cursor: pointer;
}

/* 5. Chỉnh kích thước mũi tên bên trong cho thanh thoát */
.back-arrow-btn svg, 
.back-arrow-btn i {
    font-size: 38px !important; /* Chỉnh to nhỏ tùy ý bạn */
    width: auto !important;
    height: auto !important;
	padding-top: 18px !important;
}

/* ======================================================= */
/* ÉP BUỘC 3 BIỂU ĐỒ BẰNG NHAU TUYỆT ĐỐI TRÊN MOBILE */
/* ======================================================= */
@media (max-width: 1023px) {
    /* 1. Triệt tiêu rào cản từ các thẻ cha để tạo sự công bằng */
    .chart-card-cd > div.relative,
    .bg-slate-50 > div.flex-col {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* 2. Ép 3 khung SVG về chung 1 kích thước: 72% chiều rộng màn hình */
    #svg-p1, #svg-p2, #svg-combined {
        width: 66vw !important; 
        max-width: 320px !important; 
        margin: 0 auto !important; 
    }

    /* 3. Đảm bảo bản vẽ bung vừa khít cái khung chuẩn đó */
    #svg-p1 svg, #svg-p2 svg, #svg-combined svg {
        width: 100% !important;
        height: auto !important;
    }
}

/* ======================================================= */
/* GIẢM 10% KÍCH THƯỚC 3 CHART ĐỒNG LOẠT (CHỈ TRÊN DESKTOP) */
/* ======================================================= */
@media (min-width: 1024px) {
    .charts-display {
        width: 96% !important; /* Thu nhỏ tổng thể cụm biểu đồ còn 90% */
        margin: 0 auto !important; /* Canh giữa toàn bộ cụm biểu đồ trên màn hình */
    }
}

/* ======================================================= */
/* ĐẨY CHART NGƯỜI 1 VÀ 2 RA BIÊN THÊM 20PX TRÊN DESKTOP */
/* ======================================================= */
@media (min-width: 1024px) {
    /* Chart Người 1 (Nằm bên trái) -> Đẩy lùi sang trái 20px */
    .charts-display > div:nth-child(1) {
        transform: translateX(-15px) !important;
    }

    /* Chart Người 2 (Nằm bên phải) -> Đẩy lùi sang phải 20px */
    .charts-display > div:nth-child(3) {
        transform: translateX(15px) !important;
    }
}

/* ======================================================= */
/* ĐIỀU CHỈNH CHART CÁ NHÂN TRÊN DESKTOP */
/* ======================================================= */
@media (min-width: 1024px) {
    /* 1. Tăng độ cao từng thẻ hành tinh thêm 5% (Từ 23px lên 24.5px) */
    #canhan-result #design-column > div,
    #canhan-result #personality-column > div {
        height: 24px !important;
        margin-bottom: 3.5px !important; /* Tăng nhẹ khe hở để tổng thể cột dài hơn */
    }

    /* 2. Tăng độ lớn biểu đồ trung tâm thêm 20% (scale từ 0.64 lên 0.77) */
    #canhan-result .chart-svg-wrapper svg {
        transform: scale(0.72) !important;
    }
}

/* ======================================================= */
/* ĐẨY 2 CỘT HÀNH TINH BẢN CÁ NHÂN VÀO TRONG 30PX (DESKTOP) */
/* ======================================================= */
@media (min-width: 1024px) {
    /* Cột Vô Thức (bên trái) -> Tiến vào trung tâm (sang phải) 30px */
    #canhan-result #hd-chart-area > div:first-child {
        transform: translateX(30px) !important;
    }
    
    /* Cột Ý Thức (bên phải) -> Tiến vào trung tâm (sang trái) 30px */
    #canhan-result #hd-chart-area > div:last-child {
        transform: translateX(-30px) !important;
    }
}

/* ======================================================= */
/* ĐỒNG BỘ CÂN BẰNG LỀ TRÊN VÀ DƯỚI CHO KHUNG BÁO CÁO */
/* ======================================================= */

/* 1. Ngăn lỗi cắt xén đỉnh biểu đồ khi cuộn nội dung dài */
body {
    align-items: flex-start !important; 
}

/* 2. Đảm bảo Form nhập liệu ban đầu vẫn nằm chính giữa màn hình */
.form-container {
    margin: auto !important; 
}

/* 3. Triệt tiêu khoảng cách dư thừa cũ của khung báo cáo */
#result-container {
    margin-top: 0 !important;
    margin-bottom: 0 !important; /* Xóa bỏ margin-bottom: 60px cũ */
}

/* 4. Thiết lập lề trên - dưới bằng nhau tuyệt đối (Cả Form và Báo cáo đều theo lề này) */
@media (max-width: 1023px) {
    /* Mobile: Lề trên/dưới 20px - Lề trái/phải 10px */
    body { 
        padding: 20px 10px !important; 
    } 
}

@media (min-width: 1024px) {
    /* Desktop: Lề trên/dưới 40px - Lề trái/phải 20px */
    body { 
        padding: 30px 20px !important; 
    } 
}

/* ======================================================= */
/* FIX LỖI MẢNG TRẮNG ĐÁY & CỐ ĐỊNH THANH ĐỊA CHỈ NHƯ APP  */
/* ======================================================= */
@media (max-width: 1023px) {
    /* 1. Khóa cứng khung trình duyệt để thanh địa chỉ không bao giờ thụt thò */
    html {
        height: 100dvh !important;
        width: 100% !important;
        overflow: hidden !important; 
        background-color: #1a1a1a !important; /* Lót nền màu tối để triệt tiêu hoàn toàn màu trắng */
    }

    /* 2. Chuyển không gian cuộn vào bên trong thẻ body */
    body {
        height: 100dvh !important;
        width: 100% !important;
        overflow-y: auto !important; 
        overflow-x: hidden !important;
        
        /* Tắt hiệu ứng kéo giãn cao su (rubber-band) nguyên nhân chính gây hở đáy */
        overscroll-behavior-y: none !important; 
        
        /* Bật gia tốc phần cứng giúp vuốt mượt như lụa trên điện thoại */
        -webkit-overflow-scrolling: touch !important; 
        
        /* Gỡ bỏ nền cũ ở body để chống lỗi chớp giật nền của iOS/Android */
        background-image: none !important; 
        background-color: transparent !important;
    }

    /* 3. Tạo một lớp hình nền dán chặt vĩnh viễn vào màn hình đằng sau các thẻ */
    body::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100dvh;
        background-image: url('/hinh/bg.jpg');
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        z-index: -1; 
        pointer-events: none; /* Đảm bảo không cản trở thao tác chạm vuốt */
    }
}

/* ======================================================= */
/* HIỆU ỨNG LÀM TỐI NỀN KHI HIỆN BÁO CÁO (CINEMATIC MODE)  */
/* ======================================================= */

/* 1. Tạo một lớp màn che lót dưới mọi thứ, mặc định là trong suốt */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(0, 0, 0, 0); /* Đang trong suốt */
    z-index: 1; /* Nằm đè lên ảnh nền, nhưng nằm dưới khung báo cáo */
    transition: background 0.5s ease-in-out; /* Chuyển cảnh mượt mà 0.5 giây */
    pointer-events: none; /* Đảm bảo không khóa cảm ứng vuốt màn hình */
}

/* 2. Khi có class này, màn che sẽ tối đen lại 75% */
body.report-active::after {
    background: rgba(0, 0, 0, 0.75) !important; 
}

/* 3. Nâng Form và Khung báo cáo lên lớp cao nhất để không bị làm mờ */
#form-container, #result-container {
    position: relative;
    z-index: 10 !important; 
}
