@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ══════════════════════════════════════
   CSS VARIABLES — Design Tokens
══════════════════════════════════════ */
:root {
    --accent:        #6366f1;
    --accent-2:      #8b5cf6;
    --accent-light:  #a5b4fc;
    --accent-glow:   rgba(99, 102, 241, 0.25);
    --accent-glow-2: rgba(139, 92, 246, 0.2);

    --glass-bg:      rgba(255, 255, 255, 0.75);
    --glass-border:  rgba(255, 255, 255, 0.92);
    --glass-shadow:  0 8px 32px rgba(99, 102, 241, 0.08), 0 2px 8px rgba(0,0,0,0.04);

    --color-online:  #22c55e;
    --color-offline: #94a3b8;
    --color-busy:    #ef4444;
    --color-away:    #f97316;

    --text-primary:   #1e1b4b;
    --text-secondary: #64748b;
    --text-muted:     #94a3b8;
}

/* ══════════════════════════════════════
   GLOBAL
══════════════════════════════════════ */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ══════════════════════════════════════
   AURORA BACKGROUND
══════════════════════════════════════ */
.bg-gradient-msn {
    background-color: #f5f3ff;
    background-image:
        radial-gradient(ellipse 70% 55% at 15% 25%, rgba(167, 139, 250, 0.38) 0%, transparent 65%),
        radial-gradient(ellipse 55% 70% at 85% 15%, rgba(99, 102, 241, 0.28) 0%, transparent 65%),
        radial-gradient(ellipse 60% 45% at 60% 85%, rgba(196, 181, 253, 0.32) 0%, transparent 65%),
        radial-gradient(ellipse 50% 60% at 40% 50%, rgba(224, 231, 255, 0.55) 0%, transparent 65%);
    animation: aurora-shift 14s ease-in-out infinite alternate;
}

@keyframes aurora-shift {
    0% {
        background-image:
            radial-gradient(ellipse 70% 55% at 15% 25%, rgba(167, 139, 250, 0.38) 0%, transparent 65%),
            radial-gradient(ellipse 55% 70% at 85% 15%, rgba(99, 102, 241, 0.28) 0%, transparent 65%),
            radial-gradient(ellipse 60% 45% at 60% 85%, rgba(196, 181, 253, 0.32) 0%, transparent 65%),
            radial-gradient(ellipse 50% 60% at 40% 50%, rgba(224, 231, 255, 0.55) 0%, transparent 65%);
    }
    50% {
        background-image:
            radial-gradient(ellipse 75% 60% at 35% 15%, rgba(139, 92, 246, 0.3) 0%, transparent 65%),
            radial-gradient(ellipse 55% 75% at 75% 35%, rgba(129, 140, 248, 0.25) 0%, transparent 65%),
            radial-gradient(ellipse 65% 50% at 25% 75%, rgba(167, 139, 250, 0.35) 0%, transparent 65%),
            radial-gradient(ellipse 45% 65% at 80% 80%, rgba(199, 210, 254, 0.4) 0%, transparent 65%);
    }
    100% {
        background-image:
            radial-gradient(ellipse 70% 55% at 65% 30%, rgba(196, 181, 253, 0.32) 0%, transparent 65%),
            radial-gradient(ellipse 55% 70% at 20% 65%, rgba(99, 102, 241, 0.22) 0%, transparent 65%),
            radial-gradient(ellipse 65% 50% at 72% 65%, rgba(167, 139, 250, 0.28) 0%, transparent 65%),
            radial-gradient(ellipse 45% 60% at 50% 90%, rgba(224, 231, 255, 0.45) 0%, transparent 65%);
    }
}

/* ══════════════════════════════════════
   GLASS UTILITIES
══════════════════════════════════════ */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* ══════════════════════════════════════
   SIDEBAR (glass panel)
══════════════════════════════════════ */
.glass-panel {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(24px) saturate(170%);
    -webkit-backdrop-filter: blur(24px) saturate(170%);
    border-right: 1px solid rgba(199, 210, 254, 0.45);
}

/* ══════════════════════════════════════
   MSN HEADER (agora glass header)
══════════════════════════════════════ */
.msn-header {
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(238,242,255,0.88) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(199, 210, 254, 0.4);
    box-shadow: 0 2px 16px rgba(99, 102, 241, 0.06);
    position: relative;
    padding-top: calc(12px + env(safe-area-inset-top)) !important;
}

/* ══════════════════════════════════════
   CONTACT ITEMS
══════════════════════════════════════ */
.contact-group {
    padding: 4px 0;
    background: transparent;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 12px;
    margin: 1px 6px;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact-item:hover {
    background: rgba(99, 102, 241, 0.08);
    transform: translateX(2px);
}

/* ══════════════════════════════════════
   TABS
══════════════════════════════════════ */
.msn-tabs {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(199, 210, 254, 0.4);
    position: relative;
    padding: 0 4px;
}

.msn-tab {
    position: relative;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    margin: 4px 2px;
    overflow: hidden;
}

.msn-tab:hover {
    background: rgba(99, 102, 241, 0.08);
}

.msn-tab.active {
    background: rgba(99, 102, 241, 0.11) !important;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.18), inset 0 1px 0 rgba(255,255,255,0.6);
}

.msn-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 15%;
    right: 15%;
    height: 2.5px;
    border-radius: 3px 3px 0 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#tab-btn-contacts.active::after { background: linear-gradient(90deg, #6366f1, #8b5cf6); box-shadow: 0 -2px 12px rgba(99, 102, 241, 0.6); }
#tab-btn-groups.active::after   { background: linear-gradient(90deg, #22c55e, #10b981); box-shadow: 0 -2px 12px rgba(34, 197, 94, 0.6); }
#tab-btn-search.active::after   { background: linear-gradient(90deg, #f59e0b, #f97316); box-shadow: 0 -2px 12px rgba(245, 158, 11, 0.6); }
#tab-btn-status.active::after   { background: linear-gradient(90deg, #a855f7, #6366f1); box-shadow: 0 -2px 12px rgba(168, 85, 247, 0.6); }

.msn-tab.active svg {
    transform: scale(1.2) translateY(-1px);
    filter: drop-shadow(0 2px 6px rgba(99,102,241,0.3));
}

.msn-tab svg {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.msn-tab span {
    transition: all 0.22s ease;
}

.msn-tab.active span {
    font-weight: 700;
    letter-spacing: 0.3px;
}

/* Tab click ripple */
.tab-click-anim::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 20px; height: 20px;
    background: rgba(99, 102, 241, 0.18);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: tab-shockwave 0.9s cubic-bezier(0.1, 0.9, 0.1, 1) forwards;
    pointer-events: none;
    z-index: 5;
}

@keyframes tab-shockwave {
    0%   { width: 0; height: 0; opacity: 0.9; transform: translate(-50%, -50%) scale(0.1); }
    100% { width: 220px; height: 220px; opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* ══════════════════════════════════════
   CHAT BUBBLES
══════════════════════════════════════ */
.bubble-sent {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3), 0 1px 4px rgba(0,0,0,0.08);
}

.bubble-received {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(199, 210, 254, 0.5);
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.08), 0 1px 3px rgba(0,0,0,0.05);
    color: var(--text-primary);
}

/* ══════════════════════════════════════
   MESSAGE INPUT BAR
══════════════════════════════════════ */
.input-bar-glass {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(199, 210, 254, 0.35);
    box-shadow: 0 -4px 24px rgba(99, 102, 241, 0.05);
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
}

.msg-input-pill {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    transition: border-color 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    resize: none;
    overflow: hidden;
    color: #111827;
    box-shadow: none;
}

.msg-input-pill:focus {
    background: #ffffff;
    border-color: #9ca3af;
    box-shadow: none;
    outline: none;
}

.btn-send-glass {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-send-glass:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.52);
}

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

/* ══════════════════════════════════════
   SCROLLBAR
══════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.2); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.4); }

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

/* ══════════════════════════════════════
   TOAST ANIMATIONS
══════════════════════════════════════ */
.toast-enter { transform: translateY(100%); opacity: 0; }
.toast-enter-active {
    transform: translateY(0); opacity: 1;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast-exit { transform: translateY(0); opacity: 1; }
.toast-exit-active {
    transform: translateX(110%); opacity: 0;
    transition: all 0.3s ease-in;
}

/* ══════════════════════════════════════
   BUDDY ICON
══════════════════════════════════════ */
.buddy-icon {
    width: 24px; height: 24px;
    filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.15));
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* ══════════════════════════════════════
   ACCENT BUTTON
══════════════════════════════════════ */
.btn-accent {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    font-weight: 600;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    border: none;
    cursor: pointer;
}

.btn-accent::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.18) 0%, transparent 55%);
    pointer-events: none;
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(99, 102, 241, 0.48);
}

.btn-accent:active {
    transform: scale(0.97);
}

/* ══════════════════════════════════════
   LOGIN CARD FLIP ANIMATION
══════════════════════════════════════ */
@keyframes floatIn {
    0%   { opacity: 0; transform: translateY(28px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ══════════════════════════════════════
   GLASS INPUT (login / forms)
══════════════════════════════════════ */
.glass-input {
    background: rgba(248, 248, 255, 0.8);
    border: 1.5px solid rgba(199, 210, 254, 0.6);
    border-radius: 12px;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.glass-input:focus {
    background: rgba(255, 255, 255, 0.98);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
    outline: none;
}

/* ══════════════════════════════════════
   APP CONTAINER (Responsive Fullscreen)
   ══════════════════════════════════════ */
#app-container {
    background: rgba(248, 247, 255, 0.6);
    border: none;
    box-shadow: none;
}

@media (min-width: 768px) {
    #app-container {
        border: 1px solid rgba(199, 210, 254, 0.35);
        box-shadow: 0 32px 80px rgba(99, 102, 241, 0.12), 0 8px 32px rgba(0, 0, 0, 0.06);
    }
}

/* Textura do Cabecalho */
.msn-header {
    background-color: rgba(255, 255, 255, 0.85);
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 10px 10px;
    backdrop-filter: blur(8px);
}

/* Animacao de Chat - WhatsApp Style */
@media (max-width: 767px) {
    .chat-slide-in {
        transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        will-change: transform;
        transform: translate3d(100%, 0, 0);
    }
    .chat-slide-in.chat-open {
        transform: translate3d(0, 0, 0);
    }
}
@media (min-width: 768px) {
    .chat-slide-in {
        transition: opacity 0.2s ease-out;
        opacity: 0;
    }
    .chat-slide-in.chat-open {
        opacity: 1;
    }
}

#chat-area {
    will-change: transform;
    backface-visibility: hidden;
}

/* APK MODE (Native Chat Bar) */
.apk-mode #chat-input-area {
    display: none !important;
}
.apk-mode #chat-messages {
    padding-bottom: 20px !important;
}

/* ══════════════════════════════════════
   CUSTOM LOADING SPINNER (iOS/Spoke Style)
   ══════════════════════════════════════ */
.modern-loader {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ios-spinner {
    position: relative;
    width: 32px;
    height: 32px;
}

.ios-spinner div {
    width: 3px;
    height: 8px;
    background: var(--accent, #6366f1);
    position: absolute;
    left: 14.5px;
    top: 0;
    border-radius: 2px;
    transform-origin: 1.5px 16px;
    animation: ios-fade 0.8s linear infinite;
}

.ios-spinner .bar1 { transform: rotate(0deg); animation-delay: 0s; }
.ios-spinner .bar2 { transform: rotate(30deg); animation-delay: -0.7333s; }
.ios-spinner .bar3 { transform: rotate(60deg); animation-delay: -0.6667s; }
.ios-spinner .bar4 { transform: rotate(90deg); animation-delay: -0.6s; }
.ios-spinner .bar5 { transform: rotate(120deg); animation-delay: -0.5333s; }
.ios-spinner .bar6 { transform: rotate(150deg); animation-delay: -0.4667s; }
.ios-spinner .bar7 { transform: rotate(180deg); animation-delay: -0.4s; }
.ios-spinner .bar8 { transform: rotate(210deg); animation-delay: -0.3333s; }
.ios-spinner .bar9 { transform: rotate(240deg); animation-delay: -0.2667s; }
.ios-spinner .bar10 { transform: rotate(270deg); animation-delay: -0.2s; }
.ios-spinner .bar11 { transform: rotate(300deg); animation-delay: -0.1333s; }
.ios-spinner .bar12 { transform: rotate(330deg); animation-delay: -0.0667s; }

@keyframes ios-fade {
    from { opacity: 1; }
    to { opacity: 0.15; }
}

/* APK Mode Transparent overlay for group settings */
body.apk-mode.apk-group-settings-open {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
}
body.apk-mode.apk-group-settings-open #app-container {
    display: none !important;
}

