/* --- Import Font từ Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

/* ==========================================================================
   1. ĐỊNH NGHĨA CÁC BIẾN MÀU CHO THEME
   ========================================================================== */

#stvt-test-container {
    /* Theme 1: Default Blue (Mặc định) */
    --primary-color: #3498db;
    --primary-color-dark: #2980b9;
    --secondary-color: #7f8c8d;
    --secondary-color-dark: #95a5a6;
    --highlight-color: #e74c3c;
    --success-color: #27ae60;
    --warning-bg-color: #fffbe6;
    --warning-border-color: #ffc107;
    --warning-text-color: #594400;
    --background-color: #ffffff;
    --background-light: #f8f9fa;
    --background-highlight: #eaf4fc;
    --border-color: #e0e0e0;
    --text-dark: #2c3e50;
    --text-light: #34495e;
    --text-faded: #666;
}

#stvt-test-container.theme-green {
    /* Theme 2: Forest Green */
    --primary-color: #27ae60;
    --primary-color-dark: #229954;
    --highlight-color: #e67e22;
    --success-color: #27ae60;
    --background-highlight: #e8f8f5;
}

#stvt-test-container.theme-purple {
    /* Theme 3: Royal Purple */
    --primary-color: #8e44ad;
    --primary-color-dark: #7d3c98;
    --highlight-color: #f1c40f;
    --background-highlight: #f4ecf7;
}

#stvt-test-container.theme-orange {
    /* Theme 4: Sunset Orange */
    --primary-color: #e67e22;
    --primary-color-dark: #d35400;
    --highlight-color: #3498db;
    --background-highlight: #fef5e7;
}

#stvt-test-container.theme-dark {
    /* Theme 5: Modern Dark */
    --primary-color: #3498db;
    --primary-color-dark: #2980b9;
    --secondary-color: #95a5a6;
    --secondary-color-dark: #bdc3c7;
    --highlight-color: #e67e22;
    --background-color: #2c3e50;
    --background-light: #34495e;
    --background-highlight: #3f5d79;
    --border-color: #4e6a85;
    --text-dark: #ecf0f1;
    --text-light: #bdc3c7;
    --text-faded: #95a5a6;
}


/* ==========================================================================
   2. ÁP DỤNG BIẾN VÀO GIAO DIỆN CHUNG
   ========================================================================== */

#stvt-test-container {
    max-width: 1000px;
    margin: 30px auto;
    padding: 25px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.stvt-step { display: none; }
.stvt-step.active { display: block; }

.stvt-step h3 {
    text-align: center;
    color: var(--text-dark);
    margin-bottom: 20px;
    font-size: 24px;
    font-weight: 500;
    position: sticky;
    top: 0px;
    background-color: color-mix(in srgb, var(--background-color) 95%, transparent);
    padding: 20px 10px;
    margin-top: -25px;
    z-index: 10;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}
.admin-bar .stvt-step h3 { top: 0px; }
.stvt-step h3 .highlight { color: var(--highlight-color); font-weight: 700; }

.stvt-progress-bar { background-color: #ecf0f1; border-radius: 8px; margin-bottom: 25px; overflow: hidden; width: 100%; }
#stvt-test-container.theme-dark .stvt-progress-bar { background-color: var(--background-light); }
.stvt-progress {
    width: 20%; height: 12px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-color-dark));
    border-radius: 8px; transition: width 0.5s ease-in-out;
}

.stvt-choices-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 20px; }
.stvt-choice {
    border: 2px solid #ecf0f1;
    border-radius: 10px;
    cursor: pointer; text-align: center; transition: all 0.25s ease;
    background-color: #fdfdfd;
    padding: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.stvt-choice:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); border-color: #bdc3c7; }
.stvt-choice.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px color-mix(in srgb, var(--primary-color) 40%, transparent);
    background-color: var(--background-highlight);
}
.stvt-choice img { width: 100%; max-width: 200px; height: auto; display: block; border-radius: 5px; }
.stvt-choice span { font-weight: 500; font-size: 15px; color: var(--text-light); margin-top: 10px; display: block; }
.stvt-choice input[type="radio"] { display: none; }

.stvt-age-choices { display: flex; flex-direction: column; gap: 10px; }
.stvt-age-choices label {
    display: block; padding: 15px 20px; background-color: var(--background-light); border: 2px solid #e9ecef;
    border-radius: 8px; cursor: pointer; transition: all 0.2s ease; font-size: 16px; color: var(--text-dark);
}
.stvt-age-choices label:hover { border-color: #ced4da; }
.stvt-age-choices label:has(input:checked) {
    background-color: var(--background-highlight);
    border-color: var(--primary-color);
    font-weight: 500;
}

.stvt-navigation { margin-top: 35px; display: flex; justify-content: space-between; }
.stvt-navigation button {
    padding: 12px 45px; border: none; background-color: var(--primary-color); color: white;
    border-radius: 8px; cursor: pointer; font-size: 16px; font-weight: 500; transition: background-color 0.2s;
}
.stvt-navigation button:hover:not(:disabled) { background-color: var(--primary-color-dark); }
.stvt-navigation button:disabled { background-color: #bdc3c7; cursor: not-allowed; }
#stvt-prev-btn { background-color: var(--secondary-color); }
#stvt-prev-btn:hover { background-color: var(--secondary-color-dark); }


/* ==========================================================================
   3. GIAO DIỆN KẾT QUẢ VÀ CÁC THÀNH PHẦN KHÁC
   ========================================================================== */

#stvt-results-step h2 { text-align: center; color: var(--success-color); margin-bottom: 30px; font-weight: 700; }

#stvt-synthesis-summary {
    background-color: var(--background-highlight);
    border: 1px solid color-mix(in srgb, var(--primary-color) 40%, transparent);
    border-left: 5px solid var(--primary-color);
    border-radius: 8px; padding: 20px 25px; margin-bottom: 30px;
}
#stvt-synthesis-summary h3 { margin-top: 0; color: var(--primary-color-dark); font-size: 22px; }
#stvt-synthesis-summary p { font-size: 17px; line-height: 1.7; color: var(--text-dark); text-align: justify; }
#stvt-synthesis-summary strong { color: var(--highlight-color); }

#stvt-results-content { margin-top: 20px; }
.stvt-result-item {
    background-color: var(--background-color);
    border: 1px solid #e7eaf3;
    border-left: 5px solid var(--primary-color);
    padding: 20px; margin-bottom: 25px; border-radius: 0 8px 8px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07); text-align: justify;
}
.stvt-result-item .finger-title { font-size: 18px; font-weight: 700; color: var(--text-dark); margin-top: 0; margin-bottom: 10px; }
.stvt-result-item .general-desc {
    font-size: 16px; color: var(--text-faded); margin-bottom: 20px; font-style: italic;
    border-left: 3px solid #f0f0f0; padding-left: 15px;
}
.result-section { margin-top: 15px; }
.result-section h5 { font-size: 18px; margin-bottom: 10px; color: var(--text-dark); border-bottom: 2px solid #ecf0f1; padding-bottom: 5px; font-weight: 500; }
.result-section p { color: var(--text-light); line-height: 1.6; margin: 0; padding-left: 20px; position: relative; font-size: 16px; }
.result-section p::before { content: '▪'; color: var(--primary-color); position: absolute; left: 0; top: 2px; }
.result-section ul { display: none; } /* Bỏ style cũ của ul/li */

.stvt-actions-bar { display: flex; gap: 15px; justify-content: center; margin-bottom: 25px; }
.stvt-actions-bar button {
    padding: 10px 20px; border: 1px solid #bdc3c7; background-color: #f4f6f8; color: #34495e;
    border-radius: 8px; cursor: pointer; font-size: 15px; font-weight: 500; transition: all 0.2s;
}
.stvt-actions-bar button:hover { background-color: #e5e9ed; border-color: #95a5a6; }
#stvt-share-btn { background-color: #3b5998; color: white; border: none; }
#stvt-share-btn:hover { background-color: #344e86; }

.stvt-disclaimer {
    margin-top: 40px; padding: 20px;
    background-color: var(--warning-bg-color);
    border: 1px solid color-mix(in srgb, var(--warning-border-color) 80%, transparent);
    border-left: 5px solid var(--warning-border-color);
    border-radius: 8px; font-size: 14px; color: var(--warning-text-color);
}
.stvt-disclaimer h4 { margin-top: 0; color: color-mix(in srgb, var(--warning-text-color) 80%, black); font-size: 16px; font-weight: 500; text-align: justify; }


/* ==========================================================================
   4. ĐIỀU CHỈNH RIÊNG CHO THEME DARK
   ========================================================================== */

#stvt-test-container.theme-dark .stvt-progress-bar,
#stvt-test-container.theme-dark .result-section h5,
#stvt-test-container.theme-dark .stvt-result-item .general-desc {
    border-color: var(--border-color);
}
#stvt-test-container.theme-dark .stvt-choice,
#stvt-test-container.theme-dark .stvt-age-choices label,
#stvt-test-container.theme-dark .stvt-result-item {
    background-color: var(--background-light);
    border-color: var(--border-color);
}
#stvt-test-container.theme-dark .stvt-choice:hover {
    border-color: #fff;
}
#stvt-test-container.theme-dark .stvt-actions-bar button {
    background-color: var(--background-light);
    color: var(--text-dark);
    border-color: var(--secondary-color);
}
#stvt-test-container.theme-dark .stvt-actions-bar button:hover {
    background-color: var(--background-highlight);
}


/* ==========================================================================
   5. TỐI ƯU RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .stvt-choices-grid { grid-template-columns: repeat(2, 1fr); }
    .stvt-step h3 { font-size: 20px; }
}
@media (max-width: 480px) {
    #stvt-test-container { padding: 15px; }
    .stvt-choices-grid { grid-template-columns: 1fr; gap: 15px; }
    .stvt-step h3 { font-size: 18px; padding: 15px 5px; }
    .stvt-navigation { flex-direction: column-reverse; gap: 10px; }
    .stvt-navigation button { width: 100%; }
}

/* ==========================================================================
   6. [MỚI] TRẠNG THÁI LOADING CHO NÚT BẤM
   ========================================================================== */
.stvt-navigation button.stvt-loading {
    position: relative;
    color: transparent !important; /* Ẩn chữ đi */
    pointer-events: none; /* Vô hiệu hóa click */
}

.stvt-navigation button.stvt-loading::after {
    content: 'Đang xử lý...';
    color: white; /* Màu chữ trạng thái loading */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
}

.stvt-navigation button.stvt-loading::before {
    content: '';
    display: block;
    position: absolute;
    left: 25px; /* Điều chỉnh vị trí của spinner */
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: stvt-spin 1s linear infinite;
}

@keyframes stvt-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Điều chỉnh vị trí spinner trên mobile */
@media (max-width: 480px) {
    .stvt-navigation button.stvt-loading::before {
        left: 30%;
    }
}

/* ==========================================================================
   7. [MỚI] CSS CHO THANH THỐNG KÊ
   ========================================================================== */
.stvt-stats-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}
.stvt-stat-item {
    background-color: #f1f3f5;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    color: #495057;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
#stvt-test-container.theme-dark .stvt-stat-item {
    background-color: var(--background-light);
    color: var(--text-light);
}
.stvt-stat-rating strong {
    color: #333;
    font-weight: 700;
}
#stvt-test-container.theme-dark .stvt-stat-rating strong {
    color: #fff;
}
.stvt-stat-rating .stars {
    color: #f59f00;
}
/* ==========================================================================
   8. [MỚI] CSS CHO TIÊU ĐỀ VÀ MODAL HƯỚNG DẪN
   ========================================================================== */

.stvt-main-header {
    text-align: center;
    margin-bottom: 20px; /* Giảm khoảng cách dưới 1 chút */
    position: relative;
}

.stvt-main-header h1 {
    color: var(--text-dark);
    margin: 0 0 15px 0; /* Thêm khoảng cách dưới cho tiêu đề */
    font-size: 32px; /* Tăng kích thước cho nổi bật */
    font-weight: 700;
}

#stvt-info-btn {
    /* Bỏ position absolute để nút nằm dưới tiêu đề */
    background-color: var(--background-highlight);
    border: 1px solid color-mix(in srgb, var(--primary-color) 40%, transparent);
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 20px;
    font-family: inherit;
    transition: all 0.2s ease;
}

#stvt-info-btn:hover {
    background-color: color-mix(in srgb, var(--primary-color) 15%, transparent);
    border-color: var(--primary-color);
}

/* --- Modal Styles --- */
#stvt-info-modal {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: stvt-fade-in 0.3s ease;
}

@keyframes stvt-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.stvt-info-modal-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
}

.stvt-info-modal-content {
    position: relative;
    background-color: var(--background-color);
    color: var(--text-light);
    padding: 30px;
    border-radius: 10px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    text-align: justify;
}

#stvt-test-container.theme-dark .stvt-info-modal-content {
    background-color: var(--background-light);
    color: var(--text-dark);
}

.stvt-info-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 18px;
    font-weight: bold;
    color: #aaa;
    background: none;
    border: none;
    cursor: pointer;
}
.stvt-info-modal-close:hover { color: #333; }

.stvt-info-modal-body h3 {
    color: var(--primary-color);
    margin-top: 0;
    font-size: 22px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.stvt-info-modal-body p {
    line-height: 1.7;
    margin-bottom: 15px;
}

.stvt-info-modal-body ul {
    list-style: none;
    padding-left: 0;
}

.stvt-info-modal-body li {
    padding-left: 25px;
    position: relative;
    margin-bottom: 10px;
}

.stvt-info-modal-body li::before {
    content: '✓';
    color: var(--success-color);
    font-weight: bold;
    position: absolute;
    left: 0;
    top: 2px;
}

.stvt-info-modal-body .stvt-info-note {
    font-style: italic;
    font-size: 14px;
    padding: 10px;
    background-color: var(--background-highlight);
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .stvt-main-header h1 { font-size: 22px; }
    #stvt-info-btn {
        position: static;
        transform: none;
        margin-top: 10px;
        display: inline-block;
    }
}
/* ==========================================================================
   9. [MỚI] CSS CHO MÀN HÌNH INTRO
   ========================================================================== */

#stvt-intro-step {
    text-align: center;
    padding: 20px 10px;
}

.stvt-intro-text {
    font-size: 18px;
    line-height: 1.7;
    color: var(--text-light);
    max-width: 800px;
    margin: 0 auto 30px auto;
}

#stvt-start-btn {
    padding: 15px 50px;
    border: none;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-color-dark));
    color: white;
    border-radius: 50px;
    cursor: pointer;
    font-size: 20px;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px color-mix(in srgb, var(--primary-color) 40%, transparent);
    margin-bottom: 30px;
}

#stvt-start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--primary-color) 50%, transparent);
}

/* Điều chỉnh lại khối disclaimer khi nằm trong intro */
#stvt-intro-step .stvt-disclaimer {
    margin-top: 20px;
    text-align: justify;
}
/* ==========================================================================
   9. [MỚI] CSS CHO MÀN HÌNH INTRO
   ========================================================================== */

#stvt-intro-step {
    text-align: center;
    padding: 20px 10px;
}

.stvt-intro-text {
    font-size: 18px;
    line-height: 1.7;
    color: var(--text-light);
    max-width: 800px;
    margin: 0 auto 30px auto;
}

#stvt-start-btn {
    padding: 15px 50px;
    border: none;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-color-dark));
    color: white;
    border-radius: 50px;
    cursor: pointer;
    font-size: 20px;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px color-mix(in srgb, var(--primary-color) 40%, transparent);
    margin-bottom: 30px;
}

#stvt-start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--primary-color) 50%, transparent);
}

/* Điều chỉnh lại khối disclaimer khi nằm trong intro */
#stvt-intro-step .stvt-disclaimer {
    margin-top: 20px;
    text-align: justify;
}

/* ==========================================================================
   10. [MỚI] CSS CHO NÚT LÀM LẠI TEST
   ========================================================================== */

#stvt-redo-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
}
#stvt-redo-btn:hover {
    background-color: var(--secondary-color-dark);
}

#stvt-test-container.theme-dark #stvt-redo-btn {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #fff;
}
#stvt-test-container.theme-dark #stvt-redo-btn:hover {
    background-color: var(--secondary-color-dark);
}