/* =========================================
   STYLE.CSS (ĐÃ CẬP NHẬT GREEN THEME)
   Chỉ chứa các kiểu dùng chung trên toàn trang
   ========================================= */

/* CSS cho ePortfolio VÀ Theme - Tô màu theo Cảnh báo */
/* (Phần này được di chuyển vào theme.css vì nó chỉ dùng ở đó) */

/* CSS cho thông báo lỗi nội tuyến (Dùng chung) */
.error-text {
    color: var(--color-danger);
    font-size: 0.9em;
    font-weight: 500;
    display: block;
    margin-top: 5px;
}

/* Badge trạng thái chung (Dùng trong Admin & Profile) */
.status-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: none;
    display: inline-block;
}

.status-active {
    background-color: rgba(var(--success-rgb), 0.15);
    color: var(--color-success);
}

.status-suspended {
    background-color: rgba(var(--danger-rgb), 0.15);
    color: var(--color-danger);
}

/* =========================================
   BỔ SUNG TINH CHỈNH DARK MODE (V2) CHUNG
   ========================================= */

/* YÊU CẦU 2: Chữ "Trên vùng mua" (Đã sửa) */
/* (Phần này được di chuyển vào theme.css) */

/* =========================================
   BỔ SUNG: CSS CHO NÚT GẠT SÁNG/TỐI (SIDEBAR)
   ========================================= */

/* 1. Tạo kiểu cho mục <li> chứa nút gạt */
.sidebar-theme-toggle {
    display: flex;
    justify-content: space-between;
    /* Đẩy chữ và nút gạt ra 2 bên */
    align-items: center;
    padding: 10px 16px;
    /* Giống padding của các mục menu khác */
    margin: 10px 0;
    /* Tạo khoảng cách ở cuối sidebar */
    cursor: default;
    /* Không phải là link nữa */
}

/* 2. Phần bao ngoài của nút gạt (label) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    /* Kích thước nút gạt */
    height: 24px;
    /* Kích thước nút gạt */
}

/* 3. Ẩn checkbox HTML gốc */
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* 4. Tạo kiểu cho thanh trượt (slider) - nền */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    /* Màu nền khi tắt (light mode) */
    transition: .4s;
    border-radius: 24px;
    /* Bo tròn */
}

/* 5. Tạo kiểu cho nút tròn bên trong */
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    /* Kích thước nút tròn */
    width: 18px;
    /* Kích thước nút tròn */
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    /* Bo tròn tuyệt đối */
}

/* 6. Thay đổi màu nền khi NÚT GẠT ĐƯỢC BẬT (checked) */
input:checked+.slider {
    background-color: var(--primary-color);
}

/* 7. Di chuyển nút tròn khi NÚT GẠT ĐƯỢC BẬT (checked) */
input:checked+.slider:before {
    transform: translateX(20px);
    /* Di chuyển sang phải */
}

/* =========================================
   FIX TOÀN CỤC: MÀU TIÊU ĐỀ CHO DARK MODE
   ========================================= */

/* 1. Đặt màu mặc định (Light Mode) cho các lớp tiêu đề */
.title-primary,
.title-secondary {
    color: var(--primary-color);
}

/* 2. Tự động đổi sang màu trắng khi ở Giao diện tối */
html.dark-mode .title-primary,
html.dark-mode .title-secondary {
    color: var(--text-color-dark);
    /* Sử dụng biến màu chữ của Giao diện tối */
}

/* =========================================
   STYLE CHO NÚT ĐĂNG NHẬP (NAVBAR)
   Phong cách: Clean & Flat Outline (Green Theme)
   ========================================= */

/* 1. Định dạng cơ bản cho nút */
.navbar-user .btn-login {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    /* Kích thước vừa vặn */
    font-size: 14px;
    font-weight: 600;
    /* Chữ đậm vừa phải */
    text-decoration: none;
    /* Bỏ gạch chân */

    /* [ĐÃ SỬA] Màu sắc mặc định (Light Mode) - Green */
    color: var(--primary-color);
    background-color: transparent;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    /* Bo góc nhẹ 4px */

    transition: all 0.2s ease-in-out;
    /* Hiệu ứng mượt mà */
    white-space: nowrap;
    /* Không xuống dòng */
}

/* 2. Hiệu ứng khi di chuột (Hover) */
.navbar-user .btn-login:hover {
    background-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

/* 3. Tương thích Dark Mode (Giao diện tối) */
html.dark-mode .navbar-user .btn-login {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

html.dark-mode .navbar-user .btn-login:hover {
    background-color: var(--primary-color);
    color: #121212;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* =========================================
   FIX GLOBAL MOBILE LAYOUT (CHỐNG TRÀN TOÀN TRANG)
   ========================================= */
@media (max-width: 768px) {

    /* 1. Kìm hãm toàn bộ trang web không cho cuộn ngang */
    html,
    body {
        max-width: 100vw;
        /* Chiều rộng tối đa bằng màn hình */
        overflow-x: hidden !important;
        /* Chống tràn ngang */
    }

    /* 2. Reset khung bao ngoài cùng */
    .app-layout {
        display: block !important;
        /* Đảm bảo không dính Flexbox gây giãn */
        width: 100% !important;
    }

    /* 3. Reset Sidebar & Content Wrapper */
    /* Đảm bảo phần nội dung chính không bị Sidebar đẩy sang phải */
    .main-content-wrapper {
        width: 100% !important;
        margin-left: 0 !important;
        /* Loại bỏ margin dành cho sidebar (nếu có) */
        padding-left: 0 !important;
        padding-right: 0 !important;
        box-sizing: border-box !important;
    }

    /* 4. Reset Container chứa nội dung */
    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 15px !important;
        /* Padding chuẩn mobile */
        padding-right: 15px !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
}

/* --- GLOBAL HEADER STYLES (Đã tách từ Portfolio) --- */

/* Wrapper căn chỉnh */
.header-custom-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
    /* Tạo khoảng cách dưới mặc định */
}

/* Tiêu đề chính */
.page-title {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 10px;
}

/* Dòng mô tả */
.page-desc {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary, #666);
    margin-top: -5px;
}

/* Dark Mode Support cho Header */
html.dark-mode .page-title {
    color: #ffffff;
}

html.dark-mode .page-desc {
    color: var(--text-secondary, #aaa);
}

/* =========================================
   GLOBAL COMPONENT: CIRCLE ADD BUTTON
   (Standardized across Admin, Portfolio, Journal)
   ========================================= */
.btn-circle-add {
    width: var(--btn-height);
    height: var(--btn-height);
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, background-color 0.2s;
    min-width: var(--btn-height);
}

.btn-circle-add:hover {
    transform: scale(1.1);
    background-color: var(--primary-color-hover);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
}

.btn-circle-add .material-symbols-outlined,
.btn-circle-add .material-icons {
    font-size: 24px;
}

/* =========================================
   GLOBAL COMPONENT: CIRCLE SECONDARY BUTTON
   (Used for Reset/Refresh actions)
   ========================================= */
.btn-circle-secondary {
    width: var(--btn-height);
    height: var(--btn-height);
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    color: var(--text-secondary, #666);
    border: 1px solid var(--border-color, #ccc);
    cursor: pointer;
    transition: all 0.2s;
    min-width: var(--btn-height);
}

.btn-circle-secondary:hover {
    background-color: var(--background-hover, #f0f0f0);
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: rotate(180deg);
    /* Nice effect for refresh */
}

.btn-circle-secondary .material-symbols-outlined,
.btn-circle-secondary .material-icons {
    font-size: 20px;
}

/* =========================================
   GLOBAL COMPONENT: CIRCLE PRIMARY BUTTON
   (Generic primary circle button, alias for add)
   ========================================= */
.btn-circle-primary {
    width: var(--btn-height);
    height: var(--btn-height);
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, background-color 0.2s;
    min-width: var(--btn-height);
}

.btn-circle-primary:hover {
    transform: scale(1.1);
    background-color: var(--primary-color-hover);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
}

.btn-circle-primary .material-symbols-outlined,
.btn-circle-primary .material-icons {
    font-size: 20px;
}

/* =========================================
   GLOBAL COMPONENT: CLEAN TABLE
   (Standardized Table Style)
   ========================================= */
.table-clean {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    color: var(--text-primary, #333);
}

/* =========================================
   GLOBAL COMPONENT: UNIFIED TABLE SYSTEM (.mh-table)
   Baseline: Bot Transactions Design
   ========================================= */
/* Aliases for legacy compatibility - Applying .mh-table styles via selector grouping */
.mh-table,
.table-clean,
.table-custom,
.db-mini-table,
.table-schedule,
.backup-table,
.cron-table,
.compare-table,
.table-repayment,
#portfolio-table,
#logs-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    font-size: 14.5px;
}

.mh-table thead tr,
.table-clean thead tr,
.table-custom thead tr,
.db-mini-table thead tr,
.table-schedule thead tr,
.backup-table thead tr,
.cron-table thead tr,
.compare-table thead tr,
.table-repayment thead tr,
#portfolio-table thead tr,
#logs-table thead tr {
    background-color: var(--bg-header);
    border-bottom: 2px solid var(--border-color, #eee);
}

html.dark-mode .mh-table thead tr,
html.dark-mode .table-clean thead tr,
html.dark-mode .table-custom thead tr,
html.dark-mode .db-mini-table thead tr,
html.dark-mode .table-schedule thead tr,
html.dark-mode .backup-table thead tr,
html.dark-mode .cron-table thead tr,
html.dark-mode .compare-table thead tr,
html.dark-mode .table-repayment thead tr,
html.dark-mode #portfolio-table thead tr,
html.dark-mode #logs-table thead tr {
    background-color: rgba(255, 255, 255, 0.03);
    border-bottom: 2px solid rgba(255, 255, 255, 0.05);
}

.mh-table th,
.table-clean th,
.table-custom th,
.db-mini-table th,
.table-schedule th,
.backup-table th,
.cron-table th,
.compare-table th,
.table-repayment th,
#portfolio-table th,
#logs-table th {
    padding: 12px 15px;
    font-weight: 600 !important;
    font-size: 13px !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-color-dark) !important;
    text-align: center;
    white-space: nowrap;
}

.mh-table td,
.table-clean td,
.table-custom td,
.db-mini-table td,
.table-schedule td,
.backup-table td,
.cron-table td,
.compare-table td,
.table-repayment td,
#portfolio-table td,
#logs-table td {
    padding: 12px 15px;
    font-size: 14.5px !important;
    color: var(--text-color-normal);
    text-align: center;
    border-bottom: 1px solid var(--border-color, #eee);
    vertical-align: middle;
}

html.dark-mode .mh-table td,
html.dark-mode .table-clean td,
html.dark-mode .table-custom td,
html.dark-mode .db-mini-table td,
html.dark-mode .table-schedule td,
html.dark-mode .backup-table td,
html.dark-mode .cron-table td,
html.dark-mode .compare-table td,
html.dark-mode .table-repayment td,
html.dark-mode #portfolio-table td,
html.dark-mode #logs-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.mh-table tbody tr:nth-child(even),
.table-clean tbody tr:nth-child(even),
.table-custom tbody tr:nth-child(even),
.db-mini-table tbody tr:nth-child(even),
.table-schedule tbody tr:nth-child(even),
.backup-table tbody tr:nth-child(even),
.cron-table tbody tr:nth-child(even),
.compare-table tbody tr:nth-child(even),
.table-repayment tbody tr:nth-child(even),
#portfolio-table tbody tr:nth-child(even),
#logs-table tbody tr:nth-child(even) {
    background-color: var(--table-stripe-even);
}

.mh-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

html.dark-mode .mh-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Aliases for legacy compatibility */

/* Size Utility */
.mh-table-mini th {
    padding: 8px 10px;
    font-size: 12px;
}

.mh-table-mini td {
    padding: 8px 10px;
    font-size: 13.5px;
}

/* Alignment Utility (Global) */
.mh-table .text-start {
    text-align: left !important;
}

.mh-table .text-center {
    text-align: center !important;
}

.mh-table .text-end {
    text-align: right !important;
}

html.dark-mode .mh-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Alignment Utilities */
.text-start {
    text-align: left !important;
}

.text-center {
    text-align: center !important;
}

.text-end {
    text-align: right !important;
}

/* Mini Table Modifier (for cards/widgets) */
.mh-table-mini {
    font-size: 13.5px;
}

.mh-table-mini th {
    padding: 8px 10px;
    font-size: 12px;
}

.mh-table-mini td {
    padding: 10px 10px;
}

/* Table Clean Alias */

.table-clean th {
    background: var(--bg-header) !important;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
    padding: 12px 15px;
}

.table-clean td {
    padding: 12px 15px;
}

/* =========================================
   GLOBAL COMPONENT: FLAT INPUTS & CONTROLS
   (Standardized Filter Controls)
   ========================================= */
.flat-input {
    padding: 6px 12px !important;
    border: 1px solid var(--border-color-input) !important;
    border-radius: 10px;
    background-color: var(--bg-input) !important;
    color: var(--text-color-dark);
    font-weight: 500;
    height: var(--input-height);
    outline: none;
    box-sizing: border-box;
    box-shadow: none;
    transition: all 0.3s ease;
}

.flat-select {
    padding: 6px 32px 6px 12px !important;
    border: 1px solid var(--border-color-input) !important;
    border-radius: 10px;
    color: var(--text-color-dark);
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
    transition: all 0.3s ease;
    height: var(--input-height);
    outline: none;
    box-sizing: border-box;

    /* Safari & Chrome Fix */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: var(--bg-input) !important;
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiM2NjY2NjYiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cG9seWxpbmUgcG9pbnRzPSI2IDkgMTIgMTUgMTggOSI+PC9wb2x5bGluZT48L3N2Zz4=") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 16px !important;
}

html.dark-mode .flat-input,
html.dark-mode .flat-select {
    border-color: var(--border-color-input) !important;
}

html.dark-mode .flat-select {
    background-color: var(--bg-input) !important;
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNjY2NjY2MiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cG9seWxpbmUgcG9pbnRzPSI2IDkgMTIgMTUgMTggOSI+PC9wb2x5bGluZT48L3N2Zz4=") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 16px !important;
}


.flat-input:focus,
.flat-select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.15) !important;
}

.filter-bar-container {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .filter-bar-container {
        gap: 10px;
        align-items: stretch;
        /* Stretch items to fill width */
    }

    /* Force Filter Group (Selects) to take full width */
    .filter-bar-container .filter-group {
        flex: 1 1 100% !important;
        min-width: 100%;
        display: flex;
    }

    /* Make selects share width equally */
    .filter-bar-container .filter-group .flat-select,
    .filter-bar-container .filter-group .flat-input {
        flex: 1;
        max-width: none !important;
        /* Allow growing */
    }

    /* Force Toolbar Actions (Buttons) to take full width and new line */
    .filter-bar-container .toolbar-actions {
        flex: 1 1 100%;
        justify-content: flex-end;
        /* Align right or space-between as needed */
        margin-top: 5px;
    }
}

/* --- Mobile Bottom Navigation (Flat & Modern Redesign) --- */
.mobile-bottom-nav {
    display: none;
    /* Hidden by default on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px;
    background-color: var(--bg-content);
    border-top: 1px solid var(--border-color-light);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    z-index: 9999;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    border-radius: 0;
}

html.dark-mode .mobile-bottom-nav {
    background-color: var(--bg-content);
    border-top: 1px solid var(--border-color-light);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
}

.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-color-secondary);
    font-size: 9.5px;
    /* Slightly smaller for 6 items */
    font-weight: 600;
    flex: 1;
    height: 100%;
    transition: all 0.3s ease;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.mobile-bottom-nav .nav-item .material-symbols-outlined {
    font-size: 24px;
    margin-bottom: 2px;
    transition: transform 0.3s ease;
}

.mobile-bottom-nav .nav-item:active {
    transform: scale(0.95);
}

.mobile-bottom-nav .nav-item.active {
    color: var(--primary-color);
}

.mobile-bottom-nav .nav-item.active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 75%;
    background: rgba(var(--primary-rgb), 0.08);
    border-radius: var(--border-radius-global, 10px);
    box-shadow: none;
    z-index: -1;
}

html.dark-mode .mobile-bottom-nav .nav-item.active::after {
    background: rgba(var(--primary-rgb), 0.15);
    box-shadow: none;
}

/* Show on Mobile */
@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
    }

    /* Adjust main content padding to prevent specific content from being hidden behind nav */
    body {
        padding-bottom: 80px;
        /* Tăng padding bottom để ko bị che bởi nút nổi */
    }
}

/* Overlay mờ khi mở menu (Optional) */
.nav-overlay-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
}

.nav-center-container.active .nav-overlay-backdrop {
    display: block;
}

/* =========================================
   GLOBAL TABLE SORTING STYLES
   (Copied from bot-transactions.css for global use)
   ========================================= */
th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 32px !important;
    /* Tăng khoảng cách cho ổn định */
    user-select: none;
    transition: background-color 0.2s;
}

th.sortable:hover {
    background-color: var(--bg-hover) !important;
}

th.sortable::after {
    content: "↕";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.2;
    font-size: 11px;
    font-weight: normal;
}

th.sortable.sorted-asc::after {
    content: "▲";
    opacity: 1;
    color: var(--primary-color);
}

th.sortable.sorted-desc::after {
    content: "▼";
    opacity: 1;
    color: var(--primary-color);
}

/* =========================================
   GLOBAL COMPONENT: TOAST ANIMATIONS
   ========================================= */
@keyframes fadein {
    from {
        bottom: 0;
        opacity: 0;
    }

    to {
        bottom: 20px;
        opacity: 1;
    }
}

@keyframes fadeout {
    from {
        bottom: 20px;
        opacity: 1;
    }

    to {
        bottom: 0;
        opacity: 0;
    }
}