/* chat.css — DEEP OCEAN THEME (FIXED MODALS) */

/* =========================================
   1. CHAT HEADER (FIXED LAYOUT)
   ========================================= */
.chat-header-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 20px;
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-light);
    height: 70px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    z-index: 20;
    position: relative; /* Важно для центровки статистики */
}

/* Группы слева и справа поверх статистики */
.ch-group-left, .ch-group-right { 
    display: flex; align-items: center; gap: 12px;
    flex: 1 1 0;
    min-width: 0;
    z-index: 5; 
}
.ch-group-right { justify-content: flex-end; margin-left: auto; }

.ch-center-tools {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 8;
    pointer-events: none;
}

.ch-center-tools > * {
    pointer-events: auto;
}

/* --- КАРТОЧКА ИНФО (КЛИЕНТ/БОТ) --- */
.ch-info-card {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 0;
    border-radius: 8px; /* Квадратнее */
    background: transparent; 
    border: 1px solid transparent;
    max-width: 240px; /* Ограничиваем ширину карточки */
}

.ch-info-card-client {
    max-width: 340px;
}

.ch-info-card-bot {
    max-width: 220px;
}

.ch-avatar-btn {
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    flex-shrink: 0;
}

.ch-avatar-btn:hover .ch-avatar {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.12);
}

.ch-avatar { 
    width: 40px; height: 40px; 
    border-radius: 8px; /* Квадрат с закруглением */
    object-fit: cover; 
    border: 1px solid var(--border-light); 
    flex-shrink: 0;
}

.ch-info { 
    display: flex; flex-direction: column; justify-content: center; 
    overflow: hidden; /* Чтобы обрезать текст */
    min-width: 0;
}

/* Имя + Статус */
.ch-name-row { display: flex; align-items: center; gap: 6px; }

.ch-mood-icon-wrap {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ch-mood-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    display: block;
}

.ch-real-present-icon {
    width: 30px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
    color: #f8fafc;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.18), rgba(34, 197, 94, 0.13));
    border: 1px solid rgba(56, 189, 248, 0.42);
    border-radius: 8px;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.45), 0 6px 14px rgba(14, 165, 233, 0.12);
}

.ch-real-present-icon .fa-truck-fast {
    font-size: 16px;
    color: #38bdf8;
    transform: translateX(-2px);
}

.ch-real-present-icon .fa-gift {
    position: absolute;
    right: 3px;
    bottom: 3px;
    font-size: 9px;
    color: #f472b6;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.ch-name { 
    font-weight: 700; font-size: 14px; color: var(--text-primary); 
    line-height: 1.2; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    max-width: 240px; 
    user-select: text;
}

/* ID */
.ch-id-row { display: flex; align-items: center; gap: 6px; }
.ch-id-btn {
    padding: 0;
    border: none;
    background: transparent;
    font-size: 11px;
    color: var(--accent-blue);
    font-family: monospace;
    letter-spacing: 0.5px;
    cursor: pointer;
    text-decoration: underline transparent;
    text-underline-offset: 2px;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}
.ch-id-btn:hover {
    color: #7dd3fc;
    text-decoration-color: currentColor;
}

.ch-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
    flex-shrink: 0;
}

/* --- КНОПКИ ДЕЙСТВИЙ --- */
.ch-actions-row { display: flex; gap: 8px; margin-left: 5px; }
.ch-actions-row-center {
    margin-left: 0;
    gap: 10px;
    align-items: center;
}

.ch-circle-btn {
    width: 32px; height: 32px; /* Чуть меньше */
    border-radius: 8px; /* Квадратнее */
    background: transparent; border: 1px solid var(--border-light);
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s; font-size: 14px;
}
.ch-circle-btn:hover { 
    background: var(--bg-hover); color: var(--text-primary); 
    border-color: var(--accent-blue); 
}

.ch-stats { 
    display: flex; align-items: center; gap: 15px;
    background: #0f172a; padding: 6px 16px; border-radius: 20px;
    border: 1px solid var(--border-light);
    opacity: 1; transition: 0.2s; pointer-events: none;
    z-index: 1;
}
.ch-stat-val { color: var(--accent-blue); font-weight: 700; font-size: 14px; }
.ch-stat-sep { width: 1px; height: 15px; background: var(--border-light); }

.ch-menu-btn { 
    width: 1px; height: 1px; display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); cursor: pointer; border-radius: 50%; font-size: 16px;
    transition: 0.2s;
}
.ch-menu-btn:hover { color: var(--text-primary); }

.ch-actions-row .ch-mood-icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
}

.ch-actions-row .ch-mood-icon {
    width: 18px;
    height: 18px;
}

.ch-name-row .ch-mood-icon-wrap {
    width: 20px;
    height: 20px;
    margin-left: 2px;
}

.ch-name-row .ch-mood-icon {
    width: 20px;
    height: 20px;
}

@media (max-width: 1220px) {
    .chat-header-bar { padding: 0 12px; gap: 8px; }
    .ch-group-left, .ch-group-right { gap: 8px; min-width: 0; }
    .ch-info-card-client { max-width: 250px; }
    .ch-info-card-bot { max-width: 170px; }
    .ch-name { max-width: 150px; }
    .ch-stats { padding: 5px 12px; gap: 10px; }
}

@media (max-width: 1080px) {
    .ch-info-card-client { max-width: 190px; }
    .ch-info-card-bot { max-width: 132px; }
    .ch-name { max-width: 110px; }
    .ch-group-left .ch-info,
    .ch-group-right .ch-info { min-width: 0; }
    .ch-center-tools { gap: 8px; }
}

@media (max-width: 980px) {
    .chat-header-bar { padding: 0 10px; }
    .ch-name { display: none; }
    .ch-status-dot, .ch-mood-icon-wrap, #ch-leaf-icon { display: none !important; }
    .ch-id-row, .ch-id-btn { display: none !important; }
    .ch-actions-row { margin-left: 0; }
    .ch-center-tools { position: static; transform: none; margin: 0 auto; }
}

/* =========================================
   2. MESSAGES AREA
   ========================================= */
.chat-viewport { 
    flex: 1; overflow-y: auto; padding: 20px; 
    display: flex; flex-direction: column; gap: 10px; 
    background-color: var(--bg-chat-pattern); 
    background-image: radial-gradient(#1e293b 1px, transparent 1px);
    background-size: 20px 20px;
}

.chat-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-alert-slot {
    display: none;
    padding: 10px 14px 0;
    background: var(--bg-chat-pattern);
}

.chat-alert-slot.visible {
    display: block;
}

.chat-warning-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(127, 29, 29, 0.16), rgba(153, 27, 27, 0.1));
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.chat-warning-title {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #fca5a5;
    text-align: center;
}

.msg-row { display: flex; gap: 10px; max-width: 70%; align-items: flex-end; }

/* Photo messages must stay on the same side as normal chat bubbles. */
.msg-row.msg-row-photo {
    width: fit-content !important;
    max-width: min(260px, 70%) !important;
    gap: 6px !important;
}

.msg-row.me.msg-row-photo {
    align-self: flex-end !important;
    flex-direction: row-reverse !important;
    justify-content: flex-start !important;
    margin-left: auto !important;
    margin-right: 0 !important;
}

.msg-row.client.msg-row-photo {
    align-self: flex-start !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    margin-left: 0 !important;
    margin-right: auto !important;
}

.msg-row.me.msg-row-photo .msg-content {
    align-items: flex-end !important;
}

.msg-row.client.msg-row-photo .msg-content {
    align-items: flex-start !important;
}

.msg-row.msg-row-photo .msg-photo-card {
    width: min(180px, 30vw) !important;
}

.msg-row.msg-row-photo .msg-bubble {
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}
.msg-row.client { align-self: flex-start; }
.msg-row.me { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.system {
    align-self: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    margin: 10px 0 4px;
}

.msg-avatar { 
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover; 
    flex-shrink: 0; border: 1px solid var(--border-light); 
}
.msg-content { display: flex; flex-direction: column; }

.msg-bubble {
    padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.4; 
    position: relative; word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.msg-row.client .msg-bubble { 
    background-color: var(--bg-msg-in); color: var(--text-primary); 
    border-bottom-left-radius: 4px; 
}
.msg-row.me .msg-bubble { 
    background-color: var(--bg-msg-out); color: #FFF; 
    border-bottom-right-radius: 4px; 
}

.msg-row-media {
    max-width: min(290px, 70%);
    gap: 6px;
}

.msg-row-media .msg-content {
    width: auto;
    max-width: max-content;
}

.msg-row-media .msg-bubble {
    display: inline-flex;
    width: auto;
    max-width: 100%;
    padding: 0;
    border-radius: 14px;
    line-height: 1;
    background: transparent !important;
    border: none !important;
    box-shadow: none;
}

.msg-row.me.msg-row-media .msg-bubble {
    border-bottom-right-radius: 8px;
}

.msg-row.client.msg-row-media .msg-bubble {
    border-bottom-left-radius: 8px;
}

.msg-time {
    font-size: 11px; color: var(--text-muted); margin-top: 3px; 
    align-self: flex-start; font-weight: 600;
}
.msg-row.me .msg-time { align-self: flex-end; }
.msg-system-badge {
    max-width: min(620px, 88%);
    text-align: center;
    margin: 4px auto;
    padding: 12px 16px 11px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(248,250,252,0.96), rgba(241,245,249,0.92));
    border: 1px solid rgba(148,163,184,0.28);
    border-top: 3px solid rgba(56,189,248,0.7);
    box-shadow: 0 4px 14px rgba(15,23,42,0.06);
}
.msg-system-text {
    color: #334155;
    font-size: 12px;
    line-height: 1.5;
    font-weight: 700;
}
.msg-system-time {
    display: block;
    margin-top: 6px;
    color: #475569;
    font-size: 10px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.chat-footer.is-blocked {
    opacity: 0.72;
}

.chat-footer.is-blocked .cf-btn,
.chat-footer.is-blocked .cf-btn-wide {
    pointer-events: none;
    opacity: 0.45;
}

.chat-footer.is-blocked .cf-input {
    cursor: not-allowed;
    opacity: 0.72;
}


/* =========================================
   3. FOOTER & INPUTS (FIXED LAYOUT)
   ========================================= */
.chat-footer {
    padding: 10px 10px; 
    background-color: var(--bg-header); 
    border-top: 1px solid var(--border-light);
    display: flex; align-items: flex-end; gap: 8px; 
    box-shadow: 0 -2px 10px rgba(0,0,0,0.02);
    position: relative; z-index: 10;
}

/* Left Column (Icons) */
.cf-col { 
    display: grid; grid-template-rows: 40px 40px 40px; align-content: space-between;
    height: 140px; width: 40px; flex-shrink: 0; margin: 0;
}
.cf-col .cf-btn:nth-child(1) { grid-row: 1; } 
.cf-col .cf-btn:nth-child(2) { grid-row: 2; } 
.cf-col .cf-btn:nth-child(3) { grid-row: 3; }

/* Right Column (Send/Attach) */
.cf-col:last-child {
    display: flex; flex-direction: column;
    justify-content: flex-end; gap: 8px; 
    width: 110px; min-width: 110px; 
    align-items: stretch;
}

.cf-btn {
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--bg-hover); border: 1px solid var(--border-light);
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s; font-size: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
} 
.cf-btn:hover { 
    background: #475569; border-color: var(--accent-blue); 
    color: var(--accent-blue); transform: translateY(-1px); 
}

.cf-btn-wide {
    width: 100%; padding: 0 10px; height: 40px; 
    border-radius: 10px; background: var(--bg-hover); border: 1px solid var(--border-light);
    color: var(--text-primary);
    display: flex; align-items: center; justify-content: flex-start; gap: 6px;
    cursor: pointer; transition: 0.2s; font-size: 12px; font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.cf-btn-wide:hover { background: #475569; border-color: var(--text-secondary); }

.btn-send { background: var(--accent-blue); color: #0f172a; border-color: var(--accent-blue); }
.btn-send:hover { background: var(--accent-hover); color: #FFF; }

/* Input */
.cf-input-wrap { flex: 1; position: relative; height: 140px; min-width: 0; }
.cf-input {
    width: 100%; height: 100%; background-color: var(--input-bg);
    border: 1px solid var(--input-border); color: var(--text-primary);
    padding: 12px 12px 12px 40px; border-radius: 12px;
    outline: none; font-size: 14px; resize: none; font-family: inherit;
    transition: 0.2s; box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
    box-sizing: border-box;
}
.cf-input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.1); }

.smile-inside-btn {
    position: absolute; top: 12px; left: 10px;
    color: var(--text-secondary); cursor: pointer; font-size: 20px; z-index: 15;
}
.smile-inside-btn:hover { color: var(--accent-blue); transform: scale(1.1); }


/* =========================================
   4. MODALS (INFO, NOTES, ATTACH, POST)
   ========================================= */

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 2000;
    display: none; align-items: center; justify-content: center;
    backdrop-filter: blur(5px);
}
.modal-overlay.show { display: flex; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- 4.1 CLIENT INFO MODAL (Исправленная раскладка) --- */
.modal-card-large {
    width: 850px; height: 85vh; 
    background: var(--bg-sidebar); 
    border-radius: 16px;
    border: 1px solid var(--border-light);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex; /* ВАЖНО: Две колонки */
    flex-direction: row; /* Слева - инфо, Справа - описание */
    overflow: hidden; position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 14px;
    right: 18px;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(241, 245, 249, 0.82);
    font-size: 25px;
    line-height: 1;
    font-weight: 300;
    z-index: 50;
    transition: color 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
    opacity: 0.82;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.modal-close-btn:hover {
    color: #fff;
    opacity: 1;
    transform: scale(1.08);
}

/* Левая колонка */
.modal-left {
    width: 320px; 
    background: var(--bg-body); /* Темный фон для инфо */
    border-right: 1px solid var(--border-light);
    padding: 30px 20px; 
    overflow-y: auto; 
    display: flex; flex-direction: column; align-items: center;
    flex-shrink: 0;
}

.modal-avatar-large {
    width: 140px; height: 140px; border-radius: 50%; object-fit: cover;
    border: 4px solid var(--bg-sidebar); 
    box-shadow: 0 4px 15px rgba(0,0,0,0.3); margin-bottom: 15px;
}

.modal-name { font-size: 20px; font-weight: 800; color: var(--text-primary); text-align: center; margin-bottom: 5px; }
.modal-id { font-size: 13px; color: var(--accent-blue); font-family: monospace; margin-bottom: 5px; }
.modal-sub { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; text-align: center; }

.modal-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 25px; }
.modal-tag { 
    background: var(--bg-hover); color: var(--accent-blue); 
    padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600;
    border: 1px solid var(--border-light);
}

.info-block { width: 100%; margin-bottom: 20px; }
.info-title {
    font-size: 11px; font-weight: 700; color: var(--text-muted); 
    text-transform: uppercase; letter-spacing: 1px;
    margin-bottom: 10px; border-bottom: 1px solid var(--border-light); padding-bottom: 5px;
}

.modal-table { width: 100%; border-collapse: collapse; }
.modal-table td { padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--border-light); }
.modal-table td:first-child { color: var(--text-secondary); font-weight: 500; width: 45%; }
.modal-table td:last-child { color: var(--text-primary); font-weight: 600; text-align: right; }

/* Правая колонка */
.modal-right { 
    flex: 1; 
    padding: 30px; 
    overflow-y: auto;
    background: var(--bg-sidebar);
}

.modal-section-title { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 10px; margin-top: 20px; }
.modal-section-title:first-child { margin-top: 0; }

.modal-desc { 
    font-size: 14px; line-height: 1.6; color: var(--text-secondary); 
    background: var(--bg-body); padding: 15px; border-radius: 8px; 
    border: 1px solid var(--border-light); 
}

.modal-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); gap: 10px; }
.modal-gallery-img { 
    width: 100%; aspect-ratio: 1/1; object-fit: cover; 
    border-radius: 0; cursor: pointer; transition: transform 0.2s; 
    border: 1px solid var(--border-light); 
}
.modal-gallery-img:hover { transform: scale(1.05); border-color: var(--accent-blue); }


/* --- 4.2 NOTES MODAL --- */
.modal-card-notes {
    width: 450px; height: 550px; background: var(--bg-sidebar); border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5); display: flex; flex-direction: column; overflow: hidden;
    border: 1px solid var(--border-light);
}
.notes-input-area { padding: 20px; background: var(--bg-body); border-bottom: 1px solid var(--border-light); }
.note-textarea { 
    width: 100%; height: 100px; background: var(--input-bg); border: 1px solid var(--input-border); 
    color: var(--text-primary); padding: 10px; border-radius: 8px; 
    font-family: inherit; font-size: 14px; resize: none; outline: none; margin-bottom: 10px; 
}
.note-textarea:focus { border-color: var(--accent-blue); }
.note-save-btn { 
    width: 100%; padding: 10px; background: var(--accent-blue); color: #0f172a; 
    border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; 
}
.note-save-btn:hover { background: var(--accent-hover); color: #FFF; }
.notes-list-area { flex: 1; padding: 20px; overflow-y: auto; color: var(--text-secondary); }


/* --- 4.3 ATTACH & POST COMMON --- */
.modal-attach-card, .modal-post-card {
    background: var(--bg-sidebar); width: 900px; height: 650px;
    border-radius: 12px; overflow: hidden; 
    box-shadow: 0 20px 60px rgba(0,0,0,0.5); border: 1px solid var(--border-light);
    display: flex; flex-direction: column;
}
.modal-post-card { width: 600px; height: auto; max-height: 85vh; }

.attach-header, .post-header {
    padding: 15px 20px; border-bottom: 1px solid var(--border-light);
    display: flex; justify-content: space-between; align-items: center; background: #0f172a;
}
.ah-profile-info { display: flex; align-items: center; gap: 15px; }
.ah-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border-light); flex-shrink: 0; }
.ah-title, .post-header span { font-size: 18px; font-weight: 800; color: var(--text-primary); letter-spacing: 0.5px; }

.attach-tabs { display: flex; gap: 0; background: var(--bg-sidebar); border-bottom: 1px solid var(--border-light); padding: 0 20px; }
.attach-tab-item {
    padding: 12px 18px; font-size: 13px; font-weight: 600; color: var(--text-secondary);
    cursor: pointer; border-bottom: 3px solid transparent; transition: 0.2s; text-transform: uppercase;
}
.attach-tab-item:hover { color: var(--text-primary); }
.attach-tab-item.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }

.attach-body { flex: 1; overflow-y: auto; padding: 15px; }
.attach-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }

.attach-item {
    aspect-ratio: 1/1.5; background: #0040e700; border-radius: 12px; overflow: hidden; position: relative; cursor: pointer;
    border: 2px solid transparent; transition: all 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.attach-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-item.selected {
    border-color: var(--accent-blue) !important; box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.3) !important;
    transform: scale(1.02); z-index: 5;
}
.attach-item.blocked { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.attach-checkbox {
    position: absolute; top: 5px; right: 5px; width: 20px; height: 20px; 
    border-radius: 50%; background: rgba(15, 23, 42, 0.8); color: #FFF;
    display: flex; align-items: center; justify-content: center; font-size: 10px; z-index: 5; 
    border: 1px solid var(--text-muted);
}
.attach-item.selected .attach-checkbox { background: var(--accent-blue) !important; border-color: var(--accent-blue) !important; }
.media-status-badge {
    position: absolute; bottom: 5px; left: 5px; font-size: 14px; padding: 3px; 
    border-radius: 4px; background: rgba(15, 23, 42, 0.8); color: white; box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.attach-footer, .post-footer { padding: 15px 20px; border-top: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; background: #0f172a; }

.btn-footer-action {
    height: 40px; padding: 0 20px; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 8px; text-transform: uppercase; border: 1px solid transparent;
}
.btn-upload { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.btn-upload:hover { background: #475569; }
.btn-upload.is-disabled,
.btn-upload:disabled {
    background: #1f2937;
    border-color: #334155;
    color: #64748b;
    cursor: not-allowed;
    opacity: 0.75;
    transform: none;
}
.btn-upload.is-disabled:hover,
.btn-upload:disabled:hover {
    background: #1f2937;
}


/* =========================================
   5. PICKERS 
   ========================================= */
.picker-popup {
    position: absolute; bottom: 85px; left: 20px; width: 340px; height: 300px;
    background: var(--bg-sidebar); border: 1px solid var(--border-light);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); border-radius: 12px;
    z-index: 1000; display: none; flex-direction: column;
}
.picker-popup.show { display: flex !important; animation: slideUp 0.2s ease-out; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

#sticker-picker {
    width: min(410px, calc(100vw - 40px));
    height: min(390px, calc(100vh - 140px));
}

.picker-header {
    padding: 12px 15px; border-bottom: 1px solid var(--border-light);
    font-weight: 700; color: var(--text-primary); font-size: 13px;
    background: #0f172a; border-radius: 12px 12px 0 0;
    display: flex; justify-content: space-between; align-items: center;
}
.picker-close { color: var(--text-secondary); cursor: pointer; font-size: 20px; }
.picker-close:hover { color: #FF5959; }

.picker-content { flex: 1; overflow-y: auto; padding: 10px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.emoji-item { font-size: 24px; cursor: pointer; text-align: center; padding: 8px; border-radius: 6px; transition: 0.2s; }
.emoji-item:hover { background: var(--bg-hover); transform: scale(1.1); }

.picker-content-grid {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-rows: 54px;
    gap: 7px;
    align-content: start;
    min-height: 0;
}

.sticker-category-title {
    grid-column: 1 / -1;
    padding: 8px 2px 2px;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.sticker-category-title:first-child {
    padding-top: 0;
}

.picker-state {
    grid-column: 1 / -1;
    align-self: center;
    justify-self: center;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 86px;
    padding: 14px 16px;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 700;
}

.picker-state i {
    color: var(--accent-blue);
}

.picker-state.danger {
    color: #fecaca;
}

.picker-state.danger i {
    color: #f87171;
}

.picker-state.muted,
.picker-state.muted i {
    color: #94a3b8;
}

.sticker-item {
    width: 100%;
    height: 54px;
    border: 1px solid rgba(51, 65, 85, 0.85);
    border-radius: 8px;
    background:
        radial-gradient(circle at 50% 30%, rgba(56, 189, 248, 0.07), transparent 62%),
        rgba(15, 23, 42, 0.68);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.sticker-item:hover {
    border-color: rgba(56, 189, 248, 0.75);
    background:
        radial-gradient(circle at 50% 30%, rgba(56, 189, 248, 0.12), transparent 65%),
        rgba(51, 65, 85, 0.72);
    transform: translateY(-1px) scale(1.015);
}

.sticker-item img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.sticker-item img.loaded {
    opacity: 1;
    transform: scale(1);
}

/* GIFTS */
#gift-list {
    display: grid !important; grid-template-columns: repeat(3, 1fr) !important;
    grid-auto-rows: max-content; gap: 6px; padding: 8px;
    flex: 1; overflow-y: auto !important; overflow-x: hidden; min-height: 0; align-content: start;
}
.gift-item {
    position: relative; width: 100%; aspect-ratio: 1 / 1; background: #0f172a;
    border: 1px solid var(--border-light); border-radius: 8px; overflow: hidden; cursor: pointer; box-sizing: border-box; transition: border-color 0.2s;
}
.gift-item:hover { border-color: var(--accent-blue); }
.gift-img {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 90%; height: 90%; object-fit: contain; z-index: 1;
}
.gift-cost {
    position: absolute; top: 4px; right: 4px; z-index: 10;
    background: rgba(0, 0, 0, 0.8); color: var(--accent-blue);
    font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 10px; pointer-events: none;
}
.gift-name {
    position: absolute; bottom: 0; left: 0; width: 100%; z-index: 10;
    background: rgba(15, 23, 42, 0.9); color: var(--text-secondary);
    font-size: 9px; text-align: center; padding: 3px 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2;
}

/* =========================================
   POST MODAL STYLES (FINAL VISUAL)
   ========================================= */

.post-scroll-area { 
    flex: 1; 
    overflow-y: auto; 
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
    gap: 20px; 
}

.post-form-block { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    padding-bottom: 10px; 
    border-bottom: 1px solid var(--border-light); 
}

.post-history-title {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-left: 2px;
}

/* Текстовое поле */
.post-textarea {
    width: 100%; 
    min-height: 120px; 
    background: var(--input-bg); 
    border: 1px solid var(--input-border);
    color: var(--text-primary); 
    padding: 12px; 
    border-radius: 8px; 
    font-family: inherit; 
    font-size: 14px; 
    resize: vertical; 
    outline: none; 
    box-sizing: border-box;
}
.post-textarea:focus { border-color: var(--accent-blue); }

/* Зона аттачей (Создание) */
.post-attachments-area {
    min-height: 120px; 
    border: 2px dashed var(--border-light); 
    border-radius: 8px;
    display: flex; 
    align-items: center; 
    justify-content: flex-start; 
    padding: 4px; 
    overflow-x: auto; 
    gap: 10px; 
    background: #0f172a;
}

/* Кнопка Attach: Чуть уже (100px), высота та же (110px) */
.post-add-btn {
    width: 100px; 
    height: 110px; 
    border-radius: 8px; 
    background: var(--bg-hover); 
    color: var(--accent-blue);
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    flex-shrink: 0;
    border: 1px solid var(--border-light);
    font-size: 24px;
}
.post-add-btn:hover { background: #475569; border-color: var(--accent-blue); }

/* Превью создания: Чуть уже (100px), высота та же (110px) */
.post-preview-item { 
    width: 100px; 
    height: 110px; 
    border-radius: 8px; 
    overflow: hidden; 
    position: relative; 
    flex-shrink: 0; 
    border: 1px solid var(--border-light); 
}
.post-preview-item img { width: 100%; height: 100%; object-fit: cover; }

.post-remove-btn { 
    position: absolute; top: 4px; right: 4px; 
    width: 20px; height: 20px; 
    background: rgba(0,0,0,0.8); color: #ef4444; 
    border-radius: 50%; display: flex; 
    align-items: center; justify-content: center; 
    font-size: 12px; cursor: pointer; border: 1px solid rgba(255,255,255,0.2);
}
.post-remove-btn:hover { background: #ef4444; color: white; }

.btn-send-post-small {
    padding: 6px 16px;
    background: var(--accent-blue);
    color: #0f172a;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
    transition: 0.2s;
    text-transform: uppercase;
    align-self: flex-end;
}
.btn-send-post-small:hover { background: var(--accent-hover); color: white; }

/* --- HISTORY STYLES (UPDATED) --- */
.ph-item { 
    background: #0f172a; 
    border: 1px solid var(--border-light); 
    padding: 12px; 
    border-radius: 8px; 
    display: flex; 
    flex-direction: column; 
    gap: 4px; /* Уменьшили общий gap, отступы задаем внутри элементов */
}

/* Заголовок истории: только дата, справа */
.ph-header { 
    display: flex; 
    justify-content: flex-end; /* Дата справа */
    font-size: 10px; 
    color: var(--text-muted); 
    padding-bottom: 4px; 
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 8px;
}

/* Галерея истории (ВВЕРХУ) */
.ph-gallery { 
    display: flex; 
    gap: 5px; 
    overflow-x: auto; 
    padding-bottom: 4px; 
    margin-bottom: 8px; /* Отступ до текста */
}

/* Фото истории: 80x100 */
.ph-img { 
    width: 80px; 
    height: 100px; 
    border-radius: 6px; 
    object-fit: cover; 
    border: 1px solid var(--border-light); 
    flex-shrink: 0;
}

/* Текст (ВНИЗУ) */
.ph-text-wrap {
    position: relative; 
    padding-bottom: 5px;
}

.ph-text-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 55px; 
    overflow: hidden;
    padding-right: 60px;
    transition: max-height 0.2s ease;
}

.ph-view-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    color: var(--accent-blue);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    display: flex; align-items: center; gap: 4px;
    transition: 0.2s;
    z-index: 5;
}
.ph-view-btn:hover { background: #475569; border-color: var(--accent-blue); }


/* =========================================
   CHAT & INPUT LIMITS COUNTERS
   ========================================= */

/* Изменяем padding у поля ввода, чтобы текст не прятался под счетчиком (увеличили отступ снизу до 28px) */
.cf-input {
    padding: 12px 12px 28px 40px !important;
}

/* Дизайн счетчика */
.char-counter {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    pointer-events: none; /* Чтобы счетчик не блокировал клики по тексту */
    background: var(--input-bg);
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.2s;
    z-index: 10;
}

/* Когда лимит превышен (красный цвет) */
.char-counter.limit-exceeded {
    color: #ef4444; 
}

/* Отключенная кнопка Send */
.disabled-btn {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important; /* Полностью блокирует нажатия */
    background: var(--bg-hover) !important;
    color: var(--text-muted) !important;
    border-color: var(--border-light) !important;
}


#emoji-picker {
    height: auto;
    width: 316px;
}

#emoji-list {
    display: grid !important;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 260px;
    padding: 10px !important;
    overflow-y: auto !important;
}

#emoji-list .emoji-item {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-primary);
    font-size: 20px;
    line-height: 1;
}

#emoji-list .emoji-item:hover {
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.12);
}



/* =========================================
   2. MESSAGES AREA
   ========================================= */
.chat-viewport { 
    flex: 1; overflow-y: auto; padding: 20px; 
    display: flex; flex-direction: column; gap: 10px; 
    background-color: var(--bg-chat-pattern); 
    background-image: radial-gradient(#1e293b 1px, transparent 1px);
    background-size: 20px 20px;
}

/* 🔥 МАГИЯ: Невидимая пружина, которая толкает сообщения вниз */
#msg-list > :first-child,
.chat-viewport > :first-child {
    margin-top: auto !important;
}

.msg-row { display: flex; gap: 10px; max-width: 70%; align-items: flex-end; }
