/* --- CSS GIỮ NGUYÊN TỪ BẢN GIAO DIỆN ĐẸP (INDEX_NEW) --- */
:root {
    --primary: #0056b3;
    --bg: #f4f7f6;
    --white: #fff;
    --gray: #888;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* HEADER */
.app-header {
    background: var(--primary);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 10;
    height: 50px;
}

.app-title {
    font-weight: bold;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-status {
    font-size: 12px;
    opacity: 0.9;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* --- MENU NGƯỜI DÙNG (DROPDOWN) --- */
.user-menu {
    position: absolute;
    top: 55px;
    /* Cách mép trên (Header) một chút */
    right: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    display: none;
    /* Mặc định ẩn */
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    min-width: 160px;
    animation: fadeIn 0.2s;
}

.user-menu-item {
    padding: 12px 15px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.user-menu-item:last-child {
    border-bottom: none;
}

.user-menu-item:hover {
    background-color: #f8f9fa;
    color: #0056b3;
}

/* Mũi tên nhỏ chỉ lên trên (trang trí cho đẹp) */
.user-menu::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 15px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    box-shadow: -2px -2px 5px rgba(0, 0, 0, 0.05);
}

/* MAIN CONTENT */
#main-app {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 450px;
    /* Giới hạn chiều rộng trên PC */
    height: 100%;
    max-height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* [MỚI] Nút phóng to chỉ hiện trên PC/Tablet */
.expand-btn {
    cursor: pointer;
    font-size: 18px;
    margin-right: 15px;
    display: none;
}

@media (min-width: 481px) {
    .app-container {
        max-height: 90vh;
        border-radius: 20px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
        transition: all 0.3s ease;
    }

    .expand-btn {
        display: block;
    }

    /* Hiện nút trên màn hình lớn */

    /* Class kích hoạt chế độ toàn màn hình */
    .app-container.fullscreen-mode {
        max-width: 100vw !important;
        max-height: 100vh !important;
        border-radius: 0;
    }
}

/* VIEWS */
.view-section {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
    background: #f8f9fa;
    position: relative;
}

.view-section.active {
    display: flex;
}

/* Chat Area */
.chat-box {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.user-message {
    align-self: flex-end;
    background: #007bff;
    color: white;
    border-bottom-right-radius: 2px;
}

.bot-message {
    align-self: flex-start;
    background: white;
    color: #333;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
}

/* Markdown Style */
.bot-message strong {
    color: #d63384;
    font-weight: 700;
}

.bot-message table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 5px;
    font-size: 12px;
    background: #fff;
}

.bot-message th,
.bot-message td {
    border: 1px solid #ddd;
    padding: 6px;
}

.bot-message th {
    background: #f1f1f1;
}

/* Typing Indicator */
.typing {
    font-size: 11px;
    color: #888;
    margin-left: 20px;
    margin-bottom: 5px;
    font-style: italic;
    height: 15px;
    visibility: hidden;
}

.typing.active {
    visibility: visible;
}

/* Input Area - QUAN TRỌNG: Style cho thẻ DIV thay vì FORM */
.input-area {
    display: flex;
    padding: 10px;
    background: white;
    border-top: 1px solid #eee;
    gap: 8px;
    align-items: center;
}

.input-area input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
}

.send-btn {
    background: #0056b3;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: 0.2s;
}

.send-btn:hover {
    background: #004494;
    transform: scale(1.05);
}

/* [MỚI] Style cho nút đính kèm ảnh */
.attach-btn {
    background: #f0f2f5;
    color: #555;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: 0.2s;
    margin-right: 5px;
}

.attach-btn:hover {
    background: #e4e6eb;
    color: #0056b3;
}

/* Inbox & Tab Bar & Modal (Giữ nguyên) */
.inbox-container {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}

.action-card {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    border-left: 5px solid #0056b3;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #888;
    margin-bottom: 8px;
}

.card-title {
    font-weight: bold;
    font-size: 15px;
    margin-bottom: 5px;
    color: #333;
}

.card-body {
    font-size: 13px;
    color: #555;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.card-actions {
    display: flex;
    gap: 10px;
}

.btn-action {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

.btn-approve {
    background: #e3fcef;
    color: #00a86b;
}

.btn-reject {
    background: #ffebeb;
    color: #e03131;
}

.tab-bar {
    display: flex;
    background: white;
    border-top: 1px solid #eee;
    height: 55px;
    justify-content: center;
}

.tab-item {
    flex: 1;
    max-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 10px;
    cursor: pointer;
    transition: 0.2s;
    position: relative;
}

.tab-item.active {
    color: #0056b3;
    font-weight: bold;
}

.tab-icon {
    font-size: 20px;
    margin-bottom: 2px;
}

.badge {
    position: absolute;
    top: 5px;
    left: 50%;
    margin-left: 10px;
    background: #ff4757;
    color: white;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 10px;
    display: none;
}

/* --- MODAL & POPUP CHUYÊN NGHIỆP --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.show {
    opacity: 1;
}

.modal-content {
    background: white;
    padding: 30px 25px;
    border-radius: 24px;
    width: 85%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.modal.show .modal-content {
    transform: scale(1);
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header-icon {
    font-size: 40px;
    margin-bottom: 15px;
    display: inline-block;
    background: #f0f7ff;
    width: 80px;
    height: 80px;
    line-height: 80px;
    border-radius: 50%;
    color: #0056b3;
}

.modal h3 {
    margin: 0 0 5px 0;
    color: #333;
    font-size: 20px;
}

.modal p.sub-text {
    color: #888;
    font-size: 13px;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 15px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
    margin-left: 5px;
}

.modal input {
    width: 100%;
    padding: 14px;
    border: 1px solid #e1e1e1;
    border-radius: 12px;
    box-sizing: border-box;
    background: #f9f9f9;
    transition: 0.3s;
    font-size: 14px;
}

.modal input:focus {
    border-color: #0056b3;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 86, 179, 0.1);
}

.login-btn {
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    background: linear-gradient(135deg, #0056b3, #004494);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 86, 179, 0.3);
    transition: transform 0.2s;
}

.login-btn:active {
    transform: scale(0.98);
}

.btn-close-modal {
    background: none;
    border: none;
    width: 100%;
    font-size: 13px;
    color: #888;
    cursor: pointer;
    margin-top: 20px;
    padding: 10px;
    border-radius: 8px;
}

.btn-close-modal:hover {
    background: #f5f5f5;
    color: #333;
}

/* PROFILE MENU STYLE */
.profile-info {
    margin-bottom: 20px;
}

.profile-avatar {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #00c6ff, #0072ff);
    color: white;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin: 0 auto 10px;
    box-shadow: 0 5px 15px rgba(0, 114, 255, 0.3);
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.menu-item {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: 0.2s;
    border-radius: 10px;
    color: #333;
    font-size: 14px;
}

.menu-item:hover {
    background: #f8f9fa;
    color: #0056b3;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-icon {
    width: 36px;
    height: 36px;
    background: #f0f2f5;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #555;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px dashed #eee;
    font-size: 13px;
}

/* [MỚI] FILTER BAR STYLE */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: none;
}

.filter-chip {
    padding: 6px 14px;
    background: #eee;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: 0.2s;
    color: #555;
    font-weight: 500;
}

.filter-chip.active {
    background: #e7f1ff;
    color: #0056b3;
    border-color: #0056b3;
    font-weight: bold;
}

/* [MỚI] Style khi bị disable (Chưa đăng nhập) */
.filter-bar.disabled {
    pointer-events: none;
}

.filter-bar.disabled .filter-chip {
    background: #dcdcdc;
    color: #999;
    opacity: 0.8;
}

.filter-bar.disabled .btn-mark-all {
    color: #999;
    opacity: 0.6;
}

/* [MỚI] Style cho tin đã đọc */
.action-card.is-read {
    opacity: 0.6;
    border-left-color: #ccc;
    background: #fdfdfd;
}

.action-card.is-read .card-title {
    color: #777;
    font-weight: normal;
}

.btn-mark-all {
    margin-left: auto;
    cursor: pointer;
    color: #0056b3;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-mark-all:hover {
    text-decoration: underline;
}

.btn-mark-all.disabled {
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
    text-decoration: none;
}

.btn-mark-all.disabled:hover {
    text-decoration: none;
}