/* CSS Variables for Dark/Light Mode */
:root {
    --bg-primary: #161823;
    --bg-secondary: #20222e;
    --bg-tertiary: #2a2c39;
    --bg-hover: #2a2c3a;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-tertiary: #6b7280;
    --border-primary: rgba(162, 158, 181, .1);
    --border-secondary: rgba(162, 158, 181, .1);
    --accent-primary: #54b0e4;
    --accent-secondary: #82c4e8;
}

.dark {
    --bg-primary: #f9fafb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f4f6f9;
    --bg-hover: #e5e7eb;
    --text-primary: #414a5e;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-primary: rgba(162, 158, 181, .1);
    --border-secondary: rgba(162, 158, 181, .1);
    --accent-primary: #54b0e4;
    --accent-secondary: #60a5fa;
}

/* Base Styles */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.bg-app { background-color: var(--bg-primary) !important; }
.dark\:bg-navy-900 { background-color: var(--bg-primary) !important; }

/* Background Colors */
.bg-\[\#20222e\],
.bg-\[\#20222e\]\/50,
.bg-\[\#20222e\]\/75,
.bg-\[\#20222e\]\/\[0\.6\],
.hover\:bg-\[\#20222e\]:hover,
aside,
.sidebar-nav-item.active,
.chat-bar,
.flex-none.bg-\[\#20222e\],
.tracker-card,
.rounded-lg.font-bold.bg-\[\#54b0e4\]\/25,
footer.bg-\[\#20222e\]\/50 {
    background-color: var(--bg-secondary) !important;
}

/* Hover States */
.hover\:bg-\[\#2a2c3a\]:hover,
.hover\:bg-\[\#2a2c3a\]\/80:hover,
.hover\:bg-\[\#2a2c39\]:hover {
    background-color: var(--bg-hover) !important;
}

/* Text Colors */
.text-\[\#a1a1aa\],
.text-candy-floss-text,
.text-app-gray-300,
.text-gray-400 {
    color: var(--text-secondary) !important;
}

/* Borders */
.border-\[\#20222e\],
.border-\[\#2a2c39\],
.border-truffle-border {
    border-color: var(--border-primary) !important;
}

.border-\[\#373b4e\],
.border-app-gray-700 {
    border-color: var(--border-secondary) !important;
}

/* Message Skeleton Animation */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.message-skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 0%, var(--bg-tertiary) 50%, var(--bg-secondary) 100%) !important;
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
}

/* Reply Icon */
.reply-icon {
    background: var(--bg-tertiary) !important;
    color: var(--text-secondary) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 8px;
    right: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.reply-icon:hover {
    color: var(--text-primary) !important;
    background: rgba(84, 176, 228, 0.2);
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    position: relative;
    width: 50px;
    height: 24px;
    background-color: var(--bg-tertiary);
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border: 1px solid var(--border-primary);
}

.dark-mode-toggle.active {
    background-color: var(--accent-primary);
}

.dark-mode-toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.dark-mode-toggle.active .dark-mode-toggle-slider {
    transform: translateX(26px);
}

/* Modals */
.absolute.z-10.mt-2.origin-top-right {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-primary) !important;
}

/* Form Inputs */
.form-input,
textarea {
    color: var(--text-primary) !important;
    border-color: var(--border-primary) !important;
}

/* Scrollbar */
.cc-hy::-webkit-scrollbar {
    width: 6px;
}

.cc-hy::-webkit-scrollbar-track {
    background: var(--bg-tertiary) !important;
}

.cc-hy::-webkit-scrollbar-thumb {
    background: var(--accent-primary) !important;
    border-radius: 3px;
    transition: background 0.2s;
}

.cc-hy::-webkit-scrollbar-thumb:hover {
    background: rgba(84, 176, 228, 0.8);
}

/* Icons in Light Mode */
.dark .fa-solid,
.dark .fa-brands,
.dark svg {
    color: currentColor;
}

/* Colored Elements */
.dark .bg-\[\#54b0e4\],
.dark .bg-\[\#54b0e4\]\/25 {
    background-color: var(--accent-primary) !important;
    opacity: 0.9;
}

.dark .text-\[\#54b0e4\] {
    color: var(--accent-primary) !important;
}

/* Sidebar Styles */
.sidebar-container {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapsed {
    width: 70px;
}

.sidebar-expanded {
    width: 240px;
}

.sidebar-nav-item {
    position: relative;
    transition: all 0.2s ease;
    overflow: hidden;
}

.sidebar-nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(84, 176, 228, 0.1), transparent);
    transition: left 0.5s ease;
}

.sidebar-nav-item:hover::before {
    left: 100%;
}

.sidebar-nav-item:hover {
    background: rgba(84, 176, 228, 0.1);
    border-color: rgba(84, 176, 228, 0.3);
}

.sidebar-nav-item.active {
    background: rgba(84, 176, 228, 0.15);
    border-color: #54b0e4;
}

.sidebar-nav-item.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #54b0e4;
}

.sidebar-icon {
    transition: all 0.3s ease;
}

.sidebar-collapsed .sidebar-icon {
    margin: 0 auto;
}

.sidebar-nav-item:hover .sidebar-icon {
    transform: scale(1.1);
}

/* Sidebar Tooltip */
.sidebar-tooltip {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 10px;
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    border: 1px solid var(--border-primary) !important;
}

.sidebar-collapsed .sidebar-nav-item:hover .sidebar-tooltip {
    opacity: 1;
}

/* Mobile Sidebar Overlay */
.mobile-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 49;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mobile-sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    position: relative;
    overflow: hidden;
}

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

.mobile-menu-btn:active::after {
    width: 300px;
    height: 300px;
}

/* Header Rewards Button */
.header-rewards-btn {
    outline: 2px solid rgba(42, 44, 57, 0.6);
    transition: all 0.2s ease;
}

.header-rewards-btn:hover {
    outline-color: transparent;
    background: linear-gradient(135deg, rgba(255, 183, 0, 0.1) 0%, rgba(255, 220, 71, 0.1) 100%);
}

/* Notification Badge */
@keyframes pulse-badge {
    0% {
        box-shadow: 0 0 0 0 rgba(84, 176, 228, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(84, 176, 228, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(84, 176, 228, 0);
    }
}

.notification-badge {
    animation: pulse-badge 2s infinite;
}

/* Chat Bar Styles */
@media (max-width: 768px) {
    .chat-bar {
        bottom: 0 !important;
        height: 100vh !important;
        max-height: 100vh !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100% !important;
        border-radius: 0 !important;
        z-index: 100 !important;
    }
    
    #chat-Container {
        max-height: calc(100vh - 160px) !important;
    }
    
    .chat-bar .flex-none.p-3 {
        padding-bottom: 1rem !important;
        position: sticky;
        bottom: 0;
        z-index: 52;
    }
}

@media (min-width: 769px) {
    .chat-bar {
        position: fixed !important;
        top: 70px !important;
        right: 0 !important;
        width: 380px !important;
        height: calc(100vh - 70px) !important;
        z-index: 90 !important;
        border-radius: 0 !important;
        overflow: hidden !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    
    .chat-bar.closed {
        transform: translateX(100%) !important;
    }
    
    #chat-Container {
        max-height: calc(100% - 140px) !important;
    }
}

/* Content Shrink */
.content-shrink {
    margin-right: 380px !important;
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

@media (max-width: 768px) {
    .content-shrink {
        margin-right: 0 !important;
    }
}

/* SPA Content Container */
.spa-content-container {
    min-height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
}

/* Message Container */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.message-animate {
    animation: slideInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.message-container {
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left center;
}

.message-container:hover {
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.message-container:hover .reply-icon {
    opacity: 1;
    transform: scale(1);
}

/* Mention Styles */
.mention {
    background-color: #54afe4;
    color: #ffffff;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
    animation: fadeIn 0.5s ease-out;
}

/* Avatar Wrapper */
.avatar-wrapper {
    width: 40px;
    flex-shrink: 0;
    position: relative;
}

/* Profile Level */
.pro-level {
    position: absolute;
    bottom: -10px;
    left: 55%;
    transform: translateX(-50%);
    font-size: 10px;
    background: rgba(22, 24, 35, 0.95);
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
    z-index: 10;
    border: 1px solid rgba(84, 176, 228, 0.3);
}

/* Hover Username */
.hover-username {
    transition: all 0.2s ease;
    position: relative;
}

.hover-username:hover {
    text-shadow: 0 0 8px currentColor;
}

/* Send Button */
.send-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.send-btn:hover {
    transform: translateY(-1px);
}

.send-btn:active {
    transform: scale(0.95);
}

/* Hide Scrollbar */
.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* System Toast */
.system-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #34495e;
    color: white;
    padding: 15px 20px;
    border-radius: 5px;
    z-index: 9998;
}

[data-inactive="1"] {
    transition: opacity 0.3s;
}

/* App Activity Profile */
.app-act-pro {
    border: solid 2px #54b0e4;
    border-radius: 50%;
}

.pro-lvl- {
    position: absolute;
    bottom: -8px;
    background: #2b3442;
    padding: 1px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

/* Intercom Popover */
.intercom-composer-popover {
    z-index: 2147483003;
    position: absolute;
    bottom: 50px;
    right: calc(50% - 135px);
    background-color: #fff;
    border-radius: 13px;
    transition-duration: 200ms;
    transition-delay: 0ms;
    transform-style: flat;
    transform-origin: 50% 50% 0;
    opacity: 0;
    transition: all 0.2s linear;
    display: none;
}

.intercom-composer-popover.active {
    display: block;
    opacity: 1;
    bottom: 80px;
}

.intercom-emoji-picker {
    width: 250px;
    height: 260px;
    background-color: #263345;
    border-radius: 10px;
}

.intercom-composer-popover-body {
    position: absolute;
    top: 0px;
    left: 0;
    right: 0;
    bottom: 5px;
    padding: 0 20px;
    overflow-y: scroll;
}

.intercom-emoji-picker-group {
    margin: 10px -5px;
}

.intercom-emoji-picker-group-title {
    color: #b8c3ca;
    font-weight: 400;
    font-size: 13px;
    margin: 5px;
}

.intercom-emoji-picker-emoji {
    padding: 5px;
    width: 25px;
    line-height: 25px;
    display: inline-table;
    text-align: center;
    cursor: pointer;
    vertical-align: middle;
    font-size: 20px;
    transition: transform 60ms ease-out;
    font-family: Apple Color Emoji, Segoe UI Emoji, NotoColorEmoji, Segoe UI Symbol, Android Emoji, EmojiSymbols;
}

.intercom-composer-popover-caret {
    position: absolute;
    bottom: -8px;
    right: 0;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #263345;
    left: 20px;
}

/* Leaderboard Container */
.leaderboard-container {
    position: relative;
    z-index: 1;
}

#cubeCanvas {
    position: absolute;
    width: 150vw;
    z-index: 0;
    pointer-events: none;
}

/* SPA Preloader Bar */
#spa-preloader-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: linear-gradient(90deg, #54b0e4 0%, #82c4e8 50%, #54b0e4 100%);
    background: -webkit-linear-gradient(90deg, #54b0e4 0%, #82c4e8 50%, #54b0e4 100%);
    background-size: 200% 100%;
    -webkit-animation: shimmer 1.5s linear infinite;
    animation: shimmer 1.5s linear infinite;
    z-index: 99999;
    -webkit-transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(84, 176, 228, 0.5);
}

@-webkit-keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

[x-cloak] { display: none !important; }

.spa-fade {
    opacity: 0;
    visibility: hidden;
    -webkit-transition: opacity 0.2s ease-out, visibility 0s linear 0.2s;
    transition: opacity 0.2s ease-out, visibility 0s linear 0.2s;
}

.spa-fade.loaded {
    opacity: 1;
    visibility: visible;
    -webkit-transition: opacity 0.2s ease-out, visibility 0s linear 0s;
    transition: opacity 0.2s ease-out, visibility 0s linear 0s;
}

#spa-content.spa-loading [x-show],
#spa-content.spa-loading [x-if],
#spa-content.spa-loading [x-for],
#spa-content:not(.loaded) [x-show],
#spa-content:not(.loaded) [x-if],
#spa-content:not(.loaded) [x-for] {
    display: none !important;
}

.spa-prefetching::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(84, 176, 228, 0.3);
    -webkit-transform: scaleX(0);
    transform: scaleX(0);
    -webkit-transform-origin: left;
    transform-origin: left;
    -webkit-transition: transform 0.3s ease;
    transition: transform 0.3s ease;
}

/* Modal System */
[id^="withdrawModalBackdrop-"] {
    position: fixed !important;
    z-index: 999999 !important;
}

[id^="withdrawModalBox-"] {
    position: relative !important;
    z-index: 1000000 !important;
}

#spa-content,
.main-content,
main {
    transform: none !important;
}

.overlay-fade-in {
    animation: fadeIn 0.3s forwards !important;
}

.modal-fade-in {
    animation: scaleIn 0.3s forwards !important;
}

.overlay-fade-out {
    animation: fadeOut 0.2s forwards !important;
}

.modal-fade-out {
    animation: scaleOut 0.2s forwards !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Toastify Overrides */
.toastify {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    left: auto !important;
    bottom: auto !important;
    max-width: 350px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4),
                0 6px 12px rgba(0, 0, 0, 0.3),
                0 0 40px rgba(84, 176, 228, 0.15) !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    animation: slideInRight 0.3s ease-out !important;
    transform-origin: right center !important;
    z-index: 99999 !important;
}

.toastify ~ .toastify {
    margin-top: 15px !important;
}

.toastify::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: linear-gradient(90deg, #54b0e4 0%, #3b82f6 100%);
    animation: toastProgress 3s linear forwards;
    transform-origin: left;
}

.toastify[style*="dc2626"]::after,
.toastify[style*="ef4444"]::after {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%) !important;
}

.toastify:hover {
    transform: translateX(-5px) !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5),
                0 8px 16px rgba(0, 0, 0, 0.4),
                0 0 50px rgba(84, 176, 228, 0.2) !important;
}

.toastify:hover::after {
    animation-play-state: paused !important;
}

.toastify .toast-close {
    opacity: 0.6 !important;
    font-size: 20px !important;
    line-height: 20px !important;
    padding: 0 0 0 15px !important;
    color: #fff !important;
    font-weight: normal !important;
    text-shadow: none !important;
}

.toastify .toast-close:hover {
    opacity: 1 !important;
}

@keyframes slideInRight {
    from {
        transform: translateX(110%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.toastify-top {
    top: 20px !important;
}

.toastify-right {
    right: 20px !important;
}

.toastify-text {
    color: #fff !important;
    font-weight: 500 !important;
    letter-spacing: 0.3px !important;
}

.toastify.on {
    opacity: 1 !important;
}

.toastify[style*="--toast-duration"] {
    --duration: var(--toast-duration, 3000ms);
}

.toastify[style*="--toast-duration"]::after {
    animation-duration: var(--duration) !important;
}

.chat-lock-overlay {
    position: absolute;
    top: 60px; 
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(22, 24, 36, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.chat-lock-content {
    text-align: center;
    padding: 2rem;
}

.lock-icon {
    font-size: 48px;
    color: #54b0e4;
    margin-bottom: 1rem;
}

.lock-title {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.5rem;
}

.lock-subtitle {
    font-size: 14px;
    color: #a1a1aa;
    margin-bottom: 1.5rem;
}

.lock-button {
    background: #54b0e4;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.lock-button:hover {
    background: #4aa0d4;
}

.chat-locked .cc-hy {
    filter: blur(3px);
}

.chat-locked .flex-none:last-child {
    opacity: 0.5;
    pointer-events: none;
}