@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* =========================================
   VARIABLES & RESET
   ========================================= */
:root {
    --vh: 1vh;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --accent-gradient: linear-gradient(135deg, #FF6F91 0%, #FF9671 100%);
    --incoming-bubble: rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    /* Chat specific body styles that are safe for others */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Might affect scrolling on Auth pages? No, Auth pages use flex center min-h-screen */
}

/* Fix for Auth pages scrolling if overflow is hidden globally */
body.auth-page {
    overflow: auto;
    display: block;
    /* or flex center */
}

/* Actually, let's keep body generic and move specific layout to specific classes if needed. 
   But Chat needs body height fixed. 
   Auth pages use 'min-h-screen'. 
   Let's keep the overflow:hidden for Chat (default) and override for Auth? 
   Or better: Apply .chat-body to body in chat.html? 
   No, let's stick to the provided styles but merge carefully.
   Chat body: height: calc(var(--vh) * 100); display: flex; flex-direction: column; overflow: hidden;
   Auth body: min-height: 100vh; (already in :root/body generic)
   
   I will add a class .chat-layout to body in chat.html if needed, but for now let's prioritize Chat since it's the main app.
   Actually, Auth pages have their own classes in HTML: class="flex items-center justify-center min-h-screen p-4"
   So adding overflow:hidden to body might break scrolling on small screens for Auth.
   
   Let's use a specific class for Chat body.
*/

/* =========================================
   UTILITIES
   ========================================= */
.glass,
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Animations */
@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-15px);
    }
}

.floating {
    animation: float 6s ease-in-out infinite;
}

.delay-100 {
    animation-delay: 1s;
}

.delay-300 {
    animation-delay: 3s;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s infinite;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   AUTH PAGES (Login/Register)
   ========================================= */
@keyframes pulse-glow {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.8;
    }
}

.background-image {
    background:
        radial-gradient(circle at 15% 50%, rgba(76, 29, 149, 0.4) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(255, 111, 145, 0.25) 0%, transparent 50%),
        linear-gradient(135deg, #1a1c2c 0%, #2d3748 100%);
    position: relative;
    overflow: hidden;
}

.background-image::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: 1;
}

.background-image::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.2) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    z-index: 0;
    animation: pulse-glow 8s infinite ease-in-out;
}

.input-field {
    transition: all 0.3s ease;
}

.input-field:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 111, 145, 0.2);
}

.login-button {
    background: var(--accent-gradient);
    transition: all 0.3s ease;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 124, 124, 0.4);
}

.feature-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: all 0.3s ease;
}

.feature-card:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-4px);
}

.chat-bubble {
    background: #ffffff40;
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 12px 16px;
    font-size: 0.9rem;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    display: inline-block;
}

/* =========================================
   ADMIN DASHBOARD
   ========================================= */
.tab-active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 111, 145, 0.3);
    border: none;
}

.dot-online {
    width: 10px;
    height: 10px;
    background: #00fa9a;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 10px #00fa9a;
    animation: pulse 2s infinite;
}

.dot-offline {
    width: 10px;
    height: 10px;
    background: #e53e3e;
    border-radius: 50%;
    display: inline-block;
    opacity: 0.5;
}

.card-hover:hover {
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

/* =========================================
   CHAT INTERFACE LAYOUT
   ========================================= */
header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 50;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(26, 28, 44, 0.8);
    backdrop-filter: blur(10px);
}

main {
    flex: 1;
    /* height: calc((var(--vh) * 100) - 70px); Remove fixed calc */
    display: flex;
    overflow: hidden;
    position: relative;
    width: 100%;
}

aside {
    width: 300px;
    border-right: 1px solid var(--glass-border);
    overflow-y: auto;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

aside.show {
    transform: translateX(0);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 70px 0 0 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 49;
}

.sidebar-overlay.show {
    display: block;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    position: relative;
    overflow: hidden;
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 24px;
    scroll-behavior: smooth;
    min-height: 0;
}

/* =========================================
   MESSAGES
   ========================================= */
.message-row {
    display: flex;
    flex-direction: column;
    width: fit-content;
    max-width: 75%;
    animation: fadeIn 0.3s ease;
}

.message-row.me {
    margin-left: auto;
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 18px;
    border-radius: 18px;
    background: var(--incoming-bubble);
    color: var(--text-primary);
    word-break: break-word;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: 4px;
}

.message-row.me .message-bubble {
    background: var(--accent-gradient);
    color: white;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(255, 111, 145, 0.3);
}

.message-meta {
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.6;
    text-align: left;
    padding-left: 4px;
}

.message-row.me .message-meta {
    text-align: right;
    padding-right: 4px;
}

.message-bubble.private {
    background: rgba(139, 92, 246, 0.3);
    border: 1px solid rgba(139, 92, 246, 0.5);
}

.message-row.me .message-bubble.private {
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
}

/* =========================================
   INPUT AREA
   ========================================= */
#messageForm {
    background: rgba(26, 28, 44, 0.9);
    border-top: 1px solid var(--glass-border);
    padding: 20px 24px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    /* Safe area fix */
    display: flex;
    gap: 16px;
    align-items: center;
    backdrop-filter: blur(20px);
    position: relative;
    z-index: 40;
}

#messageInput {
    flex: 1;
    padding: 14px 20px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid transparent;
    outline: none;
    color: white;
    resize: none;
    font-size: 15px;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

#messageInput:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

.input-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    padding: 10px;
    cursor: pointer;
    transition: color 0.2s;
    border-radius: 50%;
}

.input-button:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

#sendButton {
    background: var(--accent-gradient);
    color: white;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(255, 111, 145, 0.4);
    transition: transform 0.2s;
}

#sendButton:hover {
    transform: scale(1.05);
}

/* =========================================
   COMPONENTS (User List, Emojis, Reply)
   ========================================= */
#emojiPicker {
    position: absolute;
    right: 24px;
    bottom: 90px;
    display: none;
    z-index: 999;
    box-shadow: var(--shadow-lg);
    border-radius: 12px;
    overflow: hidden;
}

#emojiPicker.show {
    display: block;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    transition: background 0.2s;
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-avatar {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.user-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.user-badge {
    font-size: 12px;
    color: #FF6F91;
    background: rgba(255, 111, 145, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

.online-indicator {
    width: 10px;
    height: 10px;
    background: #00fa9a;
    border-radius: 50%;
    box-shadow: 0 0 10px #00fa9a;
}

#replyIndicator {
    display: none;
    background: rgba(139, 92, 246, 0.2);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    font-size: 13px;
    color: #ddd;
    border-top: 1px solid rgba(139, 92, 246, 0.4);
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    z-index: 10;
    align-items: center;
    justify-content: space-between;
}

#replyIndicator.show {
    display: flex;
}

#replyIndicator span {
    font-weight: 600;
    color: #a78bfa;
    margin-left: 4px;
}

#closeReply {
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    font-size: 28px;
    padding: 0 12px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

#closeReply:hover,
#closeReply:active {
    color: #ffffff;
}

/* =========================================
   BROADCAST OVERLAY
   ========================================= */
#broadcastOverlay {
    z-index: 10000 !important;
}

/* Mobile */
@media (max-width: 900px) {
    aside {
        position: fixed;
        left: 0;
        top: 70px;
        width: 280px;
        transform: translateX(-100%);
        z-index: 100;
        background: #1a1c2c;
        border-right: 1px solid var(--glass-border);
    }

    #messageForm {
        padding: 12px 16px;
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
        gap: 10px;
    }

    #messageInput {
        padding: 10px 16px;
        font-size: 14px;
    }

    #sendButton {
        width: 40px;
        height: 40px;
        min-width: 40px;
        /* Prevent shrinking */
    }

    .input-button {
        padding: 8px;
        font-size: 20px;
    }
}