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

/* Dark Theme (Default) */
:root {
    /* Brand colors */
    --primary-color: #3995BF;
    --primary-hover: #2D7798;
    --secondary-color: #57F287;
    --danger-color: #ED4245;
    --warning-color: #FEE75C;
    
    /* Background colors */
    --bg-primary: #36393F;
    --bg-secondary: #2F3136;
    --bg-tertiary: #202225;
    --bg-message: #40444B;
    --bg-attachment: #51565F;
    --bg-video: #3F3737;
    --message-sent-start: #39464D;
    --message-sent-end: #39464D;
    --message-received-start: #40444B;
    --message-received-end: #40444B;
    --row-selected: #323234;
    --item-active: #51565F;
    --border-color: #202225;
    --bg-translucent: rgba(0, 0, 0, 0.2);
    
    /* Text colors */
    --text-primary: #EDEDED;
    --text-secondary: #B9BBBE;
    --text-tertiary: #A3A6AA;
    --text-muted: #72767D;
    --text-on-accent: #EDEDED;
    
    /* Status colors */
    --online-color: #3BA55D;
    --offline-color: #747F8D;
    --typing-color: #57F287;
    
    /* Gradients */
    --gradient-login-start: #3D4270;
    --gradient-login-end: #2D3250;
    --gradient-video-start: #1A1A2E;
    --gradient-video-end: #16213E;
    
    /* Shadows */
    --shadow-dark: rgba(0, 0, 0, 0.3);
    --shadow-light: rgba(0, 0, 0, 0.2);
    --shadow-primary: rgba(57, 149, 191, 0.3);
    
    /* Overlays */
    --overlay-light: rgba(255, 255, 255, 0.2);
    --overlay-light-subtle: rgba(255, 255, 255, 0.1);
    --overlay-light-border: rgba(255, 255, 255, 0.5);
    --overlay-dark: rgba(0, 0, 0, 0.6);
    --overlay-dark-hover: rgba(0, 0, 0, 0.8);
    --overlay-dark-badge: rgba(0, 0, 0, 0.7);
    --overlay-modal: rgba(0, 0, 0, 0.8);
    --overlay-video-modal: rgba(0, 0, 0, 0.9);
    --reply-highlight: rgba(57, 149, 191, 0.2);
    
    /* Attachment menu icon colors */
    --icon-photo: #4CAF50;
    --icon-video: #E91E63;
    --icon-audio: #FF9800;
    --icon-document: #2196F3;
    
    /* Element colors */
    --logo-tint: var(--text-primary);
    --bg-header: var(--bg-tertiary);
    --bg-sidebar: var(--bg-secondary);
    --bg-chat-header: var(--bg-secondary);
    --bg-chat: var(--bg-primary);
    --bg-input-area: var(--bg-secondary);
    --bg-message-input: var(--bg-message);
    --bg-avatar-start: #4B5058;
    --bg-avatar-end: #3F434A;
    --text-avatar: var(--text-secondary);
}

/* Light Theme */
[data-theme="light"] {
    /* Brand colors */
    --primary-color: #03A9F4;
    --primary-hover: #0288D1;
    --secondary-color: #4CAF50;
    --danger-color: #F44336;
    --warning-color: #FFC107;
    
    /* Background colors */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --bg-tertiary: #E0E0E0;
    --bg-message: #EEEEEE;
    --bg-attachment: #E8E8E8;
    --bg-video: #E0E0E0;
    --message-sent-start: #E3F2FD;
    --message-sent-end: #C2E5F4;
    --message-received-start: #F5F5F5;
    --message-received-end: #EAEAEA;
    --row-selected: #E9F1F5;
    --item-active: #E9F1F5;
    --border-color: #E0E0E0;
    --bg-translucent: rgba(0, 0, 0, 0.2);
    
    /* Text colors */
    --text-primary: #212121;
    --text-secondary: #616161;
    --text-tertiary: #757575;
    --text-muted: #9E9E9E;
    --text-on-accent: #FFFFFF;
    
    /* Status colors */
    --online-color: #4CAF50;
    --offline-color: #9E9E9E;
    --typing-color: #4CAF50;
    
    /* Gradients */
    --gradient-login-start: #E3F2FD;
    --gradient-login-end: #BBDEFB;
    --gradient-video-start: #E0E0E0;
    --gradient-video-end: #BDBDBD;
    
    /* Shadows */
    --shadow-dark: rgba(0, 0, 0, 0.15);
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-primary: rgba(3, 169, 244, 0.3);
    
    /* Overlays */
    --overlay-light: rgba(0, 0, 0, 0.08);
    --overlay-light-subtle: rgba(0, 0, 0, 0.04);
    --overlay-light-border: rgba(0, 0, 0, 0.2);
    --overlay-dark: rgba(0, 0, 0, 0.5);
    --overlay-dark-hover: rgba(0, 0, 0, 0.7);
    --overlay-dark-badge: rgba(0, 0, 0, 0.6);
    --overlay-modal: rgba(0, 0, 0, 0.5);
    --overlay-video-modal: rgba(0, 0, 0, 0.8);
    --reply-highlight: rgba(3, 169, 244, 0.2);
    
    /* Attachment menu icon colors */
    --icon-photo: #4CAF50;
    --icon-video: #E91E63;
    --icon-audio: #FF9800;
    --icon-document: #2196F3;
    
    /* Element colors */
    --logo-tint: var(--primary-color);
    --bg-header: var(--bg-primary);
    --bg-sidebar: var(--bg-primary);
    --bg-chat-header: #E6DBCC;
    --bg-chat: #EEE7DD;
    --bg-input-area: #E6DBCC;
    --bg-message-input: var(--bg-primary);
    --bg-avatar-start: #DAE6EC;
    --bg-avatar-end: #C3D8E3;
    --text-avatar: var(--text-secondary);
}

body {
    font-family: 'Twemoji Country Flags', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    height: -webkit-fill-available;
    overflow: hidden;
}

/* Login Screen */
.login-container {
    display: none;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    height: -webkit-fill-available;
    background: linear-gradient(135deg, var(--gradient-login-start) 0%, var(--gradient-login-end) 100%);
}

.login-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px var(--shadow-dark);
    width: 90%;
    max-width: 400px;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo-container {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.login-box .logo-container {
    margin-bottom: 30px;
}

.logo-image {
    display: block;
    height: 24px;
    width: auto;
    fill: var(--logo-tint);
}

.login-box .logo-image {
    height: 32px;
}

.logo-subtitle {
    display: flex;
    width: 100%;
    font-size: 8px;
    text-align: center;
    flex-flow: row nowrap;
    justify-content: space-between;
    color: var(--logo-tint);
    margin-top: 2px;
}

.login-box .logo-subtitle {
    font-size: 11px;
}

.input-group {
    width: 100%;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: var(--bg-message);
    color: var(--text-primary);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: var(--text-on-accent);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--shadow-primary);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.error-message {
    color: var(--danger-color);
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
}

.signup-info {
    font-size: 13px;
    color: var(--text-muted);
    margin: 24px 0 16px;
    line-height: 1.5;
}

.app-store-badges {
    width: 100%;
    display: flex;
    justify-content: space-between;
}

.store-badge {
    height: 40px;
    width: auto;
    transition: opacity 0.2s ease;
}

.store-badge:hover {
    opacity: 0.8;
}

.social-divider {
    width: 100%;
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.social-divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: var(--border-color);
}

.social-divider span {
    background: var(--bg-secondary);
    padding: 0 15px;
    position: relative;
    color: var(--text-muted);
    font-size: 14px;
}

.social-btn {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-message);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.social-btn:hover {
    border-color: var(--primary-color);
    background: var(--bg-primary);
}

.social-btn i {
    font-size: 20px;
}

.google-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    background-image: url('./assets/google.svg');
    background-size: contain;
    background-repeat: no-repeat;
}

/* Messenger Layout */
.messenger-container {
    display: none;
    height: 100vh;
    height: 100dvh;
    height: -webkit-fill-available;
    flex-direction: column;
    background: var(--bg-primary);
}

.messenger-header {
    background: var(--bg-header);
    color: var(--text-primary);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 10px var(--shadow-light);
    border-bottom: 1px solid var(--border-color);
}

/* Theme Switch */
.theme-switch {
    display: flex;
    align-items: center;
    background: var(--bg-message);
    border-radius: 20px;
    padding: 4px;
}

.theme-switch-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-switch-btn.active {
    background: var(--primary-color);
    color: var(--text-on-accent);
}

.theme-switch-btn:hover:not(.active) {
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    color: var(--text-on-accent);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.header-btn:hover {
    background: var(--primary-hover);
}

.messenger-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.search-box {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.search-box:focus {
    outline: none;
    background: var(--bg-message);
}

.search-box::placeholder {
    color: var(--text-muted);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.chat-item:hover {
    background: var(--bg-message);
}

.chat-item.active {
    background: var(--item-active);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-avatar-start) 0%, var(--bg-avatar-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-avatar);
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

/*.chat-item.active .chat-avatar {
    background: var(--overlay-light);
}*/

.chat-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

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

.chat-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.chat-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-meta {
    text-align: right;
    font-size: 12px;
    color: var(--text-tertiary);
}

.unread-badge {
    background: var(--danger-color);
    color: var(--text-on-accent);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
    display: inline-block;
}

/* Chat Window */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    min-height: 0;
    overflow: hidden;
}

.chat-header {
    background: var(--bg-chat-header);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-info {
    flex: 1;
}

.chat-header-name {
    font-weight: 600;
    color: var(--text-primary);
}

.chat-header-status {
    font-size: 12px;
    color: var(--text-secondary);
}

.messages-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 24px 20px;
    display: flex;
    flex-direction: column-reverse;
    gap: 15px;
}

/* Message row wrapper for context menu */
.message-row {
    width: 100%;
    padding: 4px 4px;
    border-radius: 8px;
}

.message-row.context-active {
    background: var(--row-selected);
}

.message-row.reply-highlight {
    animation: replyHighlight 1.5s ease;
}

@keyframes replyHighlight {
    0% { background-color: transparent; }
    50% { background-color: var(--reply-highlight); }
    100% { background-color: transparent; }
}

.message {
    display: flex;
    gap: 10px;
    max-width: 70%;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.message.received {
    margin-left: 0;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-avatar-start) 0%, var(--bg-avatar-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-avatar);
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message-content {
    flex-shrink: 1;
}

/* Date Separator */
.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0;
    position: relative;
}

.date-separator::before,
.date-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.date-separator span {
    padding: 4px 12px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin: 0 12px;
    white-space: nowrap;
}

.message-bubble {
    color: var(--text-primary);
    border-radius: 12px;
    box-shadow: 0 1px 2px var(--shadow-light);
    word-wrap: break-word;
}

.message-bubble.text {
    padding: 10px 14px;
}

.message-bubble.media {
    padding: 4px;
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, var(--message-sent-start) 0%, var(--message-sent-end) 100%);
    border-top-right-radius: 2px;
}

.message.received .message-bubble {
    background: linear-gradient(135deg, var(--message-received-start) 0%, var(--message-received-end) 100%);
    border-top-left-radius: 2px;
}

.message-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
    padding: 0 4px;
}

.message.sent .message-time {
    text-align: right;
}

.message-status {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
}

/* Block display is just a placeholder to make this class not empty */
.message-media {
    display: block;
}

.typing-indicator {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 13px;
    font-style: italic;
    z-index: 10;
}

/* Input Area */
.input-area {
    background: var(--bg-input-area);
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    align-items: center;
}

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

.attachment-btn:hover {
    background: var(--bg-message);
    color: var(--text-primary);
}

/* Attachment Menu */
.attachment-wrapper {
    position: relative;
}

.attachment-menu {
    position: absolute;
    bottom: 50px;
    left: 0;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-dark);
    padding: 8px 0;
    min-width: 160px;
    display: none;
    z-index: 100;
    border: 1px solid var(--border-color);
}

.attachment-menu.show {
    display: block;
    animation: fadeInUp 0.2s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.attachment-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    color: var(--text-primary);
    font-size: 14px;
}

.attachment-menu-item:hover {
    background: var(--bg-message);
}

.attachment-menu-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

/* Colored icons for each type */
.attachment-menu-item[data-type="photo"] i {
    color: var(--icon-photo);
}

.attachment-menu-item[data-type="video"] i {
    color: var(--icon-video);
}

.attachment-menu-item[data-type="audio"] i {
    color: var(--icon-audio);
}

.attachment-menu-item[data-type="document"] i {
    color: var(--icon-document);
}

.message-input-wrapper {
    flex: 1;
    position: relative;
}

.message-input {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    background: var(--bg-message-input);
    color: var(--text-primary);
}

.message-input:focus {
    outline: none;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    color: var(--text-on-accent);
    font-size: 16px;
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

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

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-modal);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.close-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--bg-message);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.user-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-item {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s;
    background: var(--bg-message);
    color: var(--text-primary);
}

.user-item:hover {
    border-color: var(--primary-color);
    background: var(--bg-primary);
}

.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 10;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .chat-window {
        width: 100%;
    }

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

/* SVG Icons */
.icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.hidden {
    display: none !important;
}

/* Media Preview Styles */
.message-media-container {
    min-width: 150px;
    min-height: 60px;
}

.media-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    color: var(--text-secondary);
    font-size: 13px;
}

.media-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--bg-message);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.media-error {
    padding: 12px;
    color: var(--danger-color);
    font-size: 13px;
}

/* Image Preview */
/* Relative position is for displaying the progress indicator */
.message-media.message-image {
    position: relative;
    max-width: 300px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
}

.message-media.message-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.2s;
}

.message-media.message-image img:hover {
    transform: scale(1.02);
}

/* Media Description */
.media-description {
    padding: 8px 4px 4px;
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.4;
    word-wrap: break-word;
}

/* Video Preview */
/* Relative position is for displaying the progress indicator */
.message-media.message-video {
    position: relative;
    max-width: 300px;
    border-radius: 12px;
    overflow: hidden;
}

.video-preview {
    position: relative;
    background: var(--bg-video);
    cursor: pointer;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.video-preview.no-preview {
    background: linear-gradient(135deg, var(--gradient-video-start) 0%, var(--gradient-video-end) 100%);
}

.video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: var(--overlay-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.video-preview:hover .video-play-button {
    background: var(--overlay-dark-hover);
    transform: translate(-50%, -50%) scale(1.1);
}

.video-play-button svg {
    width: 30px;
    height: 30px;
    margin-left: 4px;
}

.video-duration {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: var(--overlay-dark-badge);
    color: var(--text-on-accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Audio Player */
.message-media.message-audio {
    display: flex;
    align-items: center;
    gap: 4px;
}

.audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-attachment);
    border-radius: 12px;
    flex: 1;
    min-width: 0;
}

.audio-play-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-accent);
    flex-shrink: 0;
    transition: transform 0.2s, background 0.2s;
}

.audio-play-btn:hover {
    transform: scale(1.05);
    background: var(--primary-hover);
}

.audio-play-btn svg {
    width: 20px;
    height: 20px;
}

.audio-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.audio-waveform {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 24px;
}

.waveform-bar {
    width: 3px;
    background: var(--text-tertiary);
    border-radius: 1px;
    transition: background 0.1s;
}

.waveform-bar.active {
    background: var(--text-primary);
}

.audio-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* File Attachment */
.message-media.message-file {
    display: flex;
    align-items: center;
    gap: 4px;
}

.file-attachment {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-attachment);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    flex: 1;
    min-width: 0;
}

.file-attachment:hover {
    background: var(--overlay-light);
}

.file-attachment .file-icon {
    width: 44px;
    height: 44px;
    background: var(--primary-color);
    color: var(--text-on-accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

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

.file-attachment .file-name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* Video Modal */
.video-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-video-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.video-modal-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.video-modal-container video {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
}

.video-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: var(--text-on-accent);
    font-size: 32px;
    cursor: pointer;
    padding: 8px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.video-modal-close:hover {
    opacity: 1;
}

/* Reply Styles */
.reply-preview {
    display: none;
    background: var(--bg-tertiary);
    border-left: 3px solid var(--primary-color);
    padding: 10px 15px;
    margin: 0 20px 10px;
    border-radius: 0 8px 8px 0;
    position: relative;
}

.reply-preview.active {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reply-preview-content {
    flex: 1;
    min-width: 0;
}

.reply-preview-author {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 13px;
    margin-bottom: 2px;
}

.reply-preview-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
}

.reply-preview-close:hover {
    color: var(--text-primary);
}

/* Message Context Menu */
.context-menu {
    display: none;
    position: fixed;
    z-index: 10000;
    min-width: 150px;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow-dark);
    padding: 6px 0;
    overflow: hidden;
}

.context-menu.show {
    display: block;
    animation: contextMenuFadeIn 0.15s ease;
}

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

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
    transition: background 0.15s;
}

.context-menu-item:hover {
    background: var(--bg-message);
}

.context-menu-item i {
    width: 16px;
    color: var(--text-secondary);
}

.context-menu-item[data-action="delete"] {
    color: var(--danger-color);
}

.context-menu-item[data-action="delete"] i {
    color: var(--danger-color);
}

/* Reply quote in message */
.message-reply-quote {
    background: var(--overlay-light-subtle);
    border-left: 2px solid var(--primary-color);
    padding: 8px 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
}

.message.sent .message-reply-quote {
    border-left-color: var(--overlay-light-border);
}

.message-reply-author {
    font-weight: 600;
    font-size: 12px;
    color: var(--primary-color);
    margin-bottom: 2px;
}

.message.sent .message-reply-author {
    color: var(--text-primary);
}

.message-reply-text {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.message-bubble {
    position: relative;
}

/* Upload Progress Indicator */
.upload-progress {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-translucent);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    z-index: 10;
}

.upload-progress-ring {
    position: absolute;
    width: 100%;
    height: 100%;
}

.upload-progress-ring circle {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.upload-progress-ring .progress-bg {
    stroke: var(--overlay-light);
}

.upload-progress-ring .progress-bar {
    stroke: var(--primary-color);
    transition: stroke-dashoffset 0.3s ease;
}

/* Percentage label in center */
.upload-progress-percent {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-on-accent);
    z-index: 1;
}

/* Phase icon in bottom-right corner */
.upload-progress-icon {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--primary-color);
    z-index: 2;
    box-shadow: 0 1px 3px var(--shadow-dark);
    overflow: hidden;
}

/* Processing animation - rotating arrows */
.upload-progress.processing .upload-progress-icon i {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Uploading animation - bouncing up arrow */
.upload-progress.uploading .upload-progress-icon i {
    animation: moveUp 1s linear infinite;
}

@keyframes moveUp {
    from { transform: translateY(16px); }
    to { transform: translateY(-16px); }
}

/* Progress indicator positioning */
.message-media.message-image .upload-progress,
.message-media.message-video .upload-progress {
    position: absolute;
    bottom: 8px;
    right: 8px;
}

.message-media.message-audio .upload-progress,
.message-media.message-file .upload-progress {
    position: relative;
    flex-shrink: 0;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-message);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive Styles */
@media (max-width: 768px) {
    .messenger-body {
        position: relative;
    }
    
    .sidebar {
        position: absolute;
        width: 100%;
        height: 100%;
        z-index: 100;
        transition: transform 0.3s ease;
    }
    
    .sidebar.hidden {
        transform: translateX(-100%);
    }
    
    .chat-window {
        position: absolute;
        width: 100%;
        height: 100%;
    }
    
    .chat-header .back-btn {
        display: flex;
    }
    
    .message {
        max-width: 85%;
    }
    
    .header-btn span {
        display: none;
    }
    
    .header-btn {
        padding: 8px 12px;
    }
}

/* Back button - hidden by default on desktop */
.chat-header .back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    margin-right: 8px;
    transition: all 0.2s;
}

.chat-header .back-btn:hover {
    background: var(--bg-message);
    color: var(--text-primary);
}
