/* css/royal_overrides.css */
/* TITAH BAGINDA: Standardisasi Lapisan & Scrollbar (ANTI-LAG & ANTI-TUMPANG TINDIH) */

:root {
    /* Menyatukan kembali skala Z-index yang sempat berantakan */
    --z-royal-close: 250000;
}

/* 1. Standardisasi Tombol Close (Royal Style) */
.close-btn {
    position: absolute !important;
    top: clamp(15px, 2.5vh, 25px) !important;
    right: clamp(12px, 2.5vh, 22px) !important;
    width: 44px !important;
    height: 44px !important;
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%) !important;
    color: #fff !important;
    border: 2px solid #d4af37 !important;
    border-radius: 50% !important;
    font-size: 1.4rem !important;
    cursor: pointer !important;
    z-index: var(--z-royal-close) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5), inset 0 0 10px rgba(0,0,0,0.3) !important;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5) !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.close-btn:hover {
    transform: scale(1.15) rotate(90deg) !important;
    background: #e74c3c !important;
    border-color: #fff !important;
    box-shadow: 0 0 25px rgba(231, 76, 60, 0.6) !important;
}

/* 2. Anti-Double Scroll Solution */
#page-content {
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Utilitas untuk region yang boleh scroll (Gunakan ini di modul mana pun) */
.scroll-royal, 
.chat-messages-container,
.mail-list-container,
.report-list-container {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    padding-right: 5px; /* Kompensasi untuk scrollbar */
}

/* Custom Scrollbar Premium */
.scroll-royal::-webkit-scrollbar {
    width: 6px;
}

.scroll-royal::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.scroll-royal::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #d4af37, #b8860b);
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.3);
}

.scroll-royal::-webkit-scrollbar-thumb:hover {
    background: #f1c40f;
}

/* 3. Perbaikan Z-Index High-Level */
body::after {
    z-index: 2000 !important; /* Di atas objek peta, tapi di bawah HUD (6000) & Modal (150rb) */
}

/* 4. PREMIUM BROADCAST & TOAST SYSTEM */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 20000000 !important; /* TITAH BAGINDA: Harus di atas modal (10jt) */
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.royal-toast {
    background: rgba(15, 12, 8, 0.95);
    border: 1px solid gold;
    border-left: 5px solid gold;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 250px;
    animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: auto;
}

.royal-toast.error { border-left-color: #ff4757; }
.royal-toast.success { border-left-color: #2ecc71; }
.royal-toast.warning { border-left-color: #ffa502; }

@keyframes toastIn {
    0% { transform: translateX(120%) scale(0.8); opacity: 0; }
    100% { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes toastOut {
    0% { transform: translateX(0) scale(1); opacity: 1; }
    100% { transform: translateX(120%) scale(0.8); opacity: 0; }
}

.broadcast-overlay {
    position: fixed;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999998 !important;
    width: 90%;
    max-width: 700px;
    background: linear-gradient(90deg, transparent 0%, rgba(15, 10, 5, 0.98) 20%, rgba(15, 10, 5, 0.98) 80%, transparent 100%);
    padding: 30px 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    border-top: 2.5px solid transparent;
    border-bottom: 2.5px solid transparent;
    border-image: linear-gradient(90deg, transparent, #d4af37, #f1c40f, #d4af37, transparent) 1;
    animation: broadcastIn 0.8s cubic-bezier(0.19, 1, 0.22, 1) forwards;
    box-shadow: 0 0 100px rgba(0,0,0,0.8);
}

.broadcast-overlay .announcer {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: #d4af37;
    letter-spacing: 5px;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
    font-weight: 900;
}

.broadcast-overlay .msg {
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    color: #fff;
    text-align: center;
    text-shadow: 0 2px 15px rgba(0,0,0,1), 0 0 5px #d4af37;
    font-weight: 800;
    line-height: 1.4;
}

@keyframes broadcastIn {
    0% { transform: translate(-50%, -150%) scaleX(0.1); opacity: 0; }
    100% { transform: translate(-50%, -50%) scaleX(1); opacity: 1; }
}

@keyframes broadcastOut {
    0% { transform: translate(-50%, -50%) scaleX(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scaleX(0.1); opacity: 0; }
}

/* 5. ROYAL BUTTON SYSTEM (Standardized) */
.btn-royal {
    position: relative;
    padding: 10px 20px;
    background: linear-gradient(135deg, #d4af37, #b8860b);
    color: #000;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    font-family: 'Cinzel', serif;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.btn-royal:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(212, 175, 55, 0.4);
    filter: brightness(1.2);
}

.btn-royal:active {
    transform: translateY(2px);
}

.btn-royal::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease-out, height 0.3s ease-out;
}

/* 6. ROYAL OVERLAY & MODAL (Z-INDEX HARDENING) */
#page-overlay, 
#confirm-overlay,
.royal-overlay {
    z-index: 10000000 !important; /* Harus lebih tinggi dari vignette 9.9jt di style.css */
}

/* Fix Vignette in style.css which has 9999999 */
/* MINI MODE HARDENING */
.page-window.mini-mode {
    width: 92% !important;
    max-width: 500px !important;
    height: auto !important;
    max-height: 85vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border-radius: 25px !important;
    background: var(--royal-glass);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.page-window.mini-mode #page-content {
    flex: 1 !important;
    overflow-y: auto !important;
    display: flex !important;
    flex-direction: column !important;
}

/* 7. REUSABLE ROYAL OBSIDIAN CLASSES */
.royal-card-glass {
    background: rgba(15, 15, 15, 0.7) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(212, 175, 55, 0.2) !important;
    border-radius: 18px !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), inset 0 0 15px rgba(212, 175, 55, 0.05) !important;
    transition: all 0.3s ease !important;
}

.royal-card-glass:hover {
    border-color: rgba(212, 175, 55, 0.5) !important;
    box-shadow: 0 15px 40px rgba(0,0,0,0.7), 0 0 20px rgba(212, 175, 55, 0.1) !important;
    transform: translateY(-2px);
}

.royal-tab-nav {
    display: flex !important;
    background: rgba(0,0,0,0.5) !important;
    border-bottom: 2px solid rgba(212, 175, 55, 0.3) !important;
    padding: 2px !important;
    gap: 2px !important;
}

.royal-tab-item {
    flex: 1 !important;
    padding: 14px 5px !important;
    text-align: center !important;
    font-size: 0.75rem !important;
    font-weight: 900 !important;
    font-family: 'Outfit', sans-serif !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    color: #666 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    border-bottom: 3px solid transparent !important;
}

.royal-tab-item.active {
    color: gold !important;
    border-bottom-color: gold !important;
    background: linear-gradient(to top, rgba(212, 175, 55, 0.1), transparent) !important;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5) !important;
}

.royal-text-gold {
    background: linear-gradient(180deg, #fff 0%, #d4af37 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: 'Cinzel', serif;
    font-weight: 900;
}
