/* Custom CSS cho cấu trúc tổng thể */
body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Đảm bảo body đủ cao để footer cố định */
    background-color: #f0f2f5; /* Light gray background */
    color: #333;
}

/* =================================================================== */
/* --- Header Style --- */
/* =================================================================== */
.app-header {
    background-color: #ffffff;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: sticky; /* Cố định header khi cuộn */
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px; /* Giới hạn chiều rộng nội dung header */
    margin: 0 auto;
}

/* header menu dropdown */
.header-dropdown-menu {
    position: absolute;
    top: 60px; /* Adjust based on header height */
    right: 1.5rem; /* Align with user-area or menu-toggle */
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 180px;
    z-index: 1010;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out, visibility 0.2s;
}

.header-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.header-dropdown-menu ul {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
}

.header-dropdown-menu li {
    padding: 0 1rem;
}

.header-dropdown-menu a {
    display: block;
    padding: 0.75rem 0;
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    transition: background-color 0.15s, color 0.15s;
}

.header-dropdown-menu a:hover {
    background-color: #f0f2f5;
    color: #007bff;
    border-radius: 0.3rem; /* Small border-radius for hover effect */
}

.header-dropdown-menu li.separator {
    border-top: 1px solid #eee;
    margin: 0.5rem 0;
    padding: 0;
}

/* Responsive adjustment for menu toggle */
@media (max-width: 768px) {
    .menu-toggle {
        display: block; /* Show menu toggle on mobile */
    }
    .header-dropdown-menu {
        right: 1rem; /* Adjust position on smaller screens */
        top: 65px; /* Adjust based on new header height/layout on mobile */
    }
    .header-content {
        position: relative; /* Ensure dropdown positions correctly relative to header */
    }
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-input {
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    border-radius: 0.5rem;
    width: 250px;
    font-size: 0.9rem;
}

.filter-btn {
    background-color: #007bff;
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.filter-btn:hover {
    background-color: #0056b3;
}

.filter-category-btn {
    background-color: #f0f2f5;
    color: #333;
    padding: 0.4rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.filter-category-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

#header-username-display {
    font-weight: 500;
    color: #555;
}

.btn-logout {
    background-color: #dc3545;
    color: white;
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-logout:hover {
    background-color: #c82333;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none; /* Hidden by default on desktop */
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
}

/* =================================================================== */
/* --- Main Content Layout --- */
/* =================================================================== */
.main-content {
    flex-grow: 1;
    padding: auto;
    margin: auto;
    width: calc(100% - var(--sidebar-width-desktop));
    transition: margin-left 0.3s ease-in-out;
    padding-top: calc(var(--header-height) + 20px);
    padding-bottom: var(--footer-height);
}

/* Sửa đổi để hiệu ứng transition hoạt động */
.main-section {
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
    position: relative; /* Dùng relative để tab-pane nằm trong luồng */
    height: 100%;
}
.main-section.active {
    display: block;
    opacity: 1;
    visibility: visible;
}

/* --- Cải thiện CSS cho Tab Buttons và Tab Panes --- */
.tab-buttons {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem; /* Tăng khoảng cách dưới */
    padding: 0 10px;
    background-color: #fff; /* Nền trắng cho thanh tab */
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* Thêm đổ bóng nhẹ */
}

.tab-buttons::-webkit-scrollbar {
    display: none; /* Dành cho Chrome, Safari và Opera */
}

/* Tối ưu hóa các nút tab */
.tab-button {
    flex-shrink: 0;
    padding: 14px 20px; /* Tăng padding để nút lớn hơn */
    margin-right: 15px;
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600; /* Tăng độ đậm của chữ */
    color: var(--secondary-color);
    position: relative;
    transition: color 0.3s ease;
}

.tab-button:hover:not(.active) {
    color: var(--primary-color);
    background-color: #f1f3f5; /* Thêm hiệu ứng hover nhẹ */
}

/* Đảm bảo hiệu ứng chỉ hiển thị trên nút tab */
.tab-button::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 3px; /* Tăng độ dày của đường gạch chân */
    background-color: transparent;
    transition: background-color 0.3s ease;
}

.tab-button.active {
    color: var(--primary-color);
}
.tab-button.active::after {
    background-color: var(--primary-color);
}

/* Tối ưu hóa Tab Panes: Đơn giản, đáng tin cậy */
.tab-pane {
    display: none;
    padding: 1.5rem; /* Tăng padding nội dung tab */
    background-color: var(--background-color);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tab-pane.active {
    display: block;
}

/* Home Page Specifics */
.home-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: transform 0.2s ease-in-out;
}

.summary-card:hover {
    transform: translateY(-5px);
}

.card-icon {
    font-size: 3rem;
    color: #007bff;
    margin-bottom: 1rem;
}

.summary-card h3 {
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
    color: #333;
}

.summary-card p {
    font-size: 0.95rem;
    color: #666;
    margin-bottom: 1.25rem;
}

.news-feed {
    margin-top: 2rem;
    border-top: 1px solid #eee;
    padding-top: 1.5rem;
}

.news-item {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.news-item h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.news-item p {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.5rem;
}

.news-item span {
    font-size: 0.8rem;
    color: #999;
}

.chart-container {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* =================================================================== */
/* Form - Link - Btn Style */
/* =================================================================== */
/* Forms */
.form-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    background-color: #fefefe;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ccc;
    border-radius: 0.4rem;
    box-sizing: border-box; /* Đảm bảo padding không làm tăng width */
    font-size: 1rem;
}

.primary-btn {
    background-color: #007bff;
    color: white;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: #0056b3;
}

.links-container {
    margin-top: 1rem;
    text-align: center;
}

.links-container a {
    color: #007bff;
    text-decoration: none;
}

.links-container a:hover {
    text-decoration: underline;
}

/* Profile Section */
.profile-info {
    padding: 1rem;
}

.profile-info h3 {
    margin-bottom: 1rem;
    color: #333;
}

.profile-info p {
    margin-bottom: 0.5rem;
}

.profile-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.profile-option-btn {
    background-color: #6c757d;
    color: white;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.profile-option-btn:hover {
    background-color: #5a6268;
}

.btn-danger {
    background-color: #dc3545;
}
.btn-danger:hover {
    background-color: #c82333;
}

/* Wallet List */
.wallet-item {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Cho phép wrap trên mobile */
    gap: 10px;
}

.wallet-item p {
    margin: 0;
}

.wallet-actions .btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    border-radius: 0.3rem;
}

/* Alerts */
.alert-container {
    position: fixed;
    top: 70px; /* Dưới header */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    opacity: 1;
    transition: opacity 0.3s ease-out;
}

/* =================================================================== */
/* Footer Style */
/* =================================================================== */
.footer {
    background-color: #ffffff;
    border-top: 1px solid #e0e0e0;
    padding: 0.8rem 0;
    position: fixed; /* Thay đổi từ sticky thành fixed */
    bottom: 0;
    width: 100%;
    z-index: 999;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
}

.footer-navbar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: space-around; /* Đảm bảo các nút cách đều */
    align-items: center;
}

.footer-navbar li {
    flex-grow: 1; /* Cho phép các mục co giãn đều */
    text-align: center;
}

.footer-navbar .btn {
    background-color: transparent;
    border: none;
    color: #555;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: color 0.2s;
    font-weight: 500;
    width: 100%; /* Quan trọng: Đảm bảo button chiếm toàn bộ chiều rộng của li */
}

.footer-navbar .btn:hover,
.footer-navbar .btn.active {
    color: #007bff;
}

.footer-navbar .btn i {
    font-size: 1.2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }

    .app-logo {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .filter-bar {
        order: 3; /* Đặt thanh lọc xuống dưới cùng trong header */
        width: 100%;
        justify-content: center;
    }

    .filter-input {
        width: 100%;
        max-width: 300px; /* Giới hạn chiều rộng trên mobile */
    }

    .user-area {
        position: absolute; /* Đặt user area ra khỏi flow chính */
        top: 10px;
        right: 15px;
        gap: 5px;
    }

    #header-username-display,
    #header-logout-btn {
        font-size: 0.8rem; /* Nhỏ hơn trên mobile */
    }

    .menu-toggle {
        display: block; /* Hiện thị nút menu toggle trên mobile */
        order: 2; /* Đảm bảo nút toggle nằm ở vị trí hợp lý */
    }

    /* Footer trên mobile - vẫn cố định nhưng có thể có thêm hiệu ứng trượt hoặc tùy chỉnh */
    .footer-navbar {
        /* Có thể giữ nguyên `fixed` hoặc thay đổi hành vi tùy thích */
        /* Nếu muốn slide-up/down, bạn sẽ cần JS để toggle class `active` và CSS `transform` */
        transform: translateY(0); /* Đảm bảo luôn hiển thị trên mobile */
        /* Nếu muốn nó trượt lên từ dưới khi click menu-toggle, cần bỏ dòng trên */
        /* và thêm: transition: transform 0.3s ease-out; */
        /* và trong JS, toggle class .active với transform: translateY(0) và translateY(100%) */
    }

    .footer-navbar ul {
        flex-direction: row; /* Giữ các nút điều hướng ngang hàng */
        justify-content: space-around; /* Co giãn đều */
        padding-bottom: env(safe-area-inset-bottom); /* Xử lý notch điện thoại */
    }

    .footer-navbar li {
        width: auto; /* Để li co giãn theo nội dung button */
        border-bottom: none; 
    }
    
    .footer-navbar .btn {
        width: auto; /* Để button co giãn theo nội dung */
        padding: 0.6rem 0.5rem; /* Giảm padding trên mobile */
        flex-direction: column; /* Icon và text dọc hàng trên mobile */
        gap: 3px; /* Giảm khoảng cách */
        font-size: 0.8rem; /* Giảm kích thước chữ */
    }
    .footer-navbar .btn i {
        font-size: 1.1rem; /* Giảm kích thước icon */
    }

    /* Đảm bảo main content có đủ padding để không bị che bởi footer */
    body {
        padding-bottom: 70px; /* Điều chỉnh dựa trên chiều cao thực tế của footer trên mobile */
    }
    .main-content {
        padding: 1rem;
    }

    .account-container {
        flex-direction: column;
    }

    .menu-sidebar {
        flex: none;
        width: 100%;
    }

    .subtab-content-area {
        padding: 1rem;
    }

    .profile-actions {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .home-summary-grid {
        grid-template-columns: 1fr; /* Một cột trên mobile */
    }
}

/* Initial display for home-page or the default tab */
#home-page {
    display: block; /* Mặc định hiển thị trang chủ */
}