:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #141933;
    --bg-tertiary: #1a1f3a;
    --bg-message-sent: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-message-received: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: #a8b2d1;
    --text-muted: #64748b;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    position: relative;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 30%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(118, 75, 162, 0.1) 0%, transparent 50%);
    pointer-events: none;
    animation: smokeEffect 20s ease-in-out infinite;
    z-index: 0;
}

@keyframes smokeEffect {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.6;
    }
}

.screen {
    position: relative;
    z-index: 1;
    height: 100vh;
    width: 100%;
}

.hidden {
    display: none !important;
}

/* Install Prompt */
.install-prompt {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100px);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.install-content {
    background: rgba(20, 25, 51, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-lg);
}

.install-icon {
    font-size: 32px;
}

.install-text h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.install-text p {
    font-size: 13px;
    color: var(--text-secondary);
}

.btn-install {
    background: var(--bg-message-sent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-install:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-dismiss {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0 8px;
    transition: color 0.2s;
}

.btn-dismiss:hover {
    color: var(--text-primary);
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 20px;
}

.login-header {
    text-align: center;
    margin-bottom: 48px;
    animation: fadeInUp 0.6s ease-out;
}

.logo {
    font-size: 80px;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header h1 {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    font-size: 18px;
    color: var(--text-secondary);
}

.login-header .branding {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 8px;
    font-style: italic;
}

.creator-credit {
    margin-top: 12px;
    font-size: 13px;
    opacity: 0.7;
}

.login-content {
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.btn-google {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.btn-google:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.login-footer {
    margin-top: 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    animation: fadeInUp 0.6s ease-out 0.4s both;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(20, 25, 51, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--accent-primary);
    position: relative;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
    background: var(--text-muted);
}

.user-avatar.online::after {
    background: var(--success);
}

.user-info h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.user-status {
    font-size: 13px;
    color: var(--text-muted);
}

.user-status.online {
    color: var(--success);
}

.header-right {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Menu Dropdown */
.menu-dropdown {
    position: absolute;
    top: 70px;
    right: 20px;
    background: rgba(20, 25, 51, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 100;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Search Panel */
.search-panel {
    position: absolute;
    top: 73px;
    left: 0;
    right: 0;
    background: rgba(20, 25, 51, 0.98);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: 50;
    animation: slideDown 0.3s ease-out;
}

.search-input-container {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
}

.search-input-container input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
}

.search-input-container input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-primary);
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
    padding: 0 20px 16px;
}

.search-result-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.search-result-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.search-highlight {
    background: rgba(102, 126, 234, 0.3);
    color: var(--text-primary);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Messages Container */
.messages-container {
    height: calc(100vh - 73px - 70px);
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.load-more {
    text-align: center;
    padding: 12px;
}

.load-more button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.load-more button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubble */
.message {
    display: flex;
    gap: 8px;
    animation: messageSlideIn 0.3s ease-out;
    position: relative;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    flex-direction: row-reverse;
}

.message-content {
    max-width: 70%;
    position: relative;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s;
}

.message-bubble:active {
    transform: scale(0.98);
}

.message.received .message-bubble {
    background: var(--bg-message-received);
    backdrop-filter: blur(10px);
    border-bottom-left-radius: 4px;
}

.message.sent .message-bubble {
    background: var(--bg-message-sent);
    border-bottom-right-radius: 4px;
}

.message-reply {
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 3px solid var(--accent-primary);
    font-size: 13px;
    color: var(--text-secondary);
}

.message-text {
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 4px;
}

.message-media {
    max-width: 100%;
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
}

.message-media img {
    max-width: 100%;
    border-radius: 12px;
    display: block;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
}

.message.received .message-meta {
    color: var(--text-muted);
}

.message-status {
    display: flex;
    align-items: center;
}

.message-status svg {
    width: 14px;
    height: 14px;
}

.message-status.read svg {
    color: #10b981;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-message-received);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: var(--shadow-sm);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typingDot 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {

    0%,
    60%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    30% {
        opacity: 1;
        transform: scale(1);
    }
}

.typing-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Reply Preview */
.reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(102, 126, 234, 0.1);
    border-top: 1px solid var(--border-color);
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.reply-content {
    flex: 1;
}

.reply-header {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-primary);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

#replyText {
    font-size: 14px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 90%;
}

/* Input Area */
.input-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(20, 25, 51, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
}

#messageInput {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
}

#messageInput:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-primary);
}

#messageInput:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-message-sent);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* GIF Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

#gifSearch {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    margin-bottom: 16px;
}

#gifSearch:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-primary);
}

.gif-results {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    padding: 4px;
}

.gif-results::-webkit-scrollbar {
    width: 6px;
}

.gif-results::-webkit-scrollbar-track {
    background: transparent;
}

.gif-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.gif-item {
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    aspect-ratio: 1;
}

.gif-item:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.gif-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gif-hint {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 14px;
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    z-index: 100;
    animation: slideUp 0.3s ease-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    .login-header h1 {
        font-size: 32px;
    }

    .logo {
        font-size: 60px;
    }

    .message-content {
        max-width: 85%;
    }

    .gif-results {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* Edit Message Styles */
.edited-indicator {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
    margin: 0 4px;
}

.edit-msg-btn {
    display: block;
    margin-top: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-msg-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.edit-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--accent-primary);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    margin-bottom: 8px;
}

.edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.save-edit,
.cancel-edit {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.save-edit {
    background: var(--bg-message-sent);
    color: white;
}

.save-edit:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.cancel-edit {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.cancel-edit:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Reaction Styles */
.reaction-picker {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: rgba(20, 25, 51, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

.reaction-emoji {
    font-size: 28px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.reaction-emoji:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.2);
}

.message-reactions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.reaction-badge:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.reaction-badge.reacted {
    background: rgba(102, 126, 234, 0.2);
    border-color: var(--accent-primary);
}

/* File Card Styles */
.file-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 8px;
}

.file-icon {
    font-size: 32px;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.file-download {
    padding: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    color: var(--text-primary);
    text-decoration: none;
}

.file-download:hover {
    background: var(--accent-primary);
    transform: translateY(-2px);
}

/* Voice Message Styles */
.voice-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 8px;
}

.voice-play {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.voice-play:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.voice-waveform {
    flex: 1;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Smooth transitions */
* {
    transition: background 0.2s ease-out, color 0.2s ease-out, border-color 0.2s ease-out;
}

button,
input,
.message-bubble,
.icon-btn {
    transition: all 0.2s ease-out;
}