body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: F5f5f5;
}

.long-content {
    padding: 20px;
}

.fb-container {
    max-width: 1200px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    margin: 2rem auto;
    padding: 2rem;
}

.copy-message {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #2ecc71;
    color: white;
    padding: 5px 15px;
    border-radius: 5px;
    z-index: 10;
}

.grid-container {
    display: grid;
    grid-template-columns: 1.5fr 2fr;
    gap: 20px;
    align-items: flex-start;
    max-height: calc(100vh - 120px);
}

.left-column {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: sticky;
    top: 20px;
    height: fit-content;
}

.right-column {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 120px);
}

.content-editable {
    width: 100%;
    min-height: 150px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 18px;
    white-space: pre-wrap;
    word-break: break-word;
    outline: none;
    caret-color: black;
    line-height: 1.5;
}

.content-editable:empty:before {
    content: attr(placeholder);
    color: #888;
}

.textarea-section {
    margin-top: 20px;
}

.copy-history-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.textarea-section button {
    padding: 8px 16px;
    background: #2ecc71;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.textarea-section button:hover {
    background: #27ae60;
}

.history-section {
    display: flex;
    align-items: center;
    gap: 5px;
}

.history-grid {
    display: flex;
    gap: 5px;
}

.history-item {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 33px;
    width: 33px;
    background: #f9f9f9;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}

.history-item:hover {
    background: #e9e9e9;
}

/*.preview-section {
    background: #f9f9f9;
    padding: 10px;
    margin-top: 10px;
    border-radius: 5px;
    min-height: 100px;
    flex-grow: 1;
    overflow-wrap: break-word;
}*/

/*.preview-content {
    word-wrap: break-word;
    white-space: pre-wrap;
}*/

.dark-mode-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    z-index: 10;
}

.dark-mode-btn:hover {
    background: #2980b9;
}

.search-bar {
    padding: 20px 0 10px 0;
    position: sticky;
    top: 0;
    background: white;
    z-index: 5;
}

#search-input {
    width: 100%;
    padding: 10px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
}

.tab-container {
    margin: 10px 0;
}

.tab-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.tab-btn {
    padding: 5px 10px;
    background: #b5b4b4;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.tab-btn:hover {
    background: #e0e0e0;
}

.tab-btn.active {
    background: #3498db;
    color: white;
}

/*.categories-section {
    margin-top: 10px;
}*/

.category-block {
    margin-bottom: 20px;
}

.category-block h3 {
    margin-bottom: 10px;
    font-size: 18px;
    color: #333;
}

.symbols-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(33px, 1fr));
    gap: 5px;
}

.symbol-item {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 33px;
    background: #f0f0f0;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    position: relative;
    transition: background 0.3s;
}

.symbol-item:hover {
    background: #e0e0e0;
}

.symbol-item::after {
    content: attr(data-desc);
    visibility: hidden;
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-bottom: 5px;
    white-space: nowrap;
    font-size: 14px;
    z-index: 1;
}

.symbol-item:hover::after {
    visibility: visible;
}

.emoji-span {
    display: inline-block;
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    vertical-align: middle;
    line-height: 24px;
    text-align: center;
    margin: 1px;
}

.emoji-span.flag-sprite {
    background: url('/assets/images/flags/flags.png');
    background-size: 6120px 24px;
    image-rendering: pixelated;
}

/* Scale background-position cho danh mục cờ */
.symbol-item .emoji-span.flag-sprite {
    background-size: 6120px 24px;
}

/* Đảm bảo cờ trong content-editable, preview, và lịch sử hiển thị đúng */
/*.content-editable .emoji-span.flag-sprite,
.preview-content .emoji-span.flag-sprite,
.history-item .emoji-span.flag-sprite {
    background-size: 6120px 24px;
    transform: scale(1);
}*/

.content-editable .emoji-span.flag-sprite, .emoji-span.flag-sprite,
.history-item .emoji-span.flag-sprite {
    background-size: 6120px 24px;
    transform: scale(1);
}

/* Đảm bảo emoji-span trong preview không chỉnh sửa được */
/*.preview-content .emoji-span.flag-sprite {
    pointer-events: none;
}*/

.emoji-span[style*="background-image"] {
    color: transparent;
    pointer-events: none;
    contenteditable: false;
}

.history-item .emoji-span {
    font-size: 16px;
}

.dark-mode {
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    color: white;
}

.dark-mode .fb-container {
    background: #34495e;
}

.dark-mode .content-editable {
    background: #2c3e50;
    color: white;
    border-color: #3d566e;
}

.dark-mode .search-bar {
    background: #34495e;
}

.dark-mode .symbol-item {
    background: #2c3e50;
}

.dark-mode .symbol-item:hover {
    background: #3d566e;
}

.dark-mode .history-item {
    background: #2c3e50;
}

.dark-mode .history-item:hover {
    background: #3d566e;
}

/*.dark-mode .preview-section {
    background: #2c3e50;
}*/

.dark-mode .category-block h3,
.dark-mode h1,
.dark-mode h2,
.dark-mode h3,
.dark-mode h4,
.dark-mode .left-column h3 {
    color: #ffffff;
}

.dark-mode .tab-btn {
    background: #2c3e50;
}

.dark-mode .tab-btn:hover {
    background: #3d566e;
}

.dark-mode .tab-btn.active {
    background: #3498db;
}

/*.fixed-footer {
    width: 100%;
    background: #1e3c72;
    color: white;
    padding: 0.5rem 0;
    text-align: center;
}*/

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .grid-container {
        grid-template-columns: 1fr;
        max-height: none;
        gap: 20px;
    }

    .left-column {
        position: static;
        height: auto;
    }

    .right-column {
        max-height: none;
        overflow-y: visible;
    }

    .copy-history-container {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .history-grid {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    /* Adjust sticky search bar for mobile */
    .search-bar {
        position: relative;
        top: 0;
    }

    /* Improve touch interaction */
    .symbol-item,
    .tab-btn,
    .textarea-section button,
    .history-item {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Ensure contenteditable is touch-friendly */
    .content-editable {
        -webkit-user-select: text;
        user-select: text;
        touch-action: auto;
    }

    /* Adjust tooltip positioning for mobile */
    .symbol-item::after {
        white-space: normal;
        max-width: 200px;
        left: 50%;
        transform: translateX(-50%);
    }
}

@media (max-width: 480px) {
    .textarea-section {
        margin-top: 0px;
    }
    .fb-container {
        margin: 0.7rem;
        padding: 0.7rem;
    }

    /* Maintain tooltip adjustments */
    .symbol-item::after {
        white-space: normal;
        max-width: 150px;
    }
}