/* --- Reset & Base Styles --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Fonts */
    --font-primary: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Colors */
    --color-background: #f4f7f9; /* Nền xám rất nhạt, hiện đại */
    --color-surface: #ffffff;    /* Nền của các card */
    --color-text-primary: #333d4f; /* Màu chữ chính (tối, hơi xanh) */
    --color-text-secondary: #7a8b9f; /* Màu chữ phụ (xám xanh nhạt) */
    --color-primary: #4a6cf7;      /* Màu nhấn chính (xanh dương sáng) */
    --color-primary-dark: #385de0;
    --color-secondary: #6c757d;    /* Màu xám trung tính */
    --color-success: #34bfa3;      /* Màu xanh lá cây thành công */
    --color-danger: #f64e60;       /* Màu đỏ lỗi/cảnh báo */
    --color-border: #e1e7ec;       /* Màu viền nhạt */
    --color-border-focus: var(--color-primary);
    --color-placeholder: #a0aec0;
    --color-highlight-bg: rgba(74, 108, 247, 0.08); /* Nền highlight rất nhạt */
    --color-tooltip-bg: rgba(20, 30, 40, 0.85);

    /* Sizing & Spacing */
    --spacing-unit: 8px;
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --max-width-container: 960px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 5px 15px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* --- Global Styles --- */
body {
    font-family: var(--font-primary);
    background-color: var(--color-background);
    color: var(--color-text-primary);
    line-height: 1.65;
    font-size: 15px; /* Base font size */
    padding-bottom: calc(var(--spacing-unit) * 10); /* Không gian cho nút AI */
}

h1, h2, h3, h4 {
    color: var(--color-text-primary);
    margin-bottom: calc(var(--spacing-unit) * 2);
    font-weight: 700;
    line-height: 1.3;
}

h1 { font-size: 2.4rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; font-weight: 500;}

p {
    margin-bottom: var(--spacing-unit);
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

i.fa-solid { /* Style cho icons */
   margin-right: calc(var(--spacing-unit) * 1);
   color: var(--color-primary);
   width: 1.2em; /* Đảm bảo icon có không gian */
   text-align: center;
}
h2 > i.fa-solid, h3 > i.fa-solid, h4 > i.fa-solid {
     color: var(--color-primary);
}


/* --- Layout --- */
.page-container {
    max-width: var(--max-width-container);
    margin: calc(var(--spacing-unit) * 4) auto;
    padding: 0 calc(var(--spacing-unit) * 2);
}

.page-header {
    text-align: center;
    margin-bottom: calc(var(--spacing-unit) * 5);
}

.page-header h1 {
    color: var(--color-primary);
}

.main-content > section:not(:last-child),
.main-content > .bai-lam-area > .phan-bai:not(:last-child) {
    margin-bottom: calc(var(--spacing-unit) * 4);
}

/* --- Card Style --- */
.card {
    background-color: var(--color-surface);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: calc(var(--spacing-unit) * 3) calc(var(--spacing-unit) * 4);
    border: 1px solid var(--color-border);
    overflow: hidden; /* Đảm bảo bóng đổ không bị cắt */
}
.card h2, .card h3 {
    display: flex;
    align-items: center;
    margin-bottom: calc(var(--spacing-unit) * 3);
}
.card h3 {
    font-size: 1.2rem; /* Hơi nhỏ hơn H2 */
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--spacing-unit);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

/* --- Đề bài Section --- */
.de-bai-content {
    background-color: #f9fafb; /* Nền hơi khác biệt nhẹ */
    padding: calc(var(--spacing-unit) * 2.5);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--color-border);
    font-size: 1.05em;
    line-height: 1.7;
    color: var(--color-text-primary);
    min-height: 80px;
}

/* Từ trong đề bài (kéo thả) */
.word {
    cursor: pointer;
    display: inline-block;
    padding: 1px 3px;
    margin: 0 1px;
    border-radius: var(--border-radius-sm);
    transition: background-color 0.2s ease, color 0.2s ease, text-decoration 0.2s ease;
}
.word:hover {
    background-color: var(--color-highlight-bg);
}
.word.underlined {
    text-decoration: underline;
    text-decoration-color: var(--color-primary);
    text-decoration-thickness: 2px;
    font-weight: 500;
    color: var(--color-primary-dark);
    background-color: rgba(74, 108, 247, 0.15); /* Nền đậm hơn khi gạch chân */
}
.word[draggable="true"] {
    cursor: grab;
    background-color: var(--color-success);
    color: white;
    box-shadow: var(--shadow-sm);
}
.word[draggable="true"]:active {
    cursor: grabbing;
}

/* --- Phân tích đề Section --- */
.phan-tich-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: calc(var(--spacing-unit) * 3);
}

.phan-tich-box, .the-loai-box {
    border: 1px solid var(--color-border);
    padding: calc(var(--spacing-unit) * 2.5);
    border-radius: var(--border-radius-md);
    background-color: var(--color-surface); /* Nền trắng giống card */
}

.phan-tich-box {
    min-height: 130px;
    border-style: dashed;
    border-color: var(--color-secondary);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.phan-tich-box:hover, .phan-tich-box.drag-over { /* Thêm class drag-over nếu JS hỗ trợ */
    background-color: var(--color-highlight-bg);
    border-color: var(--color-primary);
}
.phan-tich-box h4 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: var(--spacing-unit);
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}
.phan-tich-box h4 i {
    color: var(--color-text-secondary); /* Icon màu xám */
}

.phan-tich-box .placeholder {
    color: var(--color-placeholder);
    font-style: italic;
    font-size: 0.9em;
    margin-top: auto; /* Đẩy xuống dưới nếu nội dung trống */
    margin-bottom: auto;
}
.phan-tich-box p:not(.placeholder) {
    background-color: var(--color-highlight-bg);
    color: var(--color-primary-dark);
    padding: calc(var(--spacing-unit) * 0.5) calc(var(--spacing-unit) * 1.5);
    border-radius: 20px; /* Bo tròn dạng viên thuốc */
    margin-bottom: var(--spacing-unit);
    cursor: pointer;
    border: 1px solid rgba(74, 108, 247, 0.3);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    font-size: 0.95em;
    display: inline-block; /* Cho phép margin và padding hoạt động */
    margin-right: var(--spacing-unit); /* Khoảng cách giữa các từ */
}
.phan-tich-box p:not(.placeholder):hover {
    background-color: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}

/* Thể loại */
.the-loai-box h4 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: var(--spacing-unit);
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
}
.the-loai-box h4 i {
    color: var(--color-text-secondary);
}
.the-loai-box form label {
    display: block;
    margin-bottom: var(--spacing-unit);
    cursor: pointer;
    font-size: 1em;
    color: var(--color-text-primary);
    transition: color 0.2s ease;
}
.the-loai-box form label:hover {
    color: var(--color-primary);
}
.the-loai-box form input[type="radio"] {
    margin-right: var(--spacing-unit);
    accent-color: var(--color-primary);
    transform: scale(1.1); /* To hơn chút */
}

/* --- Bài làm Section --- */
.bai-lam-area {
    /* Vùng này sẽ chứa các .phan-bai */
}

.phan-bai {
    /* .phan-bai giờ đã có class .card */
}

.phan-bai textarea {
    width: 100%;
    min-height: 150px;
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 2);
    font-family: var(--font-primary);
    font-size: 1em;
    line-height: 1.6;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    resize: vertical;
    margin-top: calc(var(--spacing-unit) * 2);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.phan-bai textarea::placeholder {
    color: var(--color-placeholder);
    opacity: 1;
}
.phan-bai textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.15);
}

/* Gợi ý & Khung ý */
.hint, .khung-y-section {
    background-color: #f0f3ff; /* Nền xanh dương rất nhạt */
    border: 1px solid #d6e0ff; /* Viền xanh nhạt hơn */
    padding: calc(var(--spacing-unit) * 2);
    border-radius: var(--border-radius-md);
    font-size: 0.9em;
    color: #445a84; /* Màu chữ tối hơn */
    margin-bottom: calc(var(--spacing-unit) * 2);
    transition: opacity 0.3s ease, max-height 0.3s ease, margin-bottom 0.3s ease, padding 0.3s ease, border 0.3s ease;
    /* JS xử lý class .hidden */
}

.hint.hidden {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    border: none;
    overflow: hidden;
}

.hint strong, .khung-y-section strong {
    font-weight: 500;
    color: #385de0;
}

.khung-y-section {
    margin-top: calc(var(--spacing-unit) * 2);
}
.khung-y-section ul {
    list-style-type: none;
    padding-left: var(--spacing-unit);
    margin-top: var(--spacing-unit);
}
.khung-y-section ul li {
    margin-bottom: var(--spacing-unit);
    position: relative;
    padding-left: calc(var(--spacing-unit) * 2.5);
}
.khung-y-section ul li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--color-primary);
    font-weight: bold;
    font-size: 1.2em;
    line-height: 1;
}
.khung-y-section ul ul {
    margin-top: calc(var(--spacing-unit) * 0.5);
    padding-left: calc(var(--spacing-unit) * 2);
}
.khung-y-section ul ul li::before {
    content: '◦';
}
.khung-y-section i { /* Tin nhắn placeholder */
    color: var(--color-text-secondary);
}


.counter-container {
    text-align: right;
    font-size: 0.9em;
    color: var(--color-text-secondary);
    margin-top: var(--spacing-unit);
    transition: color 0.2s ease;
}
.counter-container.error { /* JS có thể thêm class này khi vượt quá giới hạn */
    color: var(--color-danger);
    font-weight: 500;
}

/* --- Nộp bài Section --- */
.nop-bai-section {
    text-align: center;
    padding: calc(var(--spacing-unit) * 2) 0;
    margin-top: calc(var(--spacing-unit) * 2); /* Tách khỏi phần cuối */
}

.countdown-timer {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--color-danger);
    margin-bottom: calc(var(--spacing-unit) * 2);
    font-variant-numeric: tabular-nums; /* Giữ độ rộng số ổn định */
}

.nop-bai-button {
    background: linear-gradient(145deg, var(--color-success), #2a9d8f); /* Gradient xanh lá */
    color: white;
    border: none;
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 4);
    font-size: 1.1em;
    font-weight: 500;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-unit);
    box-shadow: var(--shadow-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.nop-bai-button i {
    color: white; /* Icon màu trắng */
}
.nop-bai-button:hover {
    background: linear-gradient(145deg, #2a9d8f, #268a7e);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.nop-bai-button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}
.nop-bai-button:disabled {
    background: var(--color-secondary);
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: none;
    transform: none;
}

/* --- Thống kê & Lịch sử Section --- */
.progress-overview {
    text-align: center;
    margin-bottom: calc(var(--spacing-unit) * 4);
    padding-bottom: calc(var(--spacing-unit) * 3);
    border-bottom: 1px solid var(--color-border);
}
.progress-overview p {
    font-size: 1em;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-unit);
}
#progress-text {
    font-weight: 500;
     color: var(--color-text-primary);
}
.progress-bar-container {
    width: 100%;
    max-width: 500px;
    height: 12px; /* Dày hơn chút */
    background-color: #e9ecef;
    border-radius: 6px;
    margin: calc(var(--spacing-unit) * 1.5) auto;
    overflow: hidden;
}
.progress-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--color-success), #268a7e);
    width: 0%; /* Updated by JS */
    border-radius: 6px;
    transition: width 0.4s ease-in-out;
}
#progress-percentage {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--color-success);
}

.chart-container {
    margin-bottom: calc(var(--spacing-unit) * 4);
    position: relative;
}

/* Tooltip Biểu đồ */
.custom-tooltip {
    position: absolute;
    background: var(--color-tooltip-bg);
    color: #fff;
    padding: calc(var(--spacing-unit) * 1.2) calc(var(--spacing-unit) * 1.8);
    border-radius: var(--border-radius-sm);
    pointer-events: none;
    transition: opacity 0.2s ease;
    opacity: 0;
    font-size: 0.85em;
    white-space: normal;
    max-width: 280px;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    line-height: 1.5;
}
.custom-tooltip strong {
    font-weight: 700;
    display: block;
    margin-bottom: calc(var(--spacing-unit) * 0.5);
    color: #a7c5ff; /* Màu nhấn nhẹ cho tiêu đề */
}

/* Bảng lịch sử */
.history-table-container {
    overflow-x: auto; /* Cuộn ngang trên màn hình nhỏ */
	max-height: 500px;
}
#history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: calc(var(--spacing-unit) * 2);
    font-size: 0.95em;
}
#history-table th, #history-table td {
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 2);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle; /* Căn giữa theo chiều dọc */
}
#history-table thead th {
    background-color: #f9fafb; /* Nền header nhạt */
    font-weight: 500;
    color: var(--color-text-primary);
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
    position: sticky; /* Giữ header khi cuộn */
    top: 0;
    z-index: 1;
}
#history-table tbody tr:hover {
    background-color: var(--color-highlight-bg);
}
#history-table tbody td {
    color: var(--color-text-secondary);
}
#history-table tbody td:nth-child(1), /* STT */
#history-table tbody td:nth-child(4), /* Thời gian */
#history-table tbody td:nth-child(5)  /* Điểm */
{
    text-align: center;
    white-space: nowrap;
}
#history-table tbody td:nth-child(3) { /* Cột đề bài */
     color: var(--color-text-primary);
     font-weight: 500;
     max-width: 350px;
     /* white-space: nowrap; // Bỏ để có thể xuống dòng */
     overflow: hidden;
     text-overflow: ellipsis;
     /* display: -webkit-box; // Thêm để giới hạn số dòng nếu cần */
     /* -webkit-line-clamp: 2; */
     /* -webkit-box-orient: vertical; */
 }
 #history-table tbody td:nth-child(5) select { /* Select điểm */
     font-weight: 700;
     color: var(--color-primary);
 }
 #history-table tbody tr td i { /* Chữ nghiêng cho placeholder */
     color: var(--color-placeholder);
     width: 100%;
     text-align: center;
     display: block;
 }

/* Style cho select chấm điểm */
#history-table select {
    padding: calc(var(--spacing-unit) * 0.8) calc(var(--spacing-unit) * 1.2);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    background-color: var(--color-surface);
    font-size: 0.95em;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-width: 75px;
    font-family: var(--font-primary);
    font-weight: 500;
    color: var(--color-primary);
}
#history-table select:focus {
     outline: none;
     border-color: var(--color-border-focus);
     box-shadow: 0 0 0 2px rgba(74, 108, 247, 0.15);
}
#history-table select:disabled {
    background-color: #e9ecef;
    color: var(--color-text-secondary);
    cursor: not-allowed;
    opacity: 0.8;
    border-color: var(--color-border);
    box-shadow: none;
}



/* --- Responsive --- */
@media (max-width: 768px) {
    :root {
        --spacing-unit: 7px; /* Giảm nhẹ spacing */
    }
    body { font-size: 14px; }
    .page-container { margin: calc(var(--spacing-unit) * 3) auto; }
    h1 { font-size: 2rem; }
    h2 { font-size: 1.4rem; }
    h3 { font-size: 1.1rem; }
    .card { padding: calc(var(--spacing-unit) * 3); }
    .phan-tich-grid { grid-template-columns: 1fr; } /* 1 cột */

    #history-table { font-size: 0.9em; }
    #history-table th, #history-table td { padding: var(--spacing-unit) calc(var(--spacing-unit) * 1.5); }
    #history-table tbody td:nth-child(3) { max-width: 200px; }

  
}

@media (max-width: 480px) {
    :root {
        --spacing-unit: 6px;
    }
    body { font-size: 13px; }
    h1 { font-size: 1.8rem; }
    .card { padding: calc(var(--spacing-unit) * 2.5); border-radius: var(--border-radius-md);}
    .de-bai-content { font-size: 1em; }
    #history-table { font-size: 0.85em; }
    #history-table th, #history-table td { padding: calc(var(--spacing-unit) * 0.8) var(--spacing-unit); }
    #history-table tbody td:nth-child(3) { max-width: 150px; }
    .nop-bai-button { font-size: 1em; padding: var(--spacing-unit) calc(var(--spacing-unit) * 3); }

   
}
/* Container chính của hộp chat */
.support-box {
  /* Giữ các thuộc tính vị trí, kích thước, nền, bóng đổ cũ */
  position: fixed;
  /* bottom: 80px; /* Có thể cần điều chỉnh vị trí Y */
  /* right: 20px; */
  bottom: 20px; /* Đặt lại vị trí gần nút gốc hơn nếu muốn */
  right: 20px;
  width: 500px; /* Chiều rộng tổng thể */
  height: 60vh; /* Chiều cao tổng thể */
  background: white;
  border-radius: 16px; /* Bo góc */
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden; /* Quan trọng */
  z-index: 1000;

  /* --- THAY ĐỔI QUAN TRỌNG --- */
  display: none; /* Mặc định ẩn */
  flex-direction: row; /* Sắp xếp con theo hàng ngang (header trái, iframe phải) */
}

/* Khi hộp chat được mở (có class visible) */
.support-box.visible {
  display: flex; /* Hiện và áp dụng flexbox */
}

/* Thanh header dọc bên trái */
.support-header-bar {
  background: #007bff; /* Màu nền xanh */
  color: white;
  width: 55px; /* Chiều rộng cố định cho thanh dọc */
  height: 100%; /* Chiều cao 100% của container */
  padding: 10px 0; /* Padding trên dưới */
  display: flex;
  flex-direction: column; /* Sắp xếp logo và nút đóng theo chiều dọc */
  justify-content: space-between; /* Đẩy logo lên trên, nút đóng xuống dưới */
  align-items: center; /* Căn giữa theo chiều ngang */
  flex-shrink: 0; /* Không cho phép thanh này co lại */
  box-sizing: border-box; /* Tính cả padding vào width */
}

/* Logo/Title trong header */
.support-header-bar .header-logo {
  font-size: 14px;
  font-weight: bold;
  margin-top: 10px; /* Khoảng cách trên */
  /* Có thể xoay chữ nếu muốn */
  /* writing-mode: vertical-rl; */
  /* transform: rotate(180deg); */
}

/* Phần chứa nút đóng */
.support-header-bar .header-controls {
   margin-bottom: 5px; /* Khoảng cách dưới */
}

/* Nút đóng (X) */
.support-header-bar .close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 24px; /* Kích thước nút X */
  cursor: pointer;
  padding: 0; /* Bỏ padding mặc định */
  line-height: 1; /* Căn chỉnh chiều cao */
}
 .support-header-bar .close-btn:hover {
   opacity: 0.8; /* Hiệu ứng hover đơn giản */
}


/* Iframe chứa nội dung chat */
.support-box iframe {
  flex-grow: 1; /* Chiếm hết không gian ngang còn lại */
  height: 100%; /* Chiếm hết chiều cao */
  border: none; /* Bỏ viền */
  width: auto; /* Để flex-grow kiểm soát chiều rộng */
}

/* --- CSS cho nút bật/tắt gốc --- */
.support-toggle-btn {
  /* Giữ nguyên CSS cũ cho nút này */
  position: fixed;
  bottom: 20px;
  right: 20px;
  /* ... các thuộc tính khác ... */
  z-index: 999; /* Nằm dưới hộp chat khi mở */
}

 /* --- Responsive cho màn hình nhỏ --- */
 @media (max-width: 768px) {
   .support-box {
     width: 95%;
     height: 80vh;
     bottom: 10px; /* Điều chỉnh vị trí */
     right: 2.5%;
   }
   .support-header-bar {
      width: 45px; /* Thu nhỏ thanh header */
   }
    .support-header-bar .header-logo {
       font-size: 12px;
    }
    .support-header-bar .close-btn {
       font-size: 20px;
    }
 }
/* --- CSS Nâng Cấp cho Nút Trợ Lý AI --- */
.support-toggle-btn {
  position: fixed;
  bottom: 25px; /* Hơi nâng lên một chút */
  right: 25px;  /* Hơi cách lề một chút */
  background: linear-gradient(145deg, #0088ff, #0061c5); /* Gradient xanh dương hiện đại */
  color: #fff;
  border: none;
  padding: 10px 20px; /* Điều chỉnh padding */
  border-radius: 12px; /* Bo góc vuông vắn hơn, hiện đại hơn */
  cursor: pointer;
  font-size: 16px;
  font-weight: 600; /* Giữ nguyên hoặc 500 */
  font-family: 'Roboto', sans-serif; /* Đảm bảo font được áp dụng */
  letter-spacing: 0.5px; /* Tăng khoảng cách chữ một chút */
  box-shadow: 0 4px 10px rgba(0, 97, 197, 0.2), /* Bóng mờ chính */
              0 1px 3px rgba(0, 0, 0, 0.1);       /* Bóng nhẹ gần hơn */
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1); /* Transition mượt mà hơn */
  z-index: 999;
  display: inline-flex; /* Sử dụng flex để căn chỉnh icon và text */
  align-items: center;
  gap: 8px; /* Khoảng cách giữa icon và text */
  white-space: nowrap; /* Không xuống dòng */
}

.support-toggle-btn:hover {
  background: linear-gradient(145deg, #007ae0, #0055b0); /* Gradient đậm hơn khi hover */
  transform: translateY(-3px); /* Hiệu ứng nhấc lên nhẹ */
  box-shadow: 0 7px 18px rgba(0, 97, 197, 0.3), /* Bóng đổ rõ hơn khi hover */
              0 3px 6px rgba(0, 0, 0, 0.15);
}

.support-toggle-btn:active {
  transform: translateY(0px); /* Hiệu ứng nhấn xuống */
  background: #0056b3; /* Màu nền đậm khi nhấn */
  box-shadow: 0 2px 5px rgba(0, 97, 197, 0.2); /* Bóng đổ nhỏ hơn khi nhấn */
}
/* --- Nút Hướng dẫn sử dụng --- */
.guide-button {
    background: none;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    padding: calc(var(--spacing-unit) * 0.8) calc(var(--spacing-unit) * 1.5);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.5);
    margin-left: var(--spacing-unit); /* Khoảng cách với tiêu đề nếu cần */
    /* Hoặc đặt vị trí tuyệt đối nếu muốn */
    /* position: absolute; */
    /* top: calc(var(--spacing-unit) * 4); */
    /* right: calc(var(--spacing-unit) * 2); */
}

.guide-button:hover {
    background-color: var(--color-highlight-bg);
    color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}
.guide-button i {
    color: inherit; /* Màu icon theo màu nút */
}

/* --- Modal Hướng dẫn sử dụng --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Nền đen mờ */
    z-index: 1040;
    display: none; /* Ẩn ban đầu */
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--color-surface);
    padding: calc(var(--spacing-unit) * 4);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    width: 90%;
    max-width: 700px; /* Giới hạn chiều rộng modal */
    max-height: 85vh; /* Giới hạn chiều cao */
    overflow-y: auto; /* Cho phép cuộn nếu nội dung dài */
    display: none; /* Ẩn ban đầu */
    opacity: 0;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    transform: translate(-50%, -60%); /* Hiệu ứng trượt nhẹ từ trên xuống */
}

/* Lớp hiển thị modal */
.modal-overlay.modal-visible,
.modal-content.modal-visible {
    opacity: 1;
}
.modal-content.modal-visible {
     transform: translate(-50%, -50%); /* Vị trí cuối cùng khi hiện */
}


.modal-content h2 {
    margin-top: 0;
    margin-bottom: calc(var(--spacing-unit) * 3);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--spacing-unit);
    display: flex;
    align-items: center;
}

.modal-body {
    font-size: 0.95em;
    line-height: 1.7;
}

.modal-body ol {
    padding-left: calc(var(--spacing-unit) * 3);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.modal-body li {
    margin-bottom: calc(var(--spacing-unit) * 2);
}
.modal-body ul {
     list-style-type: disc;
     padding-left: calc(var(--spacing-unit) * 3);
     margin-top: var(--spacing-unit);
}
.modal-body ul li {
     margin-bottom: calc(var(--spacing-unit) * 1);
}

.modal-body code { /* Nếu dùng thẻ code để highlight */
    background-color: var(--color-highlight-bg);
    padding: 2px 5px;
    border-radius: var(--border-radius-sm);
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.modal-close-btn {
    position: absolute;
    top: calc(var(--spacing-unit) * 1.5);
    right: calc(var(--spacing-unit) * 2);
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close-btn:hover {
    color: var(--color-danger);
}

/* Nút ví dụ trong hướng dẫn */
.inline-example-btn {
    padding: 2px 6px !important;
    font-size: 0.8em !important;
    vertical-align: middle;
    cursor: default !important;
    pointer-events: none; /* Không cho phép nhấn */
    display: inline-flex !important;
    margin: 0 2px;
    gap: 4px !important;
}
.inline-example-btn i {
    margin-right: 0 !important;
}
/* === THÊM CSS CHO NÚT TOÀN MÀN HÌNH === */

/* Style chung cho các nút điều khiển trong header AI */
.support-header-bar .control-btn,
.support-header-bar .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 22px; /* Đồng nhất kích thước với nút close */
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: opacity 0.2s ease;
    width: 30px; /* Đảm bảo nút có chiều rộng để click */
    height: 30px; /* Đảm bảo nút có chiều cao để click */
    display: flex; /* Căn giữa icon */
    align-items: center;
    justify-content: center;
}

.support-header-bar .control-btn:hover,
.support-header-bar .close-btn:hover {
    opacity: 0.8;
}

/* Sắp xếp các nút điều khiển trong header */
.support-header-bar .header-controls {
   display: flex;
   flex-direction: column; /* Xếp chồng dọc */
   align-items: center;
   gap: 8px; /* Khoảng cách giữa nút toàn màn hình và nút đóng */
   margin-bottom: 10px; /* Khoảng cách với đáy */
}


/* CSS cho container khi ở chế độ toàn màn hình */
#supportContainer:fullscreen {
    /* Có thể thêm style khác nếu muốn, ví dụ nền khác */
    background-color: #ffffff;
    padding: 0; /* Bỏ padding khi fullscreen */
    border-radius: 0; /* Bỏ bo góc khi fullscreen */
}

/* Căn chỉnh lại header và iframe khi fullscreen */
#supportContainer:fullscreen .support-header-bar {
   border-radius: 0;
}

#supportContainer:fullscreen iframe {
   border-radius: 0;
}

/* Ẩn nút bật/tắt gốc khi AI đang ở chế độ toàn màn hình */
/* Lưu ý: Selector này có thể không hoạt động 100% trên mọi trình duyệt */
#supportContainer:fullscreen ~ .support-toggle-btn {
    display: none !important; /* Ưu tiên ẩn nút gốc */
}

/* === KẾT THÚC CSS THÊM === */