/* ====== CHAT STYLES ====== */

.chats-screen {
    padding: 60px 0 80px;
    height: 100vh;
    overflow-y: auto;
}

.chats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px 12px;
}

.chats-tabs {
    display: flex;
    gap: 8px;
    padding: 0 20px 12px;
    border-bottom: 1px solid var(--border-light);
}

.chats-tab {
    padding: 6px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-weight: 700;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.chats-tab.active {
    background: var(--primary);
    color: white;
}

.chats-list {
    padding: 8px 12px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.chat-item:hover {
    background: var(--bg-card);
}

.chat-avatar-wrap {
    position: relative;
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.group-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--primary);
    color: white;
    font-size: 12px;
    padding: 2px;
    border-radius: 50%;
    border: 2px solid white;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.chat-name {
    font-weight: 700;
    font-size: 14px;
}

.chat-time {
    font-size: 11px;
    color: var(--text-light);
}

.chat-preview-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-preview {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.chat-unread {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 800;
    min-width: 20px;
    text-align: center;
}

.fab-create-group {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-gradient);
    color: white;
    border: none;
    font-size: 22px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 50;
}

/* Chat Conversation */
.chat-conversation {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 400;
    display: flex;
    flex-direction: column;
}

.chat-conv-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.chat-conv-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
}

.chat-conv-info {
    flex: 1;
}

.chat-conv-name {
    font-weight: 800;
    font-size: 15px;
}

.chat-conv-status {
    font-size: 11px;
    color: var(--accent);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.date-separator {
    text-align: center;
    padding: 8px;
    color: var(--text-light);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.msg-item {
    display: flex;
    gap: 8px;
    max-width: 80%;
    animation: slideUp 0.2s ease;
}

.msg-me {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    align-self: flex-end;
    cursor: pointer;
}

.msg-avatar-space {
    width: 32px;
}

.msg-bubble {
    padding: 8px 14px;
    border-radius: 18px;
    background: white;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.msg-me .msg-bubble {
    background: var(--bg-gradient);
    color: white;
}

.msg-sender-name {
    font-size: 11px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 2px;
}

.msg-text {
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.msg-text a {
    color: inherit;
    text-decoration: underline;
}

.msg-image {
    max-width: 240px;
    max-height: 320px;
    border-radius: var(--radius-md);
    display: block;
}

.msg-sticker .msg-bubble {
    background: transparent;
    box-shadow: none;
    padding: 4px;
}

.sticker-content {
    font-size: 80px;
    animation: stickerBounce 1s ease infinite;
    line-height: 1;
}

@keyframes stickerBounce {
    0%, 100% { transform: scale(1) rotate(0); }
    25% { transform: scale(1.1) rotate(-5deg); }
    75% { transform: scale(1.1) rotate(5deg); }
}

.animated-sticker {
    animation: stickerBounce 1s ease infinite;
    display: inline-block;
}

.msg-gift-card {
    text-align: center;
    padding: 8px;
    background: linear-gradient(135deg, #FFD700, #FF6B9D);
    color: white;
    border-radius: var(--radius-md);
    min-width: 120px;
}

.msg-gift-emoji {
    font-size: 40px;
}

.msg-gift-coins {
    font-weight: 900;
    margin-top: 4px;
}

.msg-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.msg-reactions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.msg-reaction {
    background: white;
    border: 1px solid var(--border-medium);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 12px;
    box-shadow: var(--shadow-sm);
}

.reaction-picker {
    position: fixed;
    background: white;
    border-radius: var(--radius-full);
    padding: 8px;
    display: flex;
    gap: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 500;
}

.reaction-picker button {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.reaction-picker button:hover {
    background: var(--pastel-pink-light);
    transform: scale(1.3);
}

.chat-typing {
    padding: 4px 16px;
}

.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0));
    background: white;
    border-top: 1px solid var(--border-light);
}

#chat-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

/* Stickers Panel */
.stickers-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: 500;
    box-shadow: var(--shadow-lg);
    max-height: 50vh;
    display: flex;
    flex-direction: column;
}

.stickers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.stickers-header button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

.stickers-grid {
    flex: 1;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    overflow-y: auto;
}

.sticker-btn {
    aspect-ratio: 1;
    background: var(--bg-primary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-size: 30px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.sticker-btn:hover {
    border-color: var(--primary);
    background: var(--pastel-pink-light);
}

.stickers-tabs {
    display: flex;
    padding: 8px 12px;
    gap: 4px;
    border-top: 1px solid var(--border-light);
}

.stickers-tabs button {
    padding: 6px 12px;
    background: none;
    border: none;
    font-family: inherit;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-full);
    font-size: 12px;
}

.stickers-tabs button.active {
    background: var(--primary);
    color: white;
}

/* New Chat / Group */
.new-chat-modal, .create-group-modal, .group-info-modal {
    background: white;
    padding: 30px 24px;
    border-radius: var(--radius-xl);
    max-width: 400px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.user-search-results {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 12px;
}

.hint {
    text-align: center;
    color: var(--text-light);
    padding: 20px;
    font-size: 13px;
}

.friend-selector {
    max-height: 250px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
}

.friend-select-item {
    padding: 8px;
}

.friend-select-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.friend-select-item input:checked + label {
    background: var(--pastel-pink-light);
}

.friend-select-item img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.group-info-header {
    text-align: center;
    padding: 20px 0;
}

.group-info-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 12px;
}

.member-count {
    display: inline-block;
    background: var(--pastel-pink-light);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    margin-top: 8px;
}

.group-actions {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}

.group-actions button {
    flex: 1;
}

.group-members-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.admin-tag {
    background: #EF4444;
    color: white;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: 9px;
    font-weight: 800;
    margin-left: 4px;
}

/* Notifications */
.notif-toast {
    position: fixed;
    top: 68px;
    right: 12px;
    background: white;
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 700;
    max-width: 320px;
    cursor: pointer;
    transition: opacity 0.5s;
    border-left: 4px solid var(--primary);
}

.notif-toast img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.notif-toast-title {
    font-size: 13px;
    font-weight: 700;
}

.notif-toast-time {
    font-size: 11px;
    color: var(--text-light);
}

.notif-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 80vh;
    background: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: var(--z-modal);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.notif-header button {
    background: none;
    border: none;
    color: var(--primary);
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    font-size: 13px;
}

.notif-header .modal-close {
    color: var(--text-primary);
}

.notif-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.notif-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

.notif-item:hover {
    background: var(--bg-primary);
}

.notif-item.unread {
    background: var(--pastel-pink-light);
}

.notif-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.notif-body {
    flex: 1;
}

.notif-message {
    font-size: 13px;
    font-weight: 600;
}

.notif-time {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
}

.notif-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

/* AI Assistant */
.ai-assistant-btn {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 90;
    animation: aiPulse 2s ease infinite;
}

@keyframes aiPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 157, 0.4); }
    50% { box-shadow: 0 0 20px 10px rgba(255, 107, 157, 0.2); }
}

.ai-chat-modal {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 380px;
    max-width: 100%;
    height: 500px;
    max-height: 80vh;
    background: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: 500;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.ai-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    background: var(--bg-gradient);
    color: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.ai-name {
    font-weight: 800;
}

.ai-status {
    font-size: 11px;
    opacity: 0.9;
}

.ai-chat-header .modal-close {
    color: white;
    background: rgba(255, 255, 255, 0.2);
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-msg {
    padding: 10px 14px;
    border-radius: 18px;
    max-width: 80%;
    font-size: 14px;
}

.ai-bot {
    background: var(--bg-primary);
    align-self: flex-start;
}

.ai-user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
}

.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.ai-suggestions button {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.ai-suggestions button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.ai-typing {
    padding: 8px 14px;
}

.ai-input-bar {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border-light);
}

.ai-input-bar input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    font-family: inherit;
    outline: none;
}

.ai-input-bar button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-gradient);
    color: white;
    border: none;
    cursor: pointer;
}

/* AI Summary Modal */
.ai-summary-modal, .ai-clips-modal {
    background: white;
    padding: 30px 24px;
    border-radius: var(--radius-xl);
    max-width: 400px;
    width: 100%;
    position: relative;
}

.ai-stat {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}

.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.keyword-tag {
    background: var(--pastel-purple-light);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    color: var(--secondary-dark, #6B21A8);
}

.clips-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.clip-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
}

.clip-time {
    font-weight: 800;
    color: var(--primary);
}

.clip-reason {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Leaderboard */
.leaderboard-full-modal {
    background: white;
    padding: 24px;
    border-radius: var(--radius-xl);
    max-width: 450px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.lb-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin: 16px 0;
}

.lb-tab {
    padding: 10px;
    background: var(--bg-primary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
}

.lb-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.lb-time-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.lb-time-tab {
    flex: 1;
    padding: 6px;
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
}

.lb-time-tab.active {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

.lb-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.lb-item:hover {
    transform: translateX(4px);
}

.lb-top1 {
    background: linear-gradient(90deg, #FFD700, rgba(255, 215, 0, 0.1));
    border: 2px solid #FFD700;
}

.lb-top2 {
    background: linear-gradient(90deg, #C0C0C0, rgba(192, 192, 192, 0.1));
    border: 2px solid #C0C0C0;
}

.lb-top3 {
    background: linear-gradient(90deg, #CD7F32, rgba(205, 127, 50, 0.1));
    border: 2px solid #CD7F32;
}

.lb-rank {
    font-size: 20px;
    font-weight: 900;
    min-width: 40px;
    text-align: center;
}

.lb-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.lb-user-info {
    flex: 1;
}

.lb-name {
    font-weight: 800;
    font-size: 14px;
}

.lb-level {
    font-size: 11px;
    color: var(--text-secondary);
}

.lb-value {
    font-weight: 900;
    font-size: 15px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Mystery Box */
.mystery-box-modal {
    background: white;
    padding: 30px 24px;
    border-radius: var(--radius-xl);
    max-width: 400px;
    width: 100%;
    text-align: center;
    position: relative;
}

.mystery-box-container {
    padding: 40px 20px;
}

.mystery-box-3d {
    font-size: 100px;
    display: inline-block;
    transition: transform 0.5s ease;
    animation: mysteryFloat 2s ease infinite;
}

@keyframes mysteryFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.mystery-box-3d.open {
    animation: boxOpen 0.5s ease forwards;
}

@keyframes boxOpen {
    to { transform: scale(1.5) rotate(360deg); opacity: 0; }
}

.mystery-box-price {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-weight: 700;
}

.mystery-rewards {
    margin-bottom: 20px;
}

.rewards-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.reward-list-mini {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.reward-mini {
    background: var(--pastel-purple-light);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
}

.reward-reveal-modal {
    background: linear-gradient(135deg, #FFD700, #FF6B9D);
    padding: 40px 30px;
    border-radius: var(--radius-xl);
    text-align: center;
    color: white;
    max-width: 350px;
}

.reveal-header {
    font-size: 18px;
    letter-spacing: 3px;
    margin-bottom: 20px;
    font-weight: 900;
}

.reveal-icon {
    font-size: 100px;
    margin-bottom: 20px;
}

.reveal-desc {
    font-size: 24px;
    font-weight: 900;
    margin-bottom: 24px;
}

.reward-reveal-modal .btn-primary {
    background: white;
    color: var(--primary);
}

/* Event Banner */
.event-banner {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    color: white;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 13px;
    z-index: 150;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
}

.event-banner button {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: 900;
}