:root {
    --primary: #FF1500;
    --primary-dark: #CC1100;
    --accent: #FF5500;
    --bg-light: #f0f2f5;
    --sidebar-light: #ffffff;
    --message-light: #ffffff;
    --user-light: #dcf8c6;

    --bg-dark: #0e1621;
    --sidebar-dark: #1b2a38;
    --message-dark: #1f2d3d;
    --user-dark: #2b4d63;

    --border-radius: 14px;
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}
.unread-badge {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #08c;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 12px;
    display: none;
}
body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s;
    -webkit-text-size-adjust: 100%;
}

body.light {
    background-color: var(--bg-light);
    color: #111;
}

body.dark {
    background-color: var(--bg-dark);
    color: #fff;
}

.app-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* Sidebar Styles */
.sidebar {
    width: 360px;
    background: var(--sidebar-light);
    border-right: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
}

body.dark .sidebar {
    background-color: var(--sidebar-dark);
    border-color: #2c3e50;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid #ccc;
    position: relative;
}

body.dark .sidebar-header {
    border-color: #2c3e50;
}

.menu-toggle {
    display: none;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    cursor: pointer;
    z-index: 11;
}

.search-container {
    margin-bottom: 10px;
    position: relative;
}

/* Добавки для лоадера */
.loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.spinner {
    width: 50px; height: 50px;
    border: 6px solid #ccc;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Аватар в шапке чата */
.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
}

/* Accounts scroller styles */
.accounts-scroll-container {
    width: 100%;
    overflow-x: auto;
    padding: 8px 0;
    margin-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.accounts-scroll-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.accounts-scroller {
    display: flex;
    gap: 12px;
    padding: 0 12px;
}

.account-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
    cursor: pointer;
}

.account-badge-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.avatar-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #2a2a2a;
    color: var(--primary);
    font-weight: 700;
    object-fit: cover;
    border: 2px solid #3a3a3a;
    flex-shrink: 0;
}

.account-badge-avatar-ph,
.account-badge .avatar-ph {
    width: 40px;
    height: 40px;
    font-size: 14px;
}

.dialog-avatar .avatar-ph,
.dialog-avatar img {
    width: 48px;
    height: 48px;
    font-size: 16px;
}

.account-item .avatar-ph,
.account-item img {
    width: 40px;
    height: 40px;
    font-size: 14px;
}

.account-badge.active .account-badge-avatar {
    border-color: var(--primary);
}

.account-badge-name {
    font-size: 10px;
    margin-top: 4px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
}

/* Индикатор онлайн у аккаунта */
.account-item { display: flex; align-items: center; padding: 8px; cursor: pointer; }
.account-item img { width: 40px; height: 40px; border-radius: 50%; }
.account-item .status { width: 10px; height: 10px; border-radius: 50%; background: #4caf50; position: absolute; right: 12px; bottom: 12px; }

.search-container i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-container input {
    padding: 8px 12px 8px 40px;
    border: none;
    border-radius: 22px;
    background: #e9ecef;
    font-size: 14px;
    outline: none;
}

body.dark .search-container input {
    background: #2e3b4e;
    color: #fff;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.filter-buttons button {
    padding: 6px 12px;
    border: none;
    border-radius: 16px;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    flex: 1;
}

.filter-buttons button.active {
    background: var(--primary);
    color: white;
}

.cabinet-btn {
    width: 100%;
    margin-top: 10px;
    padding: 10px 14px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

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

.dialogs-list {
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.dialog-item {
    padding: 12px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    gap: 12px;
    position: relative;
}

.dialog-item:hover {
    background-color: rgba(255, 21, 0, 0.1);
}

.dialog-item.active {
    background-color: rgba(255, 21, 0, 0.2);
}

.dialog-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.dialog-info {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.dialog-name {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

.dialog-last-message {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat Container Styles */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: inherit;
    transition: transform 0.3s ease;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid #ccc;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

body.dark .chat-header {
    border-color: #2c3e50;
}


.chat-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--border-radius);
    position: relative;
    background-color: var(--message-light);
    box-shadow: var(--shadow);
    animation: fadeInUp 0.3s ease;
    transition: background 0.3s;
    word-break: break-word;
}

body.dark .message {
    background-color: var(--message-dark);
}

.message.incoming {
    align-self: flex-start;
}

.message.outgoing {
    align-self: flex-end;
    background-color: var(--user-light);
}

body.dark .message.outgoing {
    background-color: var(--user-dark);
}

.message-time {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
    text-align: right;
}

.message-input-container {
    padding: 12px;
    display: flex;
    align-items: center;
    background-color: var(--sidebar-light);
    border-top: 1px solid #ccc;
    transition: background 0.3s;
}

body.dark .message-input-container {
    background-color: var(--sidebar-dark);
    border-color: #2c3e50;
}

#messageInput {
    flex: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    background: #e9ecef;
    color: #111;
    outline: none;
}

body.dark #messageInput {
    background: #2e3b4e;
    color: #fff;
}

.send-button {
    margin-left: 10px;
    background: var(--primary);
    border: none;
    padding: 10px 14px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-button:hover {
    transform: scale(1.1);
}

.send-button svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.theme-toggle {
    position: fixed;
    top: 15px;
    right: 15px;
    font-size: 22px;
    cursor: pointer;
    z-index: 100;
    background: rgba(0, 0, 0, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary);
    color: white;
    padding: 12px 18px;
    border-radius: 10px;
    opacity: 0;
    animation: fadeInOut 2s ease;
    max-width: 80%;
    box-sizing: border-box;
}

.back-button {
    display: none;
    cursor: pointer;
    padding: 10px;
    margin-right: 10px;
    font-size: 18px;
    color: var(--text-color);
}

.back-button:hover {
    opacity: 0.8;
}



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

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(10px); }
    20% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateY(10px); }
}

@media screen and (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: 100%;
        position: absolute;
        left: 0;
        top: 0;
        transform: translateX(0);
        transition: transform 0.3s ease;
        z-index: 10;
    }
    .sidebar.hidden {
        transform: translateX(-100%);
    }
    .chat-container {
        width: 100%;
        height: 100%;
        position: absolute;
        left: 0;
        top: 0;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    .chat-container.visible {
        transform: translateX(0);
    }
    .back-button {
        display: block;
    }
}

/* === read receipts === */
.message-time {
    display: inline-block;
    margin-right: 5px;
}

.single-check {
    font-size: 12px;
    color: gray;
    vertical-align: middle;
    margin-left: 2px;
}

.double-check {
    font-size: 12px;
    color: #FF1500; /* ваш основной голубой цвет */
    vertical-align: middle;
    margin-left: 2px;
}
