@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600&display=swap');

/* =========================================
   1. CORE & UTILS (MENU & DROPDOWN)
   ========================================= */
/* Mặc định ẩn tất cả menu popup */
.mb-popup-menu, .mb-dropdown-menu { 
    display: none; 
    position: absolute; 
    z-index: 99999 !important; /* Luôn nổi trên cùng */
    background: #fff; 
    border-radius: 6px; 
    box-shadow: 0 5px 20px rgba(0,0,0,0.3); 
    padding: 6px 0; 
    text-align: left;
}

/* Chỉ hiện khi có class open/show */
.mb-dropdown-wrap.open .mb-dropdown-menu,
.mb-popup-wrap.show .mb-popup-menu { 
    display: block !important; 
}

/* Item trong menu */
.mb-popup-item, .mb-dropdown-item { 
    display: flex; align-items: center; gap: 10px; padding: 8px 14px; 
    color: #374151; cursor: pointer; font-size: 13px; transition: background 0.2s; line-height: 1.4; 
}
.mb-popup-item:hover, .mb-dropdown-item:hover { background: #f3f4f6; color: #000; }
.mb-popup-item.selected { background: #ecfdf5; color: #047857; }
.mb-popup-divider { height: 1px; background: #e5e7eb; margin: 4px 0; }
.mb-popup-item.remove { color: #dc2626; }
.mb-popup-item.remove:hover { background: #fef2f2; }

/* Icon và Text trong menu */
.mb-p-icon, .mb-icon { font-size: 15px; width: 18px; text-align: center; }
.mb-p-text, .mb-text { flex: 1; font-weight: 500; }
.mb-p-check { color: #059669; font-weight: bold; font-size: 12px; }

/* =========================================
   2. GRID LAYOUT (DANH SÁCH PHIM)
   ========================================= */
.mb-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap:16px; position: relative; min-height: 200px; overflow: visible !important; }
.mb-item { display:flex; gap:12px; background:#131313; padding:10px; border-radius:8px; align-items:stretch; color:#fff; transition:0.25s;border: 1px solid #1e293b; }
.mb-item:hover { box-shadow:0 6px 18px rgba(0,0,0,0.5); }
.mb-thumb { position:relative; flex-shrink:0; overflow:hidden; border-radius:6px; width:140px; height:200px; }
.mb-thumb img { width:100%; height:100%; object-fit:cover; transition:transform .35s ease; display:block; opacity: 0; transition: opacity 0.5s ease-in-out, transform 0.35s ease !important; }
.mb-thumb img.is-loaded { opacity: 1; }
.mb-thumb:hover img { transform:scale(1.08); }
.mb-episode { position:absolute; bottom:8px; left:8px; background:rgba(0,0,0,0.7); color:#fff; padding:4px 6px; border-radius:4px; font-size:12px; }
.mb-info { flex:1; display:flex; flex-direction:column; overflow: visible !important; }
.mb-title { 
    margin:0 0 6px 0; 
    font-size:16px; 
    line-height: 1.4; 
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mb-title a { color:#fff; text-decoration:none; }

.mb-meta { 
    font-size:13px; 
    color:#9aa5b1; 
    display:flex; 
    gap:12px; 
    margin-bottom:8px; 
    margin-top: auto; /* Mấu chốt để đẩy xuống đáy */
}
.mb-actions { margin-top:auto; width: 100%; }
.mb-remove { background:#000; color:#fff; border:none; padding:6px 10px; border-radius:6px; cursor:pointer; width: 100%; margin-top: 5px; }
.mb-remove:hover { background:#ff2f50; }
.mb-controls { display:flex; justify-content:flex-end; gap:12px; margin-bottom:20px; }
#mb-sort { padding:6px 8px; border-radius:6px; background:#111; color:#fff; border:1px solid #222; }
.mb-empty { padding:20px; text-align:center; color:#cbd5e1; grid-column: 1 / -1; }

/* Dropdown Wrapper trong Grid */
.mb-dropdown-wrap { position: relative; display: inline-block; margin-bottom: 8px; width: 100%; z-index: 5; }
.mb-dropdown-trigger { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #242424; border: 1px solid #334155; border-radius: 6px; color: #cbd5e1; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; width: 100%; justify-content: space-between; }
.mb-dropdown-trigger:hover { background: #000; }
.mb-dropdown-trigger.later { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.mb-dropdown-trigger.watching { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.mb-dropdown-trigger.finished { background: #10b981; border-color: #10b981; color: #fff; }
.mb-dropdown-menu { top: 100%; left: 0; width: 100%; background: #0f172a; border: 1px solid #334155; }
.mb-dropdown-item { color: #94a3b8; border-bottom: 1px solid #1e293b; }
.mb-dropdown-item:last-child { border-bottom: none; }
.mb-dropdown-item:hover { background: #1e293b; color: #fff; padding-left: 18px; }

/* =========================================
   3. PLAYER BUTTON (Nút trong thanh Player)
   ========================================= */

/* 1. Căn chỉnh thẻ của theme để các nút thẳng hàng */
.bar_info .list_bar li a.bar_ani4u { 
    display: flex !important; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    height: 100%; 
    vertical-align: middle; 
}

/* 2. Wrapper plugin trong player */
.bar_info .mb-popup-wrap { 
    display: block !important; 
    width: 100%; 
    margin-top: -2px; 
    position: relative !important; 
}

/* 3. Style nút bấm */
.bar_info .mb-popup-trigger { 
    background: transparent !important; 
    border: none !important; 
    padding: 0 !important; 
    width: 100%; 
    display: flex !important; 
    flex-direction: column !important; /* Xếp dọc */
    align-items: center !important; 
    justify-content: center !important; 
	gap: 5px;
	cursor: pointer;
}
.bar_info .mb-popup-icon svg { 
    width: 24px !important; 
    height: 24px !important; 
    margin-bottom: 2px; 
    fill: #8e8e93; 
}
.bar_info .mb-popup-text { 
    font-size: 13px !important; 
    line-height: 1.4 !important; 
    color: #8e8e93; 
    font-weight: 300 !important; 
}

/* Hiệu ứng Hover/Active */
.bar_info .mb-popup-trigger:hover .mb-popup-icon svg, 
.bar_info .mb-popup-trigger:hover .mb-popup-text { 
    fill: #fff !important; 
    color: #fff !important; 
}
.bar_info .mb-popup-trigger.active .mb-popup-icon svg, 
.bar_info .mb-popup-trigger.active .mb-popup-text { 
    fill: #10b981 !important; /* Màu xanh lá nổi bật */
    color: #10b981 !important; 
}

/* 4. Định vị Menu của Player: HIỆN LÊN TRÊN */
.bar_info .mb-popup-menu { 
    bottom: 135% !important; /* Đẩy lên trên nút */
    top: auto !important;    /* Hủy bỏ top */
    left: 50% !important; 
    transform: translateX(-50%) !important; /* Căn giữa */
    
    width: 160px; 
    z-index: 99999 !important; 
    background: #ffffff; 
    border-radius: 6px; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); 
    padding: 6px 0; 
}

/* Mũi tên chỉ xuống (cho khớp với vị trí menu ở trên) */
.bar_info .mb-popup-menu::before {
    content: '';
    position: absolute;
    bottom: -6px; /* Nằm ở đáy menu */
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    /* Tam giác hướng xuống */
    border-color: #fff transparent transparent transparent; 
}

/* =========================================
   4. SINGLE PAGE BUTTON (Nút "Thêm vào list" - Viên thuốc)
   ========================================= */
/* Bắt buộc phải có wrapper .mb-single-btn-wrap */
.mb-single-btn-wrap { display: inline-block !important; vertical-align: middle !important; position: relative !important; z-index: 50; margin-left: 15px; }

/* Style nút Viên thuốc */
.mb-single-btn-wrap .mb-popup-trigger {
    display: inline-flex !important; flex-direction: row !important; /* Xếp ngang */
    align-items: center !important; justify-content: center !important;
    height: 42px !important; padding: 0 25px !important; border-radius: 30px !important;
    background: #1a1a1a !important; border: 1px solid #3b82f6 !important;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.15) !important;
    min-width: 140px !important; cursor: pointer; gap: 8px !important;
}

/* Icon & Text Single Page */
.mb-single-btn-wrap .mb-popup-icon { display: flex !important; margin: 0 !important; }
.mb-single-btn-wrap .mb-popup-icon svg { width: 20px !important; height: 20px !important; fill: rgb(255 255 255) !important; margin: 0 !important; }
.mb-single-btn-wrap .mb-popup-text { font-size: 15px !important; font-weight: 600 !important; text-transform: capitalize !important; color: #fff !important; }

/* Hover Single Page */
.mb-single-btn-wrap .mb-popup-trigger:hover { background: #3b82f6 !important; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4) !important; }
.mb-single-btn-wrap .mb-popup-trigger.active { background: #3b82f6 !important; border-color: #3b82f6 !important; }
.mb-single-btn-wrap .mb-popup-trigger.active svg { fill: #fff !important; }
.mb-single-btn-wrap .mb-popup-trigger.active .mb-popup-text { color: #fff !important; }

/* Menu của Single Page: Hiện LÊN TRÊN */
.mb-single-btn-wrap .mb-popup-menu {
    /* 1. Định vị lên trên */
    bottom: 120% !important;  /* Đẩy menu lên phía trên nút */
    top: auto !important;     /* Hủy bỏ thuộc tính top cũ */
    
    /* 2. Căn giữa */
    left: 50% !important; 
    transform: translateX(-50%) !important;
    
    /* 3. Style khung */
    width: 180px; 
    z-index: 100 !important;
    background: #fff; 
    border-radius: 8px; 
    box-shadow: 0 5px 20px rgba(0,0,0,0.3); 
    padding: 5px 0;
}
.mb-single-btn-wrap .mb-popup-menu::before {
    content: '';
    position: absolute;
    /* Đặt mũi tên xuống đáy của menu */
    bottom: -6px; 
    top: auto;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    /* Tam giác ngược chỉ xuống */
    border-color: #fff transparent transparent transparent; 
}

/* =========================================
   5. PROFILE & SETTINGS
   ========================================= */
.mb-profile-header { text-align: center; margin-bottom: 30px; padding: 25px; background: #131313; border-radius: 12px; border: 1px solid #1e293b; position: relative; overflow: hidden; }
.mb-profile-header::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 5px; background: linear-gradient(90deg, #3b82f6, #8b5cf6); }
/* [UPDATE] Avatar with Gradient Border */
.mb-profile-avatar-wrap { 
    width: 110px; 
    height: 110px; 
    margin: 0 auto 15px; 
    border-radius: 50%; 
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3); 
    
    /* Tạo hiệu ứng viền gradient bằng padding + background */
    padding: 3px; 
    background: linear-gradient(45deg, #3b82f6, #8b5cf6, #ec4899); 
    background-size: 200% 200%;
    animation: mbGradientMove 3s ease infinite; /* Xoay màu viền */
}
/* Animation cho viền */
@keyframes mbGradientMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.mb-profile-avatar { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    border-radius: 50%; /* Bo tròn ảnh bên trong */
    display: block;
    background: #1a202c; /* Nền đệm */
}
.mb-profile-name { font-size: 22px; font-weight: 700; color: #fff; margin: 0 0 5px 0; letter-spacing: 0.5px; }
.mb-profile-date { font-size: 13px; color: #94a3b8; display: flex; align-items: center; justify-content: center; gap: 5px; }

/* Share Button */
.mb-share-box { display: flex; justify-content: center; align-items: center; width: 100%; margin-top: 15px; }
.mb-share-btn { display: inline-flex; align-items: center; justify-content: center; margin: 0 auto; padding: 10px 24px; font-size: 14px; background: #1e293b; border: 1px solid #334155; color: #94a3b8; border-radius: 8px; transition: all 0.2s ease; cursor: pointer; }
.mb-share-btn:hover { background: #334155; color: #fff; border-color: #475569; transform: translateY(-2px); }

/* Settings Form */
.mb-setting-section { background: #131313; padding: 25px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #1e293b; }
.mb-setting-section h4 { color: #fff; margin: 0 0 20px 0; border-bottom: 1px solid #1e293b; padding-bottom: 10px; font-size: 18px; }
.mb-form-group { margin-bottom: 20px; }
.mb-form-group label { display: block; color: #cbd5e1; margin-bottom: 8px; font-size: 14px; font-weight: 500; }
.mb-form-group input { width: 100%; padding: 12px; background: #0c0c0c; border: 1px solid #334155; border-radius: 6px; color: #fff; outline: none; transition: border 0.2s; font-size: 14px; box-sizing: border-box; }
.mb-form-group input:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }
.mb-btn-primary, .mb-btn-success, .mb-btn-danger { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; transition: 0.2s; cursor: pointer; border: none; outline: none; }
.mb-btn-primary { background: #3b82f6; color: #fff; padding: 10px 24px; border-radius: 6px; }
.mb-btn-primary:hover { background: #2563eb; transform: translateY(-1px); }
.mb-btn-primary:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.mb-btn-success { background: #10b981; color: #fff; padding: 8px 16px; border-radius: 6px; font-size: 13px; }
.mb-btn-success:hover { background: #059669; }
.mb-btn-danger { background: #ef4444; color: #fff; padding: 8px 16px; border-radius: 6px; font-size: 13px; margin-left: 10px; }
.mb-btn-danger:hover { background: #dc2626; }

/* Cropper */
#mb-crop-container { background: #000; padding: 10px; border-radius: 6px; border: 1px solid #334155; text-align: center; }
#mb-crop-container img { max-width: 100%; display: block; margin: 0 auto; }
.cropper-container { direction: ltr; font-size: 0; line-height: 0; position: relative; -ms-touch-action: none; touch-action: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } 
.cropper-view-box, .cropper-face { border-radius: 50%; }

/* =========================================
   6. PAGINATION & LOADING
   ========================================= */
.mb-pagination { display: flex; justify-content: center; margin-top: 20px; font-family: 'Rajdhani', sans-serif; gap: 5px; }
.mb-page-num { display: flex; justify-content: center; align-items: center; text-decoration: none; min-width: 40px; height: 40px; background:#0f1720; color: #6c7a89; font-size: 18px; font-weight: 500; border: 1px solid #1e293b; border-radius: 6px; transition: all 0.2s ease; cursor: pointer; }
.mb-page-num:hover:not(.active) { background-color: #1a1a1a; color: #fff; }
.mb-page-num.active { color: #ffffff; background-color: #2563eb; border-color: #2563eb; cursor: default; }
.mb-page-num.last { padding: 0 12px; font-size: 16px; text-transform: uppercase; }
.mb-page-dots { display: flex; justify-content: center; align-items: center; width: 40px; height: 40px; color: #4a5568; font-size: 20px; font-weight: bold; }

/* Spinner */
#mb-results-area { position: relative !important; min-height: 300px; transition: opacity 0.3s; z-index: 1; }
.mb-loading-overlay { position: absolute !important; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 32, 0.9); z-index: 10; border-radius: 8px; display: flex; justify-content: center; align-items: flex-start; padding-top: 80px; backdrop-filter: blur(3px); }
.mb-spinner-large { width: 50px; height: 50px; border: 4px solid rgba(255, 255, 255, 0.1); border-top-color: #3b82f6; border-radius: 50%; animation: mbSpin 0.6s linear infinite; }
@keyframes mbSpin { to { transform: rotate(360deg); } }

/* =========================================
   7. TOAST NOTIFICATION (MỚI THÊM)
   ========================================= */
#mb-toast-container { 
    position: fixed !important; 
    top: 20px !important; 
    right: 20px !important; 
    z-index: 2147483647 !important; /* Cao nhất có thể */
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    pointer-events: none; /* Cho phép bấm xuyên qua vùng trống */
}

.mb-toast { 
    background: #fff; 
    color: #333; 
    padding: 12px 20px; 
    border-radius: 8px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    min-width: 260px; 
    font-size: 14px; 
    font-weight: 500;
    border-left: 4px solid #2563eb; 
    
    /* Animation mặc định */
    opacity: 0; 
    transform: translateX(50px); 
    animation: mbSlideIn 0.3s forwards ease-out; 
    
    pointer-events: auto; /* Cho phép tương tác với thông báo */
}

/* Màu sắc từng loại */
.mb-toast.success { border-color: #10b981; } 
.mb-toast.error { border-color: #ef4444; } 
.mb-toast.warning { border-color: #f59e0b; }

.mb-toast-icon { font-size: 20px; line-height: 1; }

/* Keyframes quan trọng */
@keyframes mbSlideIn { 
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); } 
}

@keyframes mbFadeOut { 
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); } 
}
/* =========================================
   8. TABS NAVIGATION (PHẦN BẠN BỊ THIẾU)
   ========================================= */
.mb-tabs-wrapper { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; background: #131313; padding: 10px; border-radius: 8px; border: 1px solid #1e293b; }
.mb-tab { cursor: pointer; padding: 8px 16px; border-radius: 6px; color: #94a3b8; font-size: 14px; font-weight: 600; transition: all 0.2s ease; display: flex; align-items: center; gap: 6px; user-select: none; }
.mb-tab:hover { background: rgba(255, 255, 255, 0.05); color: #cbd5e1; }
.mb-tab.active { background: #2563eb; color: #ffffff; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); }
.mb-tab.active .mb-tab-count { opacity: 1; background: rgba(0,0,0,0.2); padding: 2px 6px; border-radius: 10px; }
@media (max-width: 600px) {
    .mb-tabs-wrapper { flex-wrap: nowrap !important; overflow-x: auto; justify-content: flex-start; gap: 8px; padding-bottom: 5px; -ms-overflow-style: none; scrollbar-width: none; }
    .mb-tabs-wrapper::-webkit-scrollbar { display: none; }
    .mb-tab { flex: 0 0 auto; width: auto; white-space: nowrap; font-size: 13px; padding: 6px 12px; }
}