/* assets/css/style.css */

/* =========================================
   1. VARIABLES & THEME SETUP
   ========================================= */
:root {
    /* --- Light Theme Colors --- */
    --bg-color: #f0f2f5;
    --sidebar-bg: #ffffff;
    --chat-bg: #efe7dd;
    /* WhatsApp-like subtle pattern bg color */

    --text-primary: #111b21;
    --text-secondary: #667781;
    --text-muted: #8696a0;

    --accent-color: #00a884;
    /* WhatsApp Green */
    --accent-hover: #008f6f;
    --accent-text: #ffffff;

    --message-out: #d9fdd3;
    --message-in: #ffffff;

    --border-light: #e9edef;
    --border-color: #e9edef;
    --hover-bg: #f5f6f6;
    --modal-bg: #ffffff;
    --primary-color-light: rgba(0, 168, 132, 0.12);
    --message-bubble-bg: rgba(0, 0, 0, 0.05);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);

    /* --- Layout & Spacing --- */
    --sidebar-width: 380px;
    --header-height: 60px;
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;

    /* --- Transitions --- */
    --trans-fast: 0.2s ease;
    --trans-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Dark Theme Overrides --- */
[data-theme="dark"] {
    --bg-color: #0c1317;
    /* Very dark blue/grey */
    --sidebar-bg: #111b21;
    --chat-bg: #0b141a;

    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --text-muted: #667781;

    --accent-color: #00a884;
    --accent-hover: #02906f;

    --message-out: #005c4b;
    --message-in: #202c33;

    --border-light: #2a3942;
    --border-color: #2a3942;
    --hover-bg: #202c33;
    --modal-bg: #222e35;
    --primary-color-light: rgba(0, 168, 132, 0.2);
    --message-bubble-bg: rgba(255, 255, 255, 0.08);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* =========================================
   2. GLOBAL RESET & TYPOGRAPHY
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll, handle inside containers */
    font-size: 15px;
    line-height: 1.5;
    transition: background-color var(--trans-normal), color var(--trans-normal);
}

button,
input,
textarea {
    font-family: inherit;
    border: none;
    outline: none;
    background: none;
}

input[dir="rtl"],
textarea[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

input[dir="ltr"],
textarea[dir="ltr"] {
    direction: ltr;
    text-align: left;
}

button {
    cursor: pointer;
}

a {
    text-decoration: none;
    color: var(--accent-color);
}

/* Custom Scrollbar (Webkit) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(134, 150, 160, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(134, 150, 160, 0.5);
}

/* =========================================
   3. APP LAYOUT STRUCTURE
   ========================================= */
.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* --- Sidebar (Left Panel) --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: transform var(--trans-normal), width var(--trans-normal);
}

/* --- Main Chat Area (Right Panel) --- */
.chat-main {
    flex: 1;
    background-color: var(--chat-bg);
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    /* Fixes flex child overflow issues */
}

/* =========================================
   4. SIDEBAR COMPONENTS
   ========================================= */

/* Header */
.sidebar__header {
    height: var(--header-height);
    padding: 10px 16px;
    background-color: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid transparent;
    /* Keeps layout stable */
}

.sidebar__actions {
    display: flex;
    gap: 12px;
}

/* Avatar Styles */
.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #ddd;
}

.avatar--sm {
    width: 40px;
    height: 40px;
}

.avatar--lg {
    width: 80px;
    height: 80px;
}

/* Status Indicator wrapper */
.user-profile-trigger {
    position: relative;
    cursor: pointer;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--sidebar-bg);
    background-color: #ccc;
}

.status-indicator--online {
    background-color: #25d366;
}

.status-indicator--offline {
    background-color: var(--text-muted);
}

/* Search Bar */
.search-bar-container {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    background-color: var(--sidebar-bg);
}

.search-input-wrapper {
    background-color: var(--bg-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 36px;
}

.search-icon {
    color: var(--text-secondary);
    min-width: 20px;
}

#searchInput {
    width: 100%;
    margin-left: 12px;
    color: var(--text-primary);
    font-size: 14px;
}

#searchInput::placeholder {
    color: var(--text-secondary);
}

/* Contact List */
.contact-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background-color var(--trans-fast);
}

.contact-item:hover {
    background-color: var(--hover-bg);
}

.contact-item.active {
    background-color: var(--hover-bg);
    /* Or a slightly darker tint */
}

.avatar-wrapper {
    position: relative;
    margin-right: 15px;
    flex-shrink: 0;
}

.contact-item__content {
    flex: 1;
    min-width: 0;
    /* Enables text truncation */
}

.contact-item__top,
.contact-item__bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.contact-item__bottom {
    margin-bottom: 0;
}

.contact-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-time {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 0;
}

.contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 28px;
}

.contact-pin-indicator {
    font-size: 10px;
    color: var(--accent-color);
    font-weight: 600;
    text-transform: uppercase;
}

.contact-pin-btn {
    padding: 4px;
    width: 24px;
    height: 24px;
}

.contact-pin-btn.is-pinned {
    color: var(--accent-color);
}

.contact-meta__stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.contact-preview {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sender-name {
    color: var(--text-primary);
    font-weight: 500;
}

.unread-badge {
    background-color: #e43c43;
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 0 6px;
    height: 20px;
    min-width: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    flex-shrink: 0;
}

.unread-badge--top {
    margin: 0;
}

.read-receipt {
    color: #53bdeb;
    /* Blue ticks */
}

/* =========================================
   5. CHAT AREA COMPONENTS
   ========================================= */

/* Placeholder (Empty State) */
.chat-placeholder {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: var(--border-light);
    /* Slightly different bg */
    border-bottom: 6px solid var(--accent-color);
    /* Visual flair */
}

.placeholder-content {
    max-width: 400px;
    padding: 30px;
}

.placeholder-icon {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.placeholder-content h2 {
    color: var(--text-primary);
    font-weight: 300;
    margin-bottom: 10px;
}

.placeholder-content p {
    color: var(--text-secondary);
}

/* Chat Interface */
.chat-interface {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* Chat Header */
.chat__header {
    height: var(--header-height);
    background-color: var(--sidebar-bg);
    /* Use sidebar color for header consistency */
    border-bottom: 1px solid var(--border-light);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 5;
    flex-shrink: 0;
}

.chat__header-info {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex: 1;
}

.back-button {
    display: none;
    /* Hidden on Desktop */
    margin-right: 8px;
    color: var(--text-primary);
}

.header-text {
    margin-left: 12px;
    display: flex;
    flex-direction: column;
}

.header-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.header-status {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat__header-actions {
    display: flex;
    gap: 16px;
}

/* Messages Container */
.chat__messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px clamp(12px, 2vw, 24px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
}

.chat-scroll-bottom {
    position: absolute;
    right: 18px;
    bottom: 84px;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: var(--sidebar-bg);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    z-index: 12;
}

.reply-target-highlight {
    box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.7);
}

.contact-suggestion-title,
.contact-section-title {
    padding: 8px 16px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
    background: var(--sidebar-bg);
}

.contact-item--suggestion .contact-preview {
    color: var(--accent-color);
    font-size: 13px;
}

/* Date Divider */
.date-divider {
    display: flex;
    justify-content: center;
    margin: 15px 0;
    position: sticky;
    top: 10px;
    z-index: 2;
}

.date-divider span {
    background-color: rgba(255, 255, 255, 0.2);
    /* Glassy look */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 500;
    /* In dark mode, adjust bg */
}

[data-theme="dark"] .date-divider span {
    background-color: rgba(32, 44, 51, 0.8);
}

/* Message Bubbles */
.message {
    display: flex;
    width: 100%;
    margin-bottom: 2px;
    overflow: hidden;
    min-width: 0;
    flex-shrink: 0;
}

.message--sent {
    justify-content: flex-end;
}

.message--received {
    justify-content: flex-start;
}

.message__bubble {
    max-width: min(86%, 560px);
    width: auto;
    padding: 6px 9px 8px 9px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    font-size: 14.2px;
    line-height: 19px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.message__bubble > * {
    max-width: 100%;
}

.message--received .message__bubble {
    background-color: var(--message-in);
    color: var(--text-primary);
    border-top-left-radius: 0;
}

.message--sent .message__bubble {
    background-color: var(--message-out);
    color: var(--text-primary);
    border-top-right-radius: 0;
}

.message__text {
    width: 100%;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.message__sender {
    width: 100%;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--accent-color);
    margin-bottom: 1px;
}

.message__caption {
    width: 100%;
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

/* Reply Message Styling */
.message__reply {
    border-left: 3px solid var(--accent-color);
    padding: 4px 8px;
    margin-bottom: 8px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    width: 100%;
}

.message__reply[data-reply-target-id] {
    cursor: pointer;
}

.reply-header {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.reply-header svg {
    margin-left: 4px;
}

.reply-jump-indicator {
    margin-left: auto;
    font-size: 12px;
    opacity: 0.7;
}

.reply-content {
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Forwarded Message Styling */
.message__forward {
    border-left: 3px solid #53bdeb;
    padding: 4px 8px;
    margin-bottom: 8px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    width: 100%;
}

.forward-header {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.forward-header svg {
    margin-right: 4px;
}

/* Media Message Styling */
.media-message,
.video-message {
    position: relative;
    width: min(100%, 340px);
    max-width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.05);
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    min-width: 0;
}

.media-message img {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 380px;
    display: block;
    object-fit: contain;
    border-radius: 8px;
}

.video-message video {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 360px;
    display: block;
    object-fit: contain;
    border-radius: 8px;
    background: #000;
}

.media-message--locked {
    background: linear-gradient(135deg, rgba(134, 150, 160, 0.25), rgba(134, 150, 160, 0.12));
    min-height: 170px;
    align-items: center;
    justify-content: center;
}

.media-blur-preview {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(16px) brightness(0.85);
    transform: scale(1.08);
}

.media-blur-preview--placeholder {
    background-image: linear-gradient(135deg, rgba(90, 104, 114, 0.32), rgba(90, 104, 114, 0.16));
    filter: none;
    transform: none;
}

.media-load-btn {
    position: relative;
    z-index: 1;
    border: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.75);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.video-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.video-message--circle {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    align-items: center;
    justify-content: center;
    position: relative;
}

.video-message--circle video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    cursor: pointer;
}

.video-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 10px;
}

.play-btn {
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    padding: 0;
}

.video-duration {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.message__meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
    align-self: flex-end;
    margin-left: auto;
    margin-top: 2px;
}

.message__status {
    width: 16px;
}

.message--sent .message__status {
    color: #53bdeb;
    /* Blue ticks */
}

/* Input Area */
.chat__input-area {
    min-height: 62px;
    background-color: var(--sidebar-bg);
    /* Use sidebar bg */
    padding: 8px 16px;
    display: flex;
    align-items: flex-end;
    /* Aligns items to bottom so textarea grows up */
    gap: 12px;
    z-index: 5;
    flex-shrink: 0;
}

.input-wrapper {
    flex: 1;
    background-color: var(--bg-color);
    border-radius: 8px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
}

#messageInput {
    width: 100%;
    max-height: 120px;
    /* Limits growth */
    resize: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 20px;
    overflow-y: auto;
}

#messageInput::placeholder {
    color: var(--text-secondary);
}

/* Icons/Buttons Generic */
.btn-icon {
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 50%;
    transition: background-color var(--trans-fast), color var(--trans-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: rgba(134, 150, 160, 0.1);
    color: var(--text-primary);
}

/* =========================================
   6. MODALS & FLOATING ELEMENTS
   ========================================= */

/* Theme Toggle Floating Button */
.theme-toggle-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    background-color: var(--sidebar-bg);
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    z-index: 100;
    transition: transform var(--trans-fast);
}

.theme-toggle-btn:hover {
    transform: scale(1.1);
}

/* Context Menu */
.context-menu {
    position: fixed;
    background-color: var(--modal-bg);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    width: 196px;
    overflow: hidden;
    display: block;
    backdrop-filter: blur(6px);
}

.context-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.context-menu li {
    padding: 11px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: var(--text-primary);
}

.context-menu li:hover {
    background-color: var(--hover-bg);
}

.context-menu li svg {
    min-width: 16px;
}

/* Attachment Options */
.attachment-options {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--sidebar-bg);
    border-radius: 12px;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 300px;
    box-shadow: var(--shadow-md);
    z-index: 100;
    display: grid;
}

.attachment-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: var(--text-primary);
}

.attachment-option:hover {
    background-color: var(--hover-bg);
}

.attachment-option svg {
    width: 24px;
    height: 24px;
}

.attachment-option span {
    font-size: 12px;
    text-align: center;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    /* Dimmed bg */
    backdrop-filter: blur(2px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity var(--trans-normal);
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

/* Modal Box */
.modal {
    background-color: var(--modal-bg);
    width: 90%;
    max-width: 450px;
    max-height: min(88vh, 760px);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(0);
    transition: transform var(--trans-normal);
}

.modal-overlay.hidden .modal {
    transform: translateY(20px);
}

.dialog-modal-overlay {
    z-index: 3200;
    backdrop-filter: blur(4px);
    background-color: rgba(8, 13, 16, 0.58);
}

.dialog-modal {
    width: min(92vw, 430px);
    border: 1px solid var(--border-light);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
}

.dialog-modal__header {
    padding: 14px 16px;
}

.dialog-modal__content {
    gap: 14px;
    padding: 16px;
}

.dialog-modal__message {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
    white-space: pre-wrap;
}

.dialog-modal__actions {
    margin-top: 4px;
}

.dialog-modal--danger .dialog-modal__confirm {
    background: #d64545;
}

.dialog-modal--danger .dialog-modal__confirm:hover {
    background: #bf3838;
}

/* Auth overlay */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background:
        radial-gradient(circle at 15% 20%, rgba(0, 168, 132, 0.22), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(17, 27, 33, 0.18), transparent 40%),
        var(--bg-color);
}

.auth-card {
    width: min(100%, 420px);
    background: var(--modal-bg);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 22px 20px 18px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.auth-brand__logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--accent-color), var(--accent-hover));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.auth-brand h1 {
    font-size: 20px;
    line-height: 1.2;
}

.auth-brand p {
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-switch {
    display: flex;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 14px;
}

.auth-switch__btn {
    flex: 1;
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.auth-switch__btn.active {
    background: var(--accent-color);
    color: #fff;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-form label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.auth-submit-btn {
    margin-top: 10px;
}

.auth-status {
    min-height: 18px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.auth-status.error {
    color: #d73949;
}

.modal__header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal__header h3 {
    font-size: 18px;
    color: var(--text-primary);
}

.modal__content {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.modal__content::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

/* Settings Form */
.settings-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.settings-form label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    margin-top: 12px;
}

.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
}

.input-field {
    width: 100%;
    background-color: var(--bg-color);
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-primary);
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.input-field:focus {
    border-color: var(--accent-color);
}

.input-field:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-text {
    color: var(--accent-color);
    font-size: 14px;
}

.btn--danger {
    background-color: rgba(234, 0, 56, 0.1);
    color: #ea0038;
    width: 100%;
}

.btn--danger:hover {
    background-color: rgba(234, 0, 56, 0.2);
}

/* Utility Helpers */
.hidden {
    display: none !important;
}

/* =========================================
   7. RESPONSIVE DESIGN (Mobile First Logic)
   ========================================= */

@media screen and (max-width: 768px) {

    /* 
       On mobile, the layout behaves like two layers.
       Sidebar is always full width.
       Chat Main slides in on top when active.
    */
    :root {
        --sidebar-width: 100vw;
    }

    .app-layout {
        position: relative;
    }

    .sidebar {
        width: 100vw;
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(0);
    }

    .chat-main {
        position: absolute;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100%;
        background-color: var(--chat-bg);
        transform: translateX(100%);
        /* Hidden off-screen to the right by default */
        transition: transform 0.35s cubic-bezier(0.33, 1, 0.68, 1);
        z-index: 20;
    }

    /* Class added by JS to show chat */
    .chat-main.active {
        transform: translateX(0);
    }

    .back-button {
        display: block;
        /* Show back arrow */
    }

    .message__bubble {
        max-width: 85%;
        /* Wider bubbles on phone */
    }

    .theme-toggle-btn {
        bottom: 15px;
        left: 15px;
        width: 40px;
        height: 40px;
    }

    .context-menu {
        width: 160px;
    }

    .attachment-options {
        width: 280px;
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .auth-card {
        width: min(100%, 440px);
        border-radius: 14px;
        padding: 18px 14px 14px;
    }
}


/* New Group Modal Specific Styles */
.group-icon-selector {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.group-icon-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
}

.group-icon-preview:hover {
    transform: scale(1.05);
}

.group-icon-preview img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.group-form {
    display: flex;
    flex-direction: column;
}

.member-selector {
    margin-top: 16px;
}

.selected-members {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    min-height: 30px;
}

.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: var(--accent-color);
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
}

.member-chip .remove-member {
    cursor: pointer;
    display: flex;
    align-items: center;
}

.member-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 8px;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 10px;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.member-item:hover {
    background-color: var(--hover-bg);
}

.member-item.selected {
    background-color: rgba(0, 168, 132, 0.1);
}

.member-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
}

.member-item-info {
    flex: 1;
}

.member-item-name {
    font-weight: 500;
    color: var(--text-primary);
}

.member-item-status {
    font-size: 12px;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-cancel {
    flex: 1;
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.btn-cancel:hover {
    background-color: var(--border-light);
}

.btn-primary {
    flex: 1;
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.message-action-btn {
    display: flex;
    width: 30px;
    height: 30px;
    padding: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(17, 27, 33, 0.14);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .message-action-btn {
    background: rgba(32, 44, 51, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Group member selection */
.member-selector {
    margin-top: 1rem;
}

.member-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 0.5rem;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.member-item:last-child {
    border-bottom: none;
}

.member-item:hover {
    background-color: var(--hover-bg);
}

.selected-members {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    min-height: 40px;
    padding: 0.5rem;
    border: 1px dashed var(--border-color);
    border-radius: 4px;
}

.selected-member {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    background-color: var(--primary-color-light);
    border-radius: 20px;
    font-size: 0.875rem;
}

.selected-member .avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.remove-member {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-member:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.toggle-member {
    margin-left: auto;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.toggle-member.active {
    opacity: 1;
    color: var(--accent-color);
}

/* Voice recording UI */
.voice-recorder {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 200px;
}

.voice-recording-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background-color: #ff4757;
    border-radius: 50%;
    animation: recordDotPulse 1.5s infinite;
}

@keyframes recordDotPulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.voice-recorder-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Voice message styling */
.voice-message {
    padding: 0.5rem 0;
    width: min(100%, 320px);
    max-width: 100%;
    min-width: 0;
}

.voice-player {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.55rem;
    background: var(--message-bubble-bg);
    border-radius: 18px;
    max-width: 100%;
    width: 100%;
    min-width: 0;
}

.modern-voice-player {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.modern-voice-player audio {
    flex: 1;
    min-width: 0;
}

.document-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--message-bubble-bg);
    border-radius: 8px;
    width: min(100%, 320px);
    max-width: 100%;
    min-width: 0;
}

.doc-icon {
    background: var(--accent-color);
    padding: 8px;
    border-radius: 50%;
    color: #fff;
    flex-shrink: 0;
}

.unread-badge--top {
    margin: 0;
}

.doc-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.doc-name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-size {
    font-size: 11px;
    color: var(--text-secondary);
}

.doc-download-btn {
    margin-left: auto;
}

.voice-waveform {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 20px;
    flex-grow: 1;
}

.wave-bar {
    width: 2px;
    height: 100%;
    background: var(--accent-color);
    border-radius: 1px;
    animation: wave 1.2s infinite ease-in-out;
}

.wave-bar:nth-child(2) {
    animation-delay: 0.1s;
}

.wave-bar:nth-child(3) {
    animation-delay: 0.2s;
}

.wave-bar:nth-child(4) {
    animation-delay: 0.3s;
}

.wave-bar:nth-child(5) {
    animation-delay: 0.4s;
}

@keyframes wave {

    0%,
    100% {
        height: 40%;
    }

    50% {
        height: 100%;
    }
}

.voice-duration {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 42px;
    text-align: center;
    flex-shrink: 0;
}

/* Recording button state */
.btn-icon.recording {
    color: #ff4757;
    animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Group chat styling */
.message--group .message__bubble {
    border-radius: 18px 18px 4px 18px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .voice-recorder {
        bottom: 120px;
        width: calc(100% - 40px);
        left: 20px;
        transform: none;
    }
}


/* =========================================
   8. RIGHT SIDEBAR (Chat Info)
   ========================================= */
.right-sidebar {
    width: 0;
    background-color: var(--sidebar-bg);
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    /* overflow: hidden; */
    transition: width var(--trans-normal);
    z-index: 15;
    height: 100%;
}

.right-sidebar.active {
    width: 380px;
    /* Same as left sidebar */
}

.right-sidebar__content {
    flex: 1;
    overflow-y: auto;
    width: 380px;
    /* Fixed width to prevent content squashing during transition */
    padding-bottom: 20px;
}

.info-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px;
    background-color: var(--sidebar-bg);
    border-bottom: 10px solid var(--bg-color);
    /* Separator */
}

.info-profile .avatar {
    width: 200px;
    height: 200px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}

.info-profile .avatar:hover {
    transform: scale(1.02);
}

.info-name {
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    text-align: center;
}

.info-status {
    font-size: 14px;
    color: var(--text-secondary);
}

.info-section {
    padding: 16px 20px;
    border-bottom: 10px solid var(--bg-color);
    background-color: var(--sidebar-bg);
}

.info-section h3 {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 12px;
}

.info-about {
    font-size: 16px;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Media Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.media-grid-item {
    position: relative;
    padding-top: 100%;
    /* square aspect ratio */
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    background-color: var(--border-light);
}

.media-grid-item img,
.media-grid-item video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.info-media-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.info-media-tab {
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    background: transparent;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
}

.info-media-tab.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.info-media-content {
    min-height: 80px;
}

.info-media-empty {
    text-align: center;
    padding: 14px 8px;
    color: var(--text-secondary);
}

.info-media-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.info-media-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    min-width: 0;
}

.info-media-icon {
    min-width: 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 168, 132, 0.15);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.info-media-text {
    min-width: 0;
    flex: 1;
}

.info-media-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-media-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

.info-media-row audio {
    width: 150px;
    max-width: 45%;
    min-width: 110px;
}

/* Members List */
.info-members-list {
    display: flex;
    flex-direction: column;
}

.info-member-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
}

.info-member-item:last-child {
    border-bottom: none;
}

.info-member-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
}

.info-member-info {
    flex: 1;
}

.info-member-name {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 500;
}

.info-member-role {
    font-size: 12px;
    color: var(--accent-color);
    background-color: rgba(0, 168, 132, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    text-transform: capitalize;
}

.info-member-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-member-role-select {
    border: 1px solid var(--border-light);
    background: var(--bg-color);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 12px;
    padding: 4px 8px;
    text-transform: capitalize;
}

.group-member-remove-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(234, 0, 56, 0.25);
    color: #ea0038;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.group-member-remove-btn:hover {
    background: rgba(234, 0, 56, 0.1);
}

/* Actions */
.info-actions {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.btn-action {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: var(--bg-color);
    transition: background-color 0.2s, border-color 0.2s;
}

.btn-action:hover {
    background-color: var(--hover-bg);
    border-color: rgba(0, 168, 132, 0.3);
}

.text-danger {
    color: #ea0038;
}

.text-danger svg {
    color: #ea0038;
}

/* Responsive Right Sidebar */
@media screen and (max-width: 1200px) {
    .right-sidebar.active {
        width: 320px;
    }

    .right-sidebar__content {
        width: 320px;
    }

    .info-profile .avatar {
        width: 150px;
        height: 150px;
    }
}

@media screen and (max-width: 768px) {
    .right-sidebar {
        /* On mobile, it overlays full screen */
        position: fixed;
        /* Fixed to cover everything */
        top: 0;
        right: 0;
        /* Attach to right */
        height: 100%;
        width: 100% !important;
        /* Full width */
        transform: translateX(100%);
        /* Start off-screen right */
        transition: transform 0.3s cubic-bezier(0.33, 1, 0.68, 1);
        border-left: none;
        z-index: 50;
        /* Above everything */
    }

    .right-sidebar.active {
        width: 100% !important;
        /* Force full width */
        transform: translateX(0);
        /* Slide in */
    }

    .right-sidebar__content {
        width: 100vw;
        /* full viewport width */
    }
}

/* =========================================
   8. NEW FEATURES CSS
   ========================================= */

/* Message Actions (Hidden by default, show on hover) */
.message-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    z-index: 10;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(17, 27, 33, 0.08);
}

[data-theme="dark"] .message-actions {
    background: rgba(0, 0, 0, 0.3);
}

.message:hover .message-actions,
.message:focus-within .message-actions {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .message-actions {
        opacity: 1;
        pointer-events: auto;
        background: transparent;
    }
    .chat-scroll-bottom {
        right: 12px;
        bottom: 78px;
        width: 38px;
        height: 38px;
    }
    .video-message--circle {
        width: 170px;
        height: 170px;
    }
}

/* Pinned Message Highlight */
.pinned-message .message__bubble {
    border-left: 4px solid var(--accent-color);
    background-color: rgba(0, 168, 132, 0.1) !important;
}

/* Search Active State - Hide Profile Info to make room */
.chat__header.search-active .chat__header-info {
    display: none;
}

/* Search Highlight */
.search-match {
    box-shadow: 0 0 0 2px var(--accent-color);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 2px var(--accent-color);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(0, 168, 132, 0.5);
    }

    100% {
        box-shadow: 0 0 0 2px var(--accent-color);
    }
}

/* Voice Recorder UI (Telegram Style Overlay) */
.voice-recorder-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--sidebar-bg);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 20;
    border-top: 1px solid var(--border-light);
    animation: slideInRight 0.2s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.voice-recording-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    color: #ea0038;
    font-weight: 500;
    font-size: 16px;
}

.recording-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ea0038;
    animation: blink 1s infinite;
}

@keyframes blink {
    50% {
        opacity: 0.4;
    }
}

.voice-recorder-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-cancel-voice {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    text-transform: uppercase;
    padding: 8px 12px;
    cursor: pointer;
}

.btn-cancel-voice:hover {
    color: #ea0038;
    background-color: rgba(234, 0, 56, 0.05);
    border-radius: 4px;
}

.btn-send-voice {
    color: var(--accent-color);
    padding: 8px;
    border-radius: 50%;
    background-color: rgba(0, 168, 132, 0.1);
}

.btn-send-voice:hover {
    background-color: var(--accent-color);
    color: white;
}

/* Video Recorder UI */
.video-recorder-modal {
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(12, 19, 23, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.video-recorder-shell {
    width: min(100%, 420px);
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    box-shadow: var(--shadow-md);
}

#videoRecorderPreview {
    width: 100%;
    height: min(70vh, 420px);
    display: block;
    object-fit: cover;
}

.video-recorder-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(17, 27, 33, 0.9);
}

.video-rec-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.video-rec-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Forward modal list */
.forward-contact-item {
    gap: 10px;
}

.forward-contact-item .toggle-member {
    font-size: 12px;
    color: var(--accent-color);
    opacity: 0.7;
}

.forward-contact-item.selected .toggle-member {
    opacity: 1;
    font-weight: 600;
}

/* Stories */
.stories-strip {
    padding: 10px 14px 6px;
    border-bottom: 1px solid var(--border-light);
}

.stories-strip__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.stories-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.story-item {
    min-width: 62px;
    max-width: 62px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.story-ring {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(120deg, #2bb673, #2f8fe8);
}

.story-ring.story-ring--viewed {
    background: #b3bcc7;
}

.story-ring img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--sidebar-bg);
}

.story-name {
    width: 100%;
    font-size: 11px;
    text-align: center;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.story-viewer-content {
    min-height: 220px;
    max-height: 62vh;
    overflow-y: auto;
    display: grid;
    place-items: center;
    text-align: center;
    gap: 10px;
}

.story-viewer-content img,
.story-viewer-content video {
    max-width: 100%;
    max-height: 50vh;
    border-radius: 12px;
}

.story-viewer-content video {
    width: 100%;
    background: #000;
}

.story-viewer-text {
    font-size: 16px;
    line-height: 1.6;
}

.story-viewer-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#storyDeleteBtn {
    color: #ef4444;
}

.story-progress-track {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16px, 1fr));
    gap: 4px;
    margin-bottom: 10px;
}

.story-progress-item {
    height: 3px;
    border-radius: 999px;
    background: rgba(134, 150, 160, 0.35);
    overflow: hidden;
}

.story-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-color);
    transition: width 80ms linear;
}

.story-progress-item.is-complete .story-progress-fill {
    width: 100%;
}

.chat-filters {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
}

.chat-filter-tab {
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
}

.chat-filter-tab.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.reaction-picker {
    position: fixed;
    z-index: 1300;
    background: var(--modal-bg);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    box-shadow: var(--shadow-md);
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reaction-picker button {
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    padding: 4px;
    border-radius: 50%;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
}

.reaction-picker button:hover {
    background: var(--hover-bg);
}

.reaction-picker button.active {
    background: var(--primary-color-light);
}

.message-reaction {
    margin-top: 2px;
    align-self: flex-end;
    border: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.8);
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    user-select: none;
}

[data-theme="dark"] .message-reaction {
    background: rgba(32, 44, 51, 0.8);
}

.message-reaction.is-own {
    border-color: rgba(0, 168, 132, 0.45);
    background: rgba(0, 168, 132, 0.12);
}

.message-reaction__count {
    font-size: 12px;
    color: var(--text-secondary);
}

.media-download-link,
.voice-download-link,
.video-msg-download {
    position: absolute;
    right: 8px;
    bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    padding: 4px 8px;
    z-index: 2;
}

.video-msg-download {
    top: 8px;
    bottom: auto;
}

.voice-download-link {
    position: static;
    margin-left: auto;
    background: rgba(0, 0, 0, 0.15);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.video-msg-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    pointer-events: none;
}

.video-msg-ring-bg,
.video-msg-ring-progress {
    fill: none;
    stroke-width: 7;
}

.video-msg-ring-bg {
    stroke: rgba(255, 255, 255, 0.16);
}

.video-msg-ring-progress {
    stroke: #34d399;
    stroke-linecap: round;
    stroke-dasharray: 0;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.12s linear;
}

.video-msg-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: none;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    display: grid;
    place-items: center;
    cursor: pointer;
    z-index: 3;
}

.video-msg-time {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    z-index: 3;
}
