@font-face { font-family: 'Google Sans'; src: url('fonts/GoogleSans-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Google Sans'; src: url('fonts/GoogleSans-BoldItalic.woff2') format('woff2'); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: 'Google Sans'; src: url('fonts/GoogleSans-Medium.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Google Sans'; src: url('fonts/GoogleSans-Italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Google Sans'; src: url('fonts/GoogleSans-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }


/* --- CSS Variables for Light/Dark Mode --- */
:root {
    --bg-color: #f0f2f5; /* Light grey background */
    --text-color: #333; /* Dark grey text */
    --container-bg: #ffffff; /* White container */
    --border-color: #e2e8f0; /* Light grey border */
    --group-bg: #fdfdfd; /* Slightly off-white for control groups */
    --group-border: #d6e1ec; /* Border for control groups */
    --stat-bg: #edf2f7; /* Lighter grey for stats */
    --stat-color: #4a5568; /* Darker text for stats */
    --btn-primary-bg: #4a90e2; /* Blue */
    --btn-primary-hover: #357bd8;
    --btn-danger-bg: #e57373; /* Red for clear */
    --btn-danger-hover: #d32f2f;
    --btn-secondary-bg: #a0aec0; /* Grey for minor buttons */
    --btn-secondary-hover: #718096;
    --textarea-bg: #ffffff;
    --textarea-border: #cbd5e0;
    --input-bg: #ffffff;
    --input-border: #cbd5e0;
    --focus-overlay-color: rgba(255, 255, 255, 0.9); /* Light overlay for focus mode */
    --toast-bg: #333;
    --toast-text: #fff;
    --toggle-switch-bg: #ccc;
    --toggle-switch-checked-bg: #4a90e2;
    --toggle-switch-slider: white;
    --shadow-light: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.1);
    --scroll-thumb: #a0aec0;
    --scroll-track: #edf2f7;

    /* Highlight Colors */
    --highlight-bg: #fff3c4; /* Light yellow for keyword highlight */
    --highlight-border: #ffd700; /* Darker yellow border */

    --placeholder-color: rgba(51, 51, 51, 0.6); /* Color for the dynamic placeholder */

    /* Loading Indicator */
    --loading-spinner-color: #4a90e2;
}

.dark-mode {
    --bg-color: #2c2c2c;
    --text-color: #e0e0e0;
    --container-bg: #3c3c3c;
    --border-color: #555;
    --group-bg: #4a4a4a;
    --group-border: #666;
    --stat-bg: #5a5a5a;
    --stat-color: #ccc;
    --btn-primary-bg: #61affe; /* Brighter blue for dark mode */
    --btn-primary-hover: #4a90e2;
    --btn-danger-bg: #f06292;
    --btn-danger-hover: #e91e63;
    --btn-secondary-bg: #888;
    --btn-secondary-hover: #777;
    --textarea-bg: #222;
    --textarea-border: #666;
    --input-bg: #4a4a4a;
    --input-border: #666;
    --focus-overlay-color: rgba(0, 0, 0, 0.9); /* Dark overlay for focus mode */
    --toast-bg: #eee;
    --toast-text: #333;
    --toggle-switch-bg: #555;
    --toggle-switch-checked-bg: #61affe;
    --toggle-switch-slider: #222;
    --shadow-light: 0 4px 15px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.3);
    --scroll-thumb: #666;
    --scroll-track: #333;

    /* Highlight Colors - Dark Mode */
    --highlight-bg: #a69a00; /* Darker yellow for keyword highlight */
    --highlight-border: #ffd700;

    --placeholder-color: rgba(224, 224, 224, 0.6); /* Color for the dynamic placeholder in dark mode */

    /* Loading Indicator */
    --loading-spinner-color: #61affe;
}

/* --- Global Styles --- */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    /* overflow: hidden; */ /* BỎ DÒNG NÀY ĐI */
}
body {
    font-family: 'Google Sans', system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.6;
    overflow-y: auto; /* Thêm để đảm bảo body có thanh cuộn nếu nội dung vượt quá */
}

.container {
    background-color: var(--container-bg);
    padding: 25px 35px; /* Increased padding for more breathing room */
    border-radius: 16px; /* More rounded corners */
    box-shadow: var(--shadow-light);
    width: 100%;
    max-width: 1500px; /* Slightly wider */
    height: calc(100vh - 85px); /* Vẫn giữ chiều cao giới hạn cho container chính */
    display: flex;
    flex-direction: column;
    gap: 25px; /* Spacing between top bar and main content grid */
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden; /* Giữ overflow hidden cho container để không có thanh cuộn kép */
}

/* --- Top Bar --- */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-grow: 1;
}

.app-header h2 {
    margin: 0;
    font-size: 2rem; /* Larger */
    color: var(--btn-primary-bg);
    font-weight: 700;
    letter-spacing: -0.5px; /* Tighter letter spacing */
}

.app-header h1 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-color);
    font-weight: 500;
    opacity: 0.85;
    border-left: 1px solid var(--border-color);
    padding-left: 18px;
}

.top-bar-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: flex-end;
    font-size: 0.95rem;
}

.theme-toggle-container, .font-size-controls, .focus-mode-container {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap; /* Prevent wrapping for these controls */
}
.theme-toggle-container span, .focus-mode-container span {
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.95rem;
    opacity: 0.9;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 45px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--toggle-switch-bg);
    transition: .4s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: var(--toggle-switch-slider);
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--toggle-switch-checked-bg);
}

input:checked + .slider:before {
    transform: translateX(19px);
}

/* Font Size Buttons */
.font-size-controls button {
    background-color: var(--btn-secondary-bg);
    padding: 5px 10px;
    font-size: 0.9rem;
    border-radius: 6px;
    min-width: 40px;
    border: none;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}
.font-size-controls button:hover {
    background-color: var(--btn-secondary-hover);
    transform: translateY(-1px);
}
.font-size-controls button:active {
    transform: translateY(0);
}
.font-size-controls button i {
    font-size: 0.85rem;
}

/* --- Main Layout: 3 Columns --- */
.main-content-grid {
    display: grid;
    grid-template-columns: 280px 1fr 1fr; /* Wider left column */
    gap: 25px; /* Larger gap between columns */
    flex-grow: 1;
    overflow: hidden; /* Giữ overflow hidden cho grid cha */
    height: 100%; /* Thêm dòng này để grid chiếm hết chiều cao còn lại */
}

.controls-column, .input-column, .output-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    height: 100%; /* Đảm bảo các cột chiếm 100% chiều cao của grid row */
    box-sizing: border-box;
    min-height: 0; /* Rất quan trọng để overflow hoạt động đúng trong flex/grid containers */
    min-width: 0; /* Ngăn các cột đẩy kích thước của chúng */
    /* Đã loại bỏ overflow-x: hidden; để cho phép thanh cuộn ngang trong các cột */
}

.controls-column {
    overflow-y: auto; /* Giữ lại */
    padding-right: 10px; /* Space for scrollbar */
}

textarea, .editable-content {
    width: 100%;
    padding: 18px; /* Increased padding */
    border: 1px solid var(--textarea-border);
    border-radius: 10px; /* More rounded */
    font-size: .9rem;
    flex-grow: 1;
    min-height: 0;
    box-sizing: border-box;
    resize: none; /* Cố định kích thước */
    background-color: var(--textarea-bg);
    color: var(--text-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.2s ease;
    outline: none;
    overflow-y: auto; /* Giữ lại thanh cuộn dọc */
    overflow-x: auto; /* Đã thêm: Cho phép thanh cuộn ngang */
    font-family: 'Google Sans', system-ui, sans-serif; /* Consistent font */
    position: relative; /* Đã thêm: Quan trọng để định vị placeholder */
    /* Đã loại bỏ word-break và overflow-wrap để cho phép thanh cuộn ngang */
}
textarea:focus, .editable-content:focus {
    border-color: var(--btn-primary-bg);
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.2); /* Deeper shadow on focus */
}

/* Placeholder styling for contenteditable divs */
/* This ensures the placeholder is shown via ::before pseudo-element */
.editable-content.output-placeholder-active::before {
    content: attr(placeholder); /* Use the placeholder attribute from HTML */
    color: var(--placeholder-color);
    position: absolute; /* Position it correctly */
    pointer-events: none; /* Allow clicks to pass through */
    /* Đảm bảo placeholder nằm gọn trong padding của phần tử cha */
    top: 18px; /* Đã điều chỉnh để khớp với padding của cha */
    left: 18px; /* Đã điều chỉnh để khớp với padding của cha */
    right: 18px; /* Đã điều chỉnh để khớp với padding của cha */
    bottom: 18px; /* Đã điều chỉnh để khớp với padding của cha */
    /* padding: 0; */ /* Bỏ padding trên chính pseudo-element */
    box-sizing: border-box; /* Quan trọng: Đảm bảo padding được tính vào kích thước của pseudo-element */
    display: block; /* Thay đổi từ flex sang block */
    white-space: pre-wrap; /* Essential for placeholder to respect line breaks if any */
    word-wrap: break-word; /* Ngắt từ dài */
}

/* Hide the placeholder when the contenteditable div has actual content */
.editable-content:not(.output-placeholder-active)::before {
    content: none;
}


.stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    padding: 12px 15px; /* Adjusted padding */
    border-radius: 10px;
    background-color: var(--stat-bg);
    font-size: 0.95em;
    color: var(--stat-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.03); /* Subtle inset shadow */
    flex-shrink: 0;
}
.stats p {
    margin: 5px 10px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}
.stats p i {
    color: var(--btn-primary-bg);
    font-size: 0.9em;
    opacity: 0.7;
}

.controls-group {
    padding: 20px; /* Larger padding */
    border: 1px solid var(--group-border);
    border-radius: 12px; /* More rounded */
    background-color: var(--group-bg);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-light);
    flex-shrink: 0; /* Ensures control groups don't shrink */
}
.controls-group:hover {
     box-shadow: var(--shadow-hover);
}

h3 {
    color: var(--text-color);
    font-size: 1.25rem; /* Larger heading */
    font-weight: 600;
    margin-top: 0;
    padding-bottom: 12px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}
h3 i {
    color: var(--btn-primary-bg);
    font-size: 1em;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px; /* Larger gap */
}

.controls-grid button,
.action-row button,
.output-actions button {
    background-color: var(--btn-primary-bg);
    color: white;
    border: none;
    padding: 12px 18px; /* Increased padding */
    border-radius: 8px; /* Nicely rounded */
    cursor: pointer;
    font-size: .9rem; /* Standard font size */
    font-weight: 500;
    transition: background-color 0.3s ease, transform 0.1s ease, box-shadow 0.2s ease;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Standard shadow */
}

.controls-grid button i,
.action-row button i,
.output-actions button i {
    font-size: 1.1em; /* Slightly larger icon */
}

.controls-grid button:hover,
.action-row button:hover,
.output-actions button:hover {
    background-color: var(--btn-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15); /* More prominent shadow on hover */
}

.controls-grid button:active,
.action-row button:active,
.output-actions button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Specific button colors */
#clearBtn {
    background-color: var(--btn-danger-bg);
    box-shadow: 0 4px 8px rgba(229, 115, 115, 0.2);
}
#clearBtn:hover {
    background-color: var(--btn-danger-hover);
    box-shadow: 0 6px 15px rgba(229, 115, 115, 0.3);
}

.output-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px; /* Larger gap */
    margin-top: 25px; /* More space from output area */
    flex-shrink: 0;
}
.output-actions button {
    padding: 14px 20px; /* Even larger padding */
    border-radius: 10px;
    font-size: .9rem; /* Slightly larger font */
    font-weight: 600;
}

#copyBtn, #downloadTxtBtn {
    background-color: #007bff; /* Primary blue for key actions */
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.2);
}
#copyBtn:hover, #downloadTxtBtn:hover {
    background-color: #0056b3;
    box-shadow: 0 6px 12px rgba(0, 123, 255, 0.3);
}
.dark-mode #copyBtn, .dark-mode #downloadTxtBtn {
    background-color: #61affe;
    box-shadow: 0 4px 8px rgba(97, 175, 254, 0.2);
}
.dark-mode #copyBtn:hover, .dark-mode #downloadTxtBtn:hover {
    background-color: #4a90e2;
    box-shadow: 0 6px 12px rgba(97, 175, 254, 0.3);
}

#undoBtn, #redoBtn {
    background-color: var(--btn-secondary-bg);
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.2);
}
#undoBtn:hover, #redoBtn:hover {
    background-color: var(--btn-secondary-hover);
    box-shadow: 0 6px 12px rgba(108, 117, 125, 0.3);
}
#undoBtn:disabled, #redoBtn:disabled {
    background-color: #e0e0e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
    color: #999;
}
.dark-mode #undoBtn:disabled, .dark-mode #redoBtn:disabled {
    background-color: #666;
    color: #999;
}

.action-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.action-row label {
    white-space: nowrap;
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.98rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.action-row label i {
    color: var(--btn-primary-bg);
    opacity: 0.7;
}

.action-row input[type="text"],
.action-row input[type="number"] {
    flex-grow: 1;
    padding: 10px 12px; /* Increased padding */
    border: 1px solid var(--input-border);
    border-radius: 8px; /* More rounded */
    font-size: 0.9rem;
    min-width: 80px;
    background-color: var(--input-bg);
    color: var(--text-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.2s ease;
    outline: none;
    font-family: 'Inter', sans-serif;
}
.action-row input[type="text"]:focus,
.action-row input[type="number"]:focus {
    border-color: var(--btn-primary-bg);
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.2);
}
.action-row button {
    padding: 10px 15px; /* Slightly smaller padding for inline buttons */
    font-size: 0.95rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}


.input-column .column-header,
.output-column .column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-shrink: 0;
    padding-bottom: 5px; /* Small padding below header */
}

.input-column .column-header h2,
.output-column .column-header h2 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.5rem; /* Larger heading */
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.input-column .column-header h2 i,
.output-column .column-header h2 i {
    color: var(--btn-primary-bg);
    font-size: 1em;
}

.fullscreen-btn {
    background: none;
    border: none;
    color: var(--btn-secondary-bg);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: color 0.2s ease, background-color 0.2s ease;
}
.fullscreen-btn:hover {
    color: var(--btn-primary-hover);
    background-color: rgba(74, 144, 226, 0.1);
}

/* Focus Mode Overlay */
.focus-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--focus-overlay-color);
    z-index: 999;
    display: none;
    transition: background-color 0.3s ease;
}
body.focus-mode .focus-overlay {
    display: block;
}
body.focus-mode .container {
    z-index: 1000;
}
body.focus-mode .input-column,
body.focus-mode #inputText,
body.focus-mode #outputResultContainer {
    z-index: 1001;
    position: relative;
}
body.focus-mode .controls-column {
    opacity: 0.15; /* Dim other columns */
    pointer-events: none;
    transition: opacity 0.3s ease;
}
body.focus-mode .input-column.fullscreen-mode,
body.focus-mode .output-column.fullscreen-mode {
     opacity: 1 !important;
     pointer-events: auto !important;
}

body.focus-mode .top-bar {
     opacity: 1;
     pointer-events: auto;
     z-index: 1001;
     position: relative;
}
body.focus-mode .input-column textarea,
body.focus-mode .output-column textarea,
body.focus-mode .input-column .editable-content,
body.focus-mode .output-column .editable-content {
    opacity: 1;
}
body.focus-mode .input-section,
body.focus-mode .output-section {
    background: none;
    box-shadow: none;
}

/* --- Fullscreen Mode for Columns --- */
body.fullscreen-active {
    overflow: hidden; /* Giữ lại hidden khi ở chế độ toàn màn hình */
}
.main-content-grid.fullscreen-active .input-column:not(.fullscreen-mode),
.main-content-grid.fullscreen-active .output-column:not(.fullscreen-mode),
.main-content-grid.fullscreen-active .controls-column {
    opacity: 0 !important;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.main-content-grid.fullscreen-active .top-bar {
    opacity: 0.1;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.input-column.fullscreen-mode,
.output-column.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--container-bg);
    z-index: 1005;
    padding: 30px; /* More padding when fullscreen */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-radius: 0;
    transition: all 0.3s ease;
    overflow-y: auto;
}

.input-column.fullscreen-mode textarea,
.output-column.fullscreen-mode textarea,
.input-column.fullscreen-mode .editable-content,
.output-column.fullscreen-mode .editable-content {
    min-height: calc(100vh - 150px); /* Adjust textarea height to fill fullscreen */
    height: auto;
}
.input-column.fullscreen-mode .stats,
.output-column.fullscreen-mode .output-actions {
    flex-shrink: 0;
}
.input-column.fullscreen-mode .column-header,
.output-column.fullscreen-mode .column-header {
     margin-bottom: 0;
     padding-bottom: 15px;
     border-bottom: 1px solid var(--border-color);
}

/* --- Highlighting Styles --- */
.highlight-keyword {
    background-color: var(--highlight-bg);
    padding: 1px 3px;
    border-radius: 4px;
    font-weight: 600;
    color: var(--text-color);
    box-shadow: 0 0 0 1px var(--highlight-border); /* Subtle border */
}


/* Toast Notification */
.toast-notification {
    visibility: hidden;
    min-width: 280px;
    background-color: var(--toast-bg);
    color: var(--toast-text);
    text-align: center;
    border-radius: 10px;
    padding: 18px 25px;
    position: fixed;
    z-index: 1002;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    opacity: 0;
    transition: opacity 0.4s ease, visibility 0.4s ease, bottom 0.4s ease;
    font-size: 1.05rem;
    font-weight: 500;
}
.toast-notification.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px; /* Slide up effect */
}

/* Loading Indicator */
#loadingIndicator {
    opacity: 0; /* Mặc định trong suốt */
    visibility: hidden; /* Mặc định không thể tương tác và không chiếm không gian */
    pointer-events: none; /* Mặc định không bắt sự kiện click */

    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1003;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border-radius: 10px;
    color: white;
    font-size: 1.1rem;
    display: flex; /* Giữ display: flex để định dạng bên trong */
    align-items: center;
    gap: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transition: opacity 0.3s ease, visibility 0.3s ease; /* Thêm transition */
}

#loadingIndicator.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Cho phép tương tác khi hiển thị */
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--loading-spinner-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Custom Scrollbar Styles (for WebKit browsers) */
::-webkit-scrollbar {
    width: 10px; /* Wider scrollbar */
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--scroll-track);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--btn-primary-hover);
}


/* Responsive Design */
@media (max-width: 1280px) {
    .main-content-grid {
        grid-template-columns: 260px 1fr 1fr;
        gap: 20px;
    }
    .container {
        padding: 20px 25px;
    }
    .app-header h2 {
        font-size: 1.8rem;
    }
    .app-header h1 {
        font-size: 1.1rem;
    }
    .controls-group {
        padding: 18px;
    }
    h3 {
        font-size: 1.15rem;
    }
    .controls-grid button, .action-row button, .output-actions button {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    .output-actions {
        gap: 12px;
    }
}

@media (max-width: 1024px) {
    .main-content-grid {
        grid-template-columns: 1fr 1fr; /* 2 columns: controls + (input & output stacked) */
        gap: 20px;
    }
    .input-column {
        grid-column: 2;
    }
    .output-column {
        grid-column: 2;
    }
    .controls-column {
        grid-row: 1 / span 2;
    }
    .container {
        padding: 20px;
        gap: 20px;
    }
    .app-header h2 {
        font-size: 1.6rem;
    }
    .app-header h1 {
        font-size: 1rem;
    }
    .stats p {
        margin: 5px 6px;
        font-size: 0.9em;
    }
    .output-actions {
        grid-template-columns: repeat(2, 1fr); /* 2 buttons per row on medium screens */
    }
}

@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    .container {
        height: auto; /* Cho phép container tự co giãn theo nội dung */
        min-height: calc(100vh - 30px); /* Đảm bảo nó vẫn đủ cao */
        padding: 15px;
        gap: 15px;
        overflow-y: auto; /* Cho phép container cuộn trên mobile nếu nội dung quá dài */
    }
    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding-bottom: 12px;
    }
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .app-header h1 {
        border-left: none;
        padding-left: 0;
    }
    .top-bar-controls {
        justify-content: flex-start;
        width: 100%;
        gap: 15px;
    }
    .main-content-grid {
        grid-template-columns: 1fr; /* Single column layout for smaller screens */
        height: auto; /* Trên mobile, grid có thể tự co giãn theo nội dung */
    }
    .controls-column, .input-column, .output-column {
        grid-column: 1;
        height: auto; /* Cho phép tự co giãn */
        flex-shrink: 0;
    }
    .controls-column {
        max-height: 450px; /* Limit height of controls in stacked mode */
        overflow-y: auto;
        padding-right: 5px;
    }
    textarea, .editable-content {
        min-height: 200px;
        padding: 15px;
    }
    .output-actions {
        grid-template-columns: 1fr; /* Stack buttons on small screens */
        gap: 10px;
    }
    .input-column.fullscreen-mode,
    .output-column.fullscreen-mode {
         padding: 20px;
    }
    .input-column.fullscreen-mode textarea,
    .input-column.fullscreen-mode .editable-content,
    .output-column.fullscreen-mode textarea,
    .output-column.fullscreen-mode .editable-content {
        min-height: calc(100vh - 130px);
    }
    /* Thêm vào style.css */
.editable-content[contenteditable="true"] {
    min-height: 200px; /* Hoặc chiều cao phù hợp */
    border: 1px solid var(--textarea-border);
    padding: 15px;
    font-size: var(--default-font-size); /* Sử dụng biến CSS cho kích thước chữ */
    line-height: 1.6;
    outline: none;
    resize: vertical; /* Cho phép thay đổi kích thước theo chiều dọc */
    overflow-y: auto;
    border-radius: 8px;
    background-color: var(--textarea-bg);
    color: var(--text-color);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    white-space: pre-wrap; /* Quan trọng để giữ ngắt dòng khi dán */
    word-wrap: break-word; /* Ngắt từ dài */
}

/* Điều chỉnh khi focus */
.editable-content[contenteditable="true"]:focus {
    border-color: var(--btn-primary-bg);
    box-shadow: 0 0 0 0.2rem rgba(74, 144, 226, 0.25);
}
    h3 {
        font-size: 1.1rem;
        padding-bottom: 10px;
        margin-bottom: 12px;
    }
    .controls-group {
        padding: 15px;
    }
    .controls-grid button {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    .action-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .action-row input, .action-row button {
        width: 100%;
    }
    .action-row label {
        width: 100%;
    }
    .stats p {
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    .container {
        padding: 10px;
        height: auto; /* Đã chỉnh sửa */
        min-height: calc(100vh - 20px); /* Đảm bảo nó vẫn đủ cao */
    }
    .app-header h2 {
        font-size: 1.5rem;
    }
    .app-header h1 {
        font-size: 0.9rem;
    }
    .controls-column {
        max-height: 350px;
    }
    .output-actions button {
        font-size: 0.95rem;
        padding: 12px 15px;
    }
    .toast-notification {
        min-width: unset;
        width: calc(100% - 40px);
        left: 20px;
        transform: translateX(0);
        bottom: 20px;
        font-size: 0.95rem;
    }
}

/* Đảm bảo vùng hiển thị HTML giữ đúng ngắt dòng và định dạng */
.editable-content {
    white-space: pre-wrap;
    word-wrap: break-word;
}
