/* ========================================================== */
/* ==           NÂNG CẤP GIAO DIỆN TÔNG MÔN               == */
/* ========================================================== */

/* --- Keyframes cho các hiệu ứng Animation --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes glow {
    0% { text-shadow: 0 0 5px rgba(255, 196, 122, 0.7), 0 0 10px rgba(255, 196, 122, 0.5); }
    50% { text-shadow: 0 0 10px rgba(255, 220, 150, 0.9), 0 0 20px rgba(255, 196, 122, 0.7); }
    100% { text-shadow: 0 0 5px rgba(255, 196, 122, 0.7), 0 0 10px rgba(255, 196, 122, 0.5); }
}



/* === Header của Panel Tông Môn === */
.tong-mon-header {
    position: relative; /* Rất quan trọng để định vị nút con */
    width: 100%;
    max-width: 600px; /* Giới hạn chiều rộng của header */
    display: flex;
    justify-content: center; /* Căn giữa tiêu đề theo chiều ngang */
    align-items: center;
    padding: 20px 0;
    margin-bottom: 20px;
}


/* === PANEL TÔNG MÔN TOÀN MÀN HÌNH  === */

/* Sử dụng ID #tongMon để có độ ưu tiên cao nhất */
#tongMon {
    /* Kích hoạt Flexbox để căn chỉnh */
    display: flex;
    flex-direction: column;

    /* Căn giữa tất cả nội dung con theo chiều ngang */
    align-items: center; 
    
    /* Đẩy nội dung lên phía trên, không căn giữa theo chiều dọc */
    justify-content: flex-start;

    /* Thêm khoảng đệm phía trên cho đẹp */
    padding-top: 5vh; 

    /* Các thuộc tính khác */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding-left: 20px;
    padding-right: 20px;
    overflow-y: auto;
    background: radial-gradient(ellipse at center, #2a2a2e 0%, #1c1c1f 100%);
    animation: fadeIn 0.5s ease-out;
}

.tong-mon-header .tong-mon-main-title {
    font-size: 2.8em;
    color: #ffc97a;
    margin-bottom: 20px;
    animation: glow 2.5s infinite ease-in-out;
}

/* Giới hạn chiều rộng của khối nội dung chính để nó không bị bè ra trên màn hình lớn */
.tong-mon-content {
    width: 100%;
    max-width: 650px; /* Bạn có thể điều chỉnh con số này */
    text-align: center;
    animation: slideUp 0.6s ease-out forwards;
}

#sect-status-message {
    font-size: 1.2em;
    color: #ccc;
    margin-bottom: 25px;
}

#sect-status-message strong {
    color: #E48F45;
}

/* Nút bấm hành động chính */
.create-sect-link-standalone, #go-to-my-sect-btn {
    display: inline-block;
    padding: 15px 30px;
    font-size: 1.2em;
    font-weight: bold;
    color: #1a1a1a;
    background: linear-gradient(145deg, #ffc97a, #E48F45);
    border: none;
    border-radius: 8px;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(228, 143, 69, 0.3), inset 0 -2px 2px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.create-sect-link-standalone:hover, #go-to-my-sect-btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 6px 20px rgba(228, 143, 69, 0.5), inset 0 -2px 2px rgba(0,0,0,0.15);
    filter: brightness(1.1);
}

.sect-list-title {
    margin: 40px 0 15px 0;
    font-size: 1.5em;
    color: #E48F45;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}


* --- PANEL LẬP TÔNG MÔN (CSS ĐÃ SỬA LỖI VÀ THIẾT KẾ LẠI) --- */

@keyframes slideUpIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 4px rgba(228, 143, 69, 0.4);
    }
    50% {
        box-shadow: 0 0 12px rgba(228, 143, 69, 0.8);
    }
    100% {
        box-shadow: 0 0 4px rgba(228, 143, 69, 0.4);
    }
}


#create-sect-modal-overlay {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.create-sect-content {
    position: relative;
    background: #1e1e22;
    border: 1px solid #4a4a52;
    border-radius: 8px;
    padding: 25px 30px;
    width: 100%;
    max-width: 480px;
    color: #e0e0e0;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    text-align: center;
    animation: slideUpIn 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

.create-sect-content h3 {
    color: #E48F45;
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 1.6em;
    font-weight: 500;
}

.create-sect-content h3 .fas {
    margin-right: 10px;
}

.emblem-upload-area {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 15px auto;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px dashed #444;
    background-color: #111;
}

#emblem-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.emblem-upload-area .upload-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.emblem-upload-area:hover .upload-overlay {
    opacity: 1;
}

.emblem-upload-area:hover #emblem-preview {
    transform: scale(1.1);
}

.upload-overlay .fas {
    font-size: 24px;
    margin-bottom: 8px;
}

.emblem-selection-title {
    font-size: 0.9em;
    color: #aaa;
    margin-bottom: 15px;
}

.preset-emblems-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 25px;
}

.preset-emblems-grid img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #555;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-emblems-grid img:hover {
    transform: scale(1.1);
    border-color: #999;
}

.preset-emblems-grid img.selected {
    border-color: #E48F45;
    transform: scale(1.05);
    animation: pulse-glow 2s infinite;
}

.create-sect-content .input-group {
    text-align: left;
    margin-bottom: 15px;
}

.create-sect-content .input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #ccc;
}

.create-sect-content .input-group input,
.create-sect-content .input-group textarea {
    width: 100%;
    padding: 10px;
    background: #111;
    border: 1px solid #444;
    border-radius: 4px;
    color: #fff;
    box-sizing: border-box;
}

.create-sect-content .input-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-fee {
    color: #ffde7a;
    margin-top: 20px;
    margin-bottom: 20px;
    font-style: italic;
}

.confirm-create-btn {
    width: 100%;
    padding: 12px;
    font-size: 1.1em;
    font-weight: bold;
    background-color: #995A3A;
    transition: background-color 0.3s ease;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 5px;
}

.confirm-create-btn:hover {
    background-color: #E48F45;
}


/* ========================================= */
/* ==       Panel Nhà Tông Môn (Full)     == */
/* ========================================= */

#sect-view-fullscreen {
    /* ----- Cấu trúc & Vị trí ----- */
    display: flex;
    flex-direction: column;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh; /* Quan trọng: Chiếm 100% chiều cao màn hình */
    overflow: auto; /* Cho phép cuộn nếu nội dung quá dài */

    /* ----- Hình nền ----- */
    background-image: linear-gradient(rgba(10, 5, 2, 0.6), rgba(0, 0, 0, 0.9)), url('/assets/chua.jpg');
    background-size: cover; /* Quan trọng: Phủ kín toàn bộ không gian */
    background-position: center bottom; /* Căn nền vào giữa và ở dưới */
    background-repeat: no-repeat;
    
    /* ----- Hiệu ứng ----- */
    animation: fadeIn 0.5s ease-out;
}

/* (Tùy chọn) Đảm bảo nội dung bên trong được đẩy lên trên */
#sect-view-fullscreen .sect-home-content {
    padding-top: 5vh; 
    /* Các thuộc tính khác của .sect-home-content giữ nguyên */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#sect-home-name {
    font-size: 3em;
    color: #ffdeb4;
    text-shadow: 0 0 10px #ffc97a, 0 0 20px #E48F45, 0 0 35px #a15821;
}

/* Thanh footer của nhà tông môn */
.sect-home-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(228, 143, 69, 0.3);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.3);
}

.sect-footer-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: #aaa;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}
.sect-footer-btn:hover {
    color: #ffc97a;
    transform: translateY(-3px);
}
.sect-footer-btn i { font-size: 22px; }
.sect-footer-btn span { font-size: 11px; font-weight: 500;}

/* Nút "Động Phủ" ở giữa */
.sect-footer-btn.is-central {
    transform: translateY(-20px);
    background-color: #E48F45;
    color: #fff;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: 3px solid #1c1c1f;
    justify-content: center;
    box-shadow: 0 0 20px rgba(228, 143, 69, 0.6);
}
.sect-footer-btn.is-central:hover {
    background-color: #ffc97a;
    color: #1c1c1f;
}
.sect-footer-btn.is-central i { font-size: 28px; }


/* === PANEL CHI TIẾT TÔNG MÔN (Lớp phủ nền) === */
.sect-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    background: rgba(18, 18, 18, 0.6);
    backdrop-filter: blur(10px);
    
    display: flex;
    justify-content: center;
    align-items: center;
    
    padding: 20px;
    box-sizing: border-box;
    z-index: 1000;
    
    overflow: hidden; /* Quan trọng: Ẩn thanh cuộn của cả trang */
    
    animation: fadeIn 0.3s ease;
}

/* === Khung Nội Dung Chính === */
.sect-panel-content {
    /* ----- Kích Thước Linh Hoạt (Responsive) ----- */
    width: 95vw; /* Chiếm 95% chiều rộng trên màn hình nhỏ */
    max-width: 800px; /* Nhưng không quá 800px trên màn hình lớn */
    height: 85vh; /* Chiếm 85% chiều cao màn hình */
    max-height: 900px; /* Giới hạn chiều cao tối đa */
    position: relative;

    /* ----- Cấu trúc Flexbox ----- */
    display: flex;
    flex-direction: column; /* Sắp xếp header, content, footer theo cột */

    /* ----- Giao diện ----- */
    background: #242428;
    border: 1px solid rgba(228, 143, 69, 0.4);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    
    padding: 0; /* Xóa padding cũ để kiểm soát tốt hơn */
    overflow: hidden; /* Quan trọng: để bo góc và layout hoạt động đúng */
    
    /* ----- Hiệu ứng ----- */
    animation: slideUp 0.4s ease-out;
}

/* Header và Footer của Panel (Giữ nguyên, không cuộn) */
.sect-panel-header {
    padding: 20px;
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0; /* Không cho co lại */
}

.sect-daily-stipend {
    background: linear-gradient(rgba(40,40,44,0.8), rgba(30,30,33,0.8));
    border-top: 1px solid #444;
    padding: 20px;
    flex-shrink: 0; /* Không cho co lại */
}

.sect-panel-emblem {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid #E48F45;
    box-shadow: 0 0 15px rgba(228, 143, 69, 0.5);
}

.sect-panel-info-text h2 {
    color: #ffc97a;
    margin: 0 0 5px 0;
}
.sect-panel-info-text p {
    margin: 0;
    color: #aaa;
    font-size: 0.9em;
}




/* === Nút Đóng Panel (Nằm ngoài góc) === */
.sect-panel-close-btn {
    /* ----- Vị trí ----- */
    position: absolute;
    top: -18px;
    right: -18px;
    z-index: 1100;

    /* ----- Kích thước & Hình dạng ----- */
    width: 36px;
    height: 36px;
    border-radius: 50%;

    /* ----- Giao diện ----- */
    background: rgba(40, 40, 44, 0.8);
    border: 1px solid #666;
    color: #ddd;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);

    /* ----- Căn chỉnh & Hiệu ứng ----- */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sect-panel-close-btn:hover {
    transform: scale(1.1);
    background: #E48F45;
    color: #fff;
    border-color: #ffc97a;
    box-shadow: 0 4px 10px rgba(228, 143, 69, 0.6);
}

.sect-panel-close-btn:active {
    transform: scale(0.95);
}

.sect-panel-close-btn:focus {
    outline: none;
}

/* ========================================= */
/* ==   Style Chung Cho Nút Đóng Modal     == */
/* ========================================= */

.modal-close-button-style {
    /* ----- Vị trí ----- */
    position: absolute;
    top: -15px;
    right: -15px;
    z-index: 9999; /* Z-index cực lớn để luôn nổi lên trên cùng */

    /* ----- Kích thước & Hình dạng ----- */
    width: 32px;
    height: 32px;
    border-radius: 50%;

    /* ----- Giao diện ----- */
    background: #2a2a2e;
    border: 1px solid #777;
    color: #ccc;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);

    /* ----- Căn chỉnh & Hiệu ứng ----- */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
}

.modal-close-button-style:hover {
    transform: scale(1.1) rotate(180deg);
    background: #E48F45;
    color: #fff;
    border-color: #ffc97a;
}

/* Quan trọng: Đảm bảo panel cha có position: relative */
#mailbox-panel-content, .sect-panel-content {
    position: relative;
}


/* Danh sách thành viên trong modal */
/* === Khu vực Danh Sách Thành Viên (Scrollable) === */
.sect-member-list-container {
    flex-grow: 1; /* Quan trọng: Cho phép khu vực này giãn ra, chiếm hết không gian trống */
    overflow-y: auto; /* Quan trọng: Tự động thêm thanh cuộn khi cần */
    padding: 0 20px 20px 20px; /* Thêm đệm cho đẹp */
}

/* Tùy chỉnh thanh cuộn cho đẹp */
.sect-member-list-container::-webkit-scrollbar {
    width: 8px;
}
.sect-member-list-container::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}
.sect-member-list-container::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}
.sect-member-list-container::-webkit-scrollbar-thumb:hover {
    background-color: #E48F45;
}





/* ================================================== */
/* ==   Danh Sách Thành Viên (Bố cục 2 cột)        == */
/* ================================================== */

/* --- Container chung cho Header và mỗi dòng --- */
.ranking-header,
.ranking-entry .entry-content {
    display: grid;
    /* QUAN TRỌNG: Chỉ còn 2 cột */
    grid-template-columns: 50px 1fr;
    align-items: start;
    gap: 10px;
    width: 100%;
}

/* --- Style cho Header (bỏ cột cống hiến) --- */
.ranking-header {
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
    text-transform: uppercase;
    font-weight: 600;
    color: #999;
    font-size: 0.8em;
}
.header-col.rank { text-align: center; }
.header-col.player { text-align: left; }


/* --- Style cho nội dung của từng dòng --- */
/* Cột Hạng */
.entry-col.rank {
    font-size: 1.4em;
    font-weight: bold;
    color: #BDBDBD; /* Màu xám bạc, nổi bật hơn */
    text-align: center;
    padding-top: 10px;
}
.entry-col.player {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

/* Chi tiết thành viên */
.player-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-name {
    font-weight: 600;
    font-size: 1.1em;
    color: #E4DCCF; /* Giữ màu giấy da cho tên */
}
.player-level {
    font-size: 0.9em;
    color: #A6D8B4; /* Màu xanh lá mạ cho cấp độ */
}

/* Dòng Cống Hiến */
.player-contribution {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
}
.contribution-label {
    font-size: 0.9em;
    color: #aaa; /* Giữ màu xám cho nhãn */
}
.contribution-value {
    font-size: 1em;
    font-weight: 600;
    color: #F5A623; /* Giữ màu cam cho điểm cống hiến */
}

.header-col.player .player-avatar-mini {
    width: 32px;
    height: 32px;
}

/* Khối nhận bổng lộc */
.sect-daily-stipend {
    background: linear-gradient(rgba(40,40,44,0.8), rgba(30,30,33,0.8));
    border-top: 1px solid #444;
    padding: 20px;
}
#claim-stipend-btn {
    background: linear-gradient(145deg, #4caf50, #419844);
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}
#claim-stipend-btn:hover {
    filter: brightness(1.1);
}



.tong-mon-header .back-btn {
    /* Định vị tuyệt đối so với header */
    position: absolute; 
    left: 0; /* Đặt ở cạnh trái của header */
    top: 50%; /* Căn giữa theo chiều dọc */
    transform: translateY(-50%); /* Tinh chỉnh để tâm nút nằm chính giữa */
    
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.2em;
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 5;
}

.tong-mon-header .back-btn:hover {
    background: rgba(228, 143, 69, 0.8);
    border-color: #ffc97a;
    transform: translateY(-50%) scale(1.1); /* Giữ nguyên transform dọc khi phóng to */
    box-shadow: 0 0 15px rgba(228, 143, 69, 0.5);
}

/* ========================================================== */
/* ==      NỘI DUNG MÀN HÌNH CHÍNH CỦA TÔNG MÔN            == */
/* ========================================================== */

.sect-home-content {
    width: 100%;
    padding: 20px;
    padding-top: 5vh; /* Khoảng cách từ đỉnh màn hình */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.sect-home-title {
    font-size: 2.8em;
    color: #E48F45;
    font-weight: 600;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
    margin: 0;
    padding: 0 20px;
    position: relative;
    text-align: center;
}

/* Hiệu ứng gạch chân trang trí */
.sect-home-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 2px;
    background: linear-gradient(to right, transparent, #E48F45, transparent);
}

.sect-activity-feed {
    width: 100%;
    max-width: 600px;
    min-height: 200px;
    background: rgba(0, 0, 0, 0.5); /* Nền đen mờ */
    border-radius: 8px;
    backdrop-filter: blur(5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.sect-activity-feed h4 {
    margin: 0 0 15px 0;
    text-align: center;
    color: #E48F45;
    font-size: 1.2em;
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.sect-activity-feed h4 .fas {
    margin-right: 8px;
}

.sect-activity-feed .feed-content {
    flex-grow: 1; /* Làm cho khung nội dung chiếm hết không gian còn lại */
    max-height: 300px; /* Chiều cao tối đa trước khi có thanh cuộn */
    overflow-y: auto;
    padding-right: 10px; /* Chừa không gian cho thanh cuộn */
    display: flex;
    flex-direction: column-reverse; /* Đảo ngược để thông báo mới nhất ở dưới cùng */
}

/* Tùy chỉnh thanh cuộn */
.feed-content::-webkit-scrollbar { width: 6px; }
.feed-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.feed-content::-webkit-scrollbar-thumb { background-color: #555; border-radius: 3px; }

/* Hiệu ứng và style cho từng dòng thông báo */
@keyframes newItemFadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.activity-item {
    margin-bottom: 10px;
    color: #ccc;
    font-size: 0.95em;
    line-height: 1.5;
    animation: newItemFadeIn 0.5s ease-out;
}

.activity-item .activity-timestamp {
    color: #E48F45;
    font-weight: bold;
    margin-right: 8px;
}

.activity-item .activity-actor {
    color: #ffc97a; /* Màu vàng sáng cho tên nhân vật */
    font-weight: 600;
}


/* ========================================================== */
/* ==      NỘI DUNG MÀN HÌNH CHÍNH CỦA TÔNG MÔN            == */
/* ========================================================== */

.sect-home-content {
    width: 100%;
    padding: 20px;
    padding-top: 5vh; /* Khoảng cách từ đỉnh màn hình */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.sect-home-title {
    font-size: 2.8em;
    color: #E48F45;
    font-weight: 600;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
    margin: 0;
    padding: 0 20px;
    position: relative;
    text-align: center;
}

/* Hiệu ứng gạch chân trang trí */
.sect-home-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 2px;
    background: linear-gradient(to right, transparent, #E48F45, transparent);
}

.sect-activity-feed {
    width: 100%;
    max-width: 600px;
    min-height: 200px;
    background: rgba(18, 18, 18, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    backdrop-filter: blur(5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.sect-activity-feed h4 {
    margin: 0 0 15px 0;
    text-align: center;
    color: #E48F45;
    font-size: 1.2em;
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.sect-activity-feed h4 .fas {
    margin-right: 8px;
}

.sect-activity-feed .feed-content {
    flex-grow: 1; /* Làm cho khung nội dung chiếm hết không gian còn lại */
    max-height: 300px; /* Chiều cao tối đa trước khi có thanh cuộn */
    overflow-y: auto;
    padding-right: 10px; /* Chừa không gian cho thanh cuộn */
    display: flex;
    flex-direction: column-reverse; /* Đảo ngược để thông báo mới nhất ở dưới cùng */
}

/* Tùy chỉnh thanh cuộn */
.feed-content::-webkit-scrollbar { width: 6px; }
.feed-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.feed-content::-webkit-scrollbar-thumb { background-color: #555; border-radius: 3px; }

/* Hiệu ứng và style cho từng dòng thông báo */
@keyframes newItemFadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.activity-item {
    margin-bottom: 10px;
    color: #ccc;
    font-size: 0.95em;
    line-height: 1.5;
    animation: newItemFadeIn 0.5s ease-out;
}

.activity-item .activity-timestamp {
    color: #E48F45;
    font-weight: bold;
    margin-right: 8px;
}

.activity-item .activity-actor {
    color: #ffc97a; /* Màu vàng sáng cho tên nhân vật */
    font-weight: 600;
}


/* ========================================= */
/* ==   Nút Trở Về (Vị trí dưới bản tin)    == */
/* ========================================= */

.sect-home-back-button {
    /* Đã loại bỏ position, top, left để nút tự căn chỉnh */
    margin-top: 25px; /* Tạo khoảng cách với bản tin ở trên */
    padding: 10px 25px; /* Tăng chiều rộng một chút */
    font-size: 1em;
    font-weight: 600;
    color: #E4DCCF;
    
    background: linear-gradient(145deg, rgba(45, 45, 50, 0.7), rgba(30, 30, 33, 0.7));
    border: 1px solid rgba(228, 143, 69, 0.3);
    border-radius: 8px;
    
    cursor: pointer;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    
    transition: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
    
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2), 
                inset 0 0 10px rgba(228, 143, 69, 0.1);
}

.sect-home-back-button:hover {
    transform: translateY(-3px) scale(1.05);
    color: #ffc97a;
    border-color: #E48F45;
    box-shadow: 0 5px 20px rgba(228, 143, 69, 0.25),
                inset 0 0 15px rgba(228, 143, 69, 0.2);
}

.sect-home-back-button:active {
    transform: translateY(0) scale(1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3),
                inset 0 0 10px rgba(0, 0, 0, 0.3);
    transition-duration: 0.1s;
}

.sect-home-back-button i {
    margin-right: 8px;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.sect-home-back-button:hover i {
    transform: translateX(-4px);
}

/* ========================================= */
/* ==   Giao Diện Danh Sách Thành Viên     == */
/* ========================================= */

/* Khung chính cho mỗi thành viên */
.ranking-entry {
    position: relative; /* Nền tảng để định vị chức vụ */
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid transparent; /* Viền trong suốt, màu sẽ được ghi đè */
    border-radius: 10px;
    margin-bottom: 15px; /* Khoảng cách giữa các thành viên */
    padding: 12px 15px;
    transition: all 0.3s ease;
    margin-top: 10px; /* Tạo không gian cho chức vụ đè lên */
}

.ranking-entry:hover {
    transform: translateY(-3px) scale(1.02);
    background: rgba(255, 255, 255, 0.08);
}

/* --- Các lớp màu viền theo chức vụ --- */
.ranking-entry.role-tong-chu {
    border-color: #4A90E2; /* Xanh nước biển */
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.3);
}
.ranking-entry.role-pho-tong-chu {
    border-color: #50E3C2; /* Xanh lá cây */
    box-shadow: 0 0 15px rgba(80, 227, 194, 0.3);
}
.ranking-entry.role-truong-lao {
    border-color: #F8E71C; /* Vàng */
    box-shadow: 0 0 15px rgba(248, 231, 28, 0.3);
}
.ranking-entry.role-thanh-vien {
    border-color: #F5A623; /* Cam nhạt */
    box-shadow: 0 0 15px rgba(245, 166, 35, 0.2);
}

/* Thẻ hiển thị chức vụ đè lên viền */
.member-role-tag {
    position: absolute;
    top: -14px; /* Đẩy lên trên để đè lên viền */
    left: 15px;
    color: #1a1a1a;
    font-size: 0.8em;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 6px;
    text-transform: uppercase;
}

/* --- Màu nền cho thẻ chức vụ --- */
.role-tong-chu .member-role-tag { background-color: #4A90E2; }
.role-pho-tong-chu .member-role-tag { background-color: #50E3C2; }
.role-truong-lao .member-role-tag { background-color: #F8E71C; }
.role-thanh-vien .member-role-tag { background-color: #F5A623; }

/* Thẻ hiển thị Tu Vi */
.member-realm-tag {
    position: absolute;
    /* THAY ĐỔI VỊ TRÍ TẠI ĐÂY */
    bottom: 10px; /* Di chuyển xuống dưới */
    right: 15px;  /* Giữ ở bên phải */
    
    background: #1F2544;
    color: #81D4FA;
    border: 1px solid #474F7A;
    font-size: 0.8em;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 6px;
    text-transform: uppercase;
}




/* Sắp xếp lại header của panel */
.sect-panel-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid #444;
}

/* Container cho các nút chức năng */
.header-actions-container {
    margin-left: auto; /* Quan trọng: Đẩy các nút về phía bên phải */
    display: flex;
    gap: 12px; /* Khoảng cách giữa các nút */
}

/* Style cho từng nút */
.header-action-btn {
    background: rgba(74, 74, 94, 0.6);
    border: 1px solid #6b6b83;
    color: #e0e0e0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.header-action-btn:hover {
    background-color: #5f5f7a;
    color: #fff;
    transform: scale(1.1);
}

/* Nút giải tán có màu đỏ để cảnh báo */
#sect-disband-btn {
    background-color: rgba(125, 42, 42, 0.6);
    border-color: #a53f3f;
}

#sect-disband-btn:hover {
    background-color: #a53f3f;
}

/* Class 'hidden' để ẩn các nút đi */
.hidden {
    display: none !important;
}

/* Responsive cho Header của Panel Tông Môn chi tiết */
@media (max-width: 480px) {
    .sect-panel-header {
        /* Khi màn hình nhỏ, chuyển bố cục sang dạng cột (xếp chồng lên nhau) */
        flex-direction: column;
        /* Căn các mục về phía bên trái */
        align-items: flex-start;
        /* Tăng khoảng cách giữa khối thông tin và khối nút */
        gap: 15px;
    }

    .header-actions-container {
        /* Bỏ margin cũ để không bị đẩy lệch */
        margin-left: 0; 
        /* Tự đẩy khối chứa các nút về phía cuối (bên phải) của panel */
        align-self: flex-end; 
    }
}


.sect-list-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid transparent;
    transition: all 0.2s ease-in-out;
}

.sect-list-item:hover {
    border-color: #E48F45;
    background: rgba(228, 143, 69, 0.1);
}

.sect-item-emblem {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 15px;
    flex-shrink: 0;
}

.sect-item-info {
    flex-grow: 1;
}

.sect-item-name {
    margin: 0 0 5px 0;
    color: #e0e0e0;
    font-size: 1.1em;
}

.sect-item-details {
    margin: 0;
    font-size: 0.85em;
    color: #aaa;
    display: flex;
    gap: 15px;
}

.sect-item-details i {
    margin-right: 5px;
    color: #E48F45;
}

.sect-item-join-btn {
    background: #5A3E2B;
    color: #ddd;
    border: 1px solid #8c6d56;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.sect-item-join-btn:hover {
    background-color: #7c5942;
    color: #fff;
}



/* Keyframes cho hiệu ứng xuất hiện */
@keyframes slideUpIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- Panel Quản Lý Tông Môn (Giao diện mới) --- */
#sect-manage-panel-overlay {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1010;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* css/tongmon.css */

/* --- Panel Quản Lý Tông Môn (CSS ĐÃ SỬA LỖI VÀ LÀM SẠCH) --- */

@keyframes slideUpIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.hidden-by-role {
    display: none !important;
}

#sect-manage-panel-overlay {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1010;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sect-manage-panel {
    width: 90%;
    max-width: 500px;
    background: #24272c;
    border-radius: 12px;
    border: 1px solid #40444c;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    animation: slideUpIn 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

.manage-panel-header {
    position: relative;
    display: flex;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid #3a3f48;
}

.manage-panel-header h3 {
    margin: 0;
    color: #E48F45;
    font-size: 1.5em;
    font-weight: 600;
}

.manage-panel-header h3 .fas {
    margin-right: 12px;
}

#sect-manage-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 35px;
    height: 35px;
}

.manage-tabs-nav {
    display: flex;
    padding: 10px 20px;
    background-color: #2c3038;
    border-bottom: 1px solid #3a3f48;
}

.manage-tab-link {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: #a0a8b4;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.25s ease-out;
    position: relative;
}

.manage-tab-link:hover {
    color: #fff;
    background-color: #3e434c;
}

.manage-tab-link.active {
    color: #E48F45;
    background-color: #24272c;
    font-weight: 700;
}

.manage-tab-link.active::after {
    content: '';
    position: absolute;
    bottom: -11px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #E48F45;
}

.manage-panel-content {
    padding: 25px;
    overflow-y: auto;
    flex-grow: 1;
}

.manage-tab-content { display: none; }
.manage-tab-content.active { display: block; }

#edit-sect-info-form {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#edit-sect-info-form .form-group {
    width: 100%;
    margin-bottom: 25px;
}

#edit-sect-info-form label {
    text-align: center;
    display: block;
    color: #c0c8d4;
    margin-bottom: 12px;
    font-weight: 500;
}

#edit-sect-info-form .emblem-upload-area {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 15px auto;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px dashed #444;
}

#edit-sect-info-form #emblem-edit-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#edit-sect-info-form .upload-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#edit-sect-info-form .emblem-upload-area:hover .upload-overlay {
    opacity: 1;
}

#edit-sect-info-form .emblem-selection-title {
    font-size: 0.9em;
    color: #aaa;
    margin: 15px 0;
    text-align: center;
}

#edit-sect-info-form .preset-emblems-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 320px;
    margin: 0 auto;
}

#edit-sect-info-form .preset-emblems-grid img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #555;
    cursor: pointer;
    transition: all 0.3s ease;
}

#edit-sect-info-form .preset-emblems-grid img:hover,
#edit-sect-info-form .preset-emblems-grid img.selected {
    border-color: #E48F45;
    transform: scale(1.1);
}

#edit-sect-info-form input, 
#edit-sect-info-form textarea {
    width: 100%;
    max-width: 350px;
    display: block;
    margin: 0 auto;
    padding: 12px;
    background: #1a1c20;
    border: 1px solid #40444c;
    border-radius: 6px;
    color: #e0e8f2;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    text-align: center;
}

#edit-sect-info-form input:focus, 
#edit-sect-info-form textarea:focus {
    outline: none;
    border-color: #E48F45;
    box-shadow: 0 0 0 3px rgba(228, 143, 69, 0.2);
}

#edit-sect-info-form .form-hint { 
    font-size: 0.85em; 
    color: #808894; 
    margin-top: 8px;
    text-align: center;
}

.manage-save-btn {
    width: 100%;
    max-width: 350px;
    padding: 12px;
    background: linear-gradient(145deg, #e39d67, #d47e45);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    margin-top: 10px;
}

.manage-save-btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 15px rgba(228, 143, 69, 0.3);
}

.join-request-item {
    display: flex;
    align-items: center;
    background: #2a2a2e;
    padding: 12px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.join-request-item:not(:last-child) {
    margin-bottom: 12px;
}

.join-request-item:hover {
    background-color: #333338;
}

.request-info {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}

.request-info img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #555;
}

.request-details { line-height: 1.3; }
.request-details .player-name { font-weight: bold; color: #fff; }
.request-details .player-level { font-size: 0.9em; color: #aaa; }

.request-actions {
    display: flex;
    gap: 10px;
}

.request-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-weight: bold;
}

.request-actions .approve-btn { background-color: #28a745; }
.request-actions .approve-btn:hover { background-color: #218838; }
.request-actions .deny-btn { background-color: #dc3545; }
.request-actions .deny-btn:hover { background-color: #c82333; }

/* giải tán tông môn */
/* css/tongmon.css */

/* --- Hộp thoại xác nhận giải tán --- */
#disband-confirm-modal {
    z-index: 1020; /* Phải nằm trên tất cả các panel khác */
}

.confirm-dialog-box {
    background: #2c3038;
    border: 1px solid #c82333;
    border-radius: 8px;
    padding: 30px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 5px 25px rgba(220, 53, 69, 0.3);
    animation: slideUpIn 0.3s ease-out;
}

.confirm-dialog-box h4 {
    color: #dc3545;
    font-size: 1.6em;
    margin-top: 0;
    margin-bottom: 15px;
}

.confirm-dialog-box h4 .fas {
    margin-right: 10px;
}

.confirm-dialog-box p {
    color: #ccc;
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 30px;
}

.confirm-dialog-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.dialog-btn {
    padding: 10px 25px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dialog-btn.cancel-btn {
    background-color: #4a4a52;
    color: #fff;
}

.dialog-btn.cancel-btn:hover {
    background-color: #5a5a62;
}

.dialog-btn.confirm-btn {
    background-color: #dc3545;
    color: #fff;
}

.dialog-btn.confirm-btn:hover {
    background-color: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.4);
}


/* Style cho nút Rời Tông Môn */
#sect-leave-btn {
    background-color: rgba(189, 87, 87, 0.6);
    border-color: #d16a6a;
}

#sect-leave-btn:hover {
    background-color: #d16a6a;
}

/* Nút hủy đơn xin gia nhập tông môn*/

.sect-item-join-btn.cancel-request {
    background-color: #a13a3a; /* Màu đỏ */
    border-color: #b55;
}

.sect-item-join-btn.cancel-request:hover {
    background-color: #c0392b;
}


/* ========================================================== */
/* ==      DÁN TOÀN BỘ ĐOẠN NÀY VÀO CUỐI TỆP tongmon.css    == */
/* ========================================================== */

/* --- Cấu trúc chung của mỗi thành viên --- */
.ranking-entry {
    position: relative;
    background: rgba(36, 36, 40, 0.8);
    border: 1px solid #4a4a52;
    border-radius: 10px;
    margin-bottom: 15px;
    padding: 12px 15px;
    transition: all 0.3s ease;
    /* QUAN TRỌNG: Tạo khoảng trống ở trên để thẻ chức vụ có chỗ hiển thị */
    margin-top: 20px;
    overflow: visible; /* Đảm bảo thẻ không bị cắt */
}

/* 1. Sửa thẻ Chức vụ (Tông Chủ, Phó Tông Chủ...) */
.member-role-tag {
    position: absolute;
    top: -14px; /* Đẩy lên trên, đè lên viền */
    left: 15px; /* Căn lề trái */
    font-size: 0.8em;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 15px;
    text-transform: uppercase;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 5; /* Cho thẻ nổi lên trên */
}

/* --- Phân màu nền cho các thẻ chức vụ --- */
.role-tong-chu .member-role-tag { background-color: #F8E71C; color: #333; }
.role-pho-tong-chu .member-role-tag { background-color: #50E3C2; color: #333; }
.role-truong-lao .member-role-tag { background-color: #4A90E2; color: #fff; }
/* Mặc định cho thành viên hoặc vai trò khác */
.ranking-entry:not(.role-tong-chu):not(.role-pho-tong-chu):not(.role-truong-lao) .member-role-tag {
    background-color: #888;
    color: #fff;
}


/* 2. Sửa lỗi Tu Vi đè lên Cống Hiến */

/* Sắp xếp chi tiết người chơi (tên, cấp, tu vi, cống hiến) */
.player-details {
    display: flex;
    flex-direction: column; /* Xếp các mục theo cột dọc */
    align-items: flex-start; /* Căn các mục về bên trái */
    gap: 6px; /* Khoảng cách giữa các mục */
}

/* Thẻ hiển thị Tu Vi (NGUYÊN ANH...) */
.member-realm-tag {
    /* Bỏ position: absolute để nó nằm trong luồng bình thường */
    position: static;
    /* Style lại cho đẹp */
    background: #1F2544;
    color: #81D4FA;
    border: 1px solid #474F7A;
    font-size: 0.8em;
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 6px;
    text-transform: uppercase;
    display: inline-block; /* Để padding và border hoạt động đúng */
}

/* Dòng Cống Hiến */
.player-contribution {
    display: flex;
    align-items: center;
    gap: 5px;
}
.contribution-label {
    font-size: 0.9em;
    color: #aaa;
}
.contribution-value {
    font-size: 1em;
    font-weight: 600;
    color: #F5A623;
}

/* ========================================================== */
/* ==              KẾT THÚC PHẦN SỬA LỖI                    == */
/* ========================================================== */

/* ============================================================== */
/* ==      GIẢI PHÁP CUỐI CÙNG    == */
/* ============================================================== */

/*
 * BƯỚC 1: Đặt thẻ chức vụ nằm gọn bên trong khung
 * Thay đổi giá trị 'top' thành 0 để nó nằm sát mép trên, không bị khuất.
*/
.member-role-tag {
    position: absolute;
    top: 0;      /* THAY ĐỔI QUAN TRỌNG: Sát mép trên */
    left: 0;     /* THAY ĐỔI QUAN TRỌNG: Sát mép trái */
    z-index: 5;

    /* Style lại một chút cho đẹp ở vị trí mới */
    padding: 4px 12px;
    /* Bo tròn góc dưới bên phải để tạo cảm giác nó ôm vào góc khung */
    border-radius: 0 0 12px 0;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.4);
}

/*
 * BƯỚC 2: Đẩy nội dung chính (tên, avatar,...) xuống một chút
 * để không bị thẻ chức vụ vừa đặt ở trên che mất.
*/
.entry-content {
    padding-top: 15px;
}


/* --- Các màu nền cho chức vụ (Giữ nguyên) --- */
.role-tong-chu .member-role-tag { background-color: #F8E71C; color: #333; }
.role-pho-tong-chu .member-role-tag { background-color: #50E3C2; color: #333; }
.role-truong-lao .member-role-tag { background-color: #4A90E2; color: #fff; }
.ranking-entry:not(.role-tong-chu):not(.role-pho-tong-chu):not(.role-truong-lao) .member-role-tag {
    background-color: #888;
    color: #fff;
}
