/* ═══════════════════════════════════════════
   CHAT LOCAL — стилі чату міста
   /css/chat_local/style.css
═══════════════════════════════════════════ */

/* ── Превью на сторінці міста ─────────────── */
.city-chat-preview {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    margin: 20px 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.city-chat-preview__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #111;
    color: #fff;
}
.city-chat-preview__title {
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 0.3px;
}
.city-chat-preview__open {
    font-size: 13px;
    color: #bbb;
    text-decoration: none;
    transition: color 0.2s;
}
.city-chat-preview__open:hover { color: #fff; }
.city-chat-preview__messages {
    padding: 12px 16px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.city-chat-preview__empty {
    color: #aaa;
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}
.city-chat-preview__footer {
    border-top: 1px solid #eee;
    padding: 10px 16px;
}
.city-chat-preview__footer a {
    display: block;
    text-align: center;
    background: #111;
    color: #fff;
    padding: 9px 0;
    border-radius: 7px;
    font-size: 14px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
}
.city-chat-preview__footer a:hover { background: #333; }

/* ── Превью повідомлень (міні на сторінці міста) ── */
.chat-mini-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 13px;
}
.chat-mini-msg__ava {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ddd;
    flex-shrink: 0;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #555;
}
.chat-mini-msg__body { flex: 1; min-width: 0; }
.chat-mini-msg__name { font-weight: 600; color: #333; font-size: 12px; }
.chat-mini-msg__text {
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-mini-msg__time { font-size: 11px; color: #aaa; margin-left: auto; flex-shrink: 0; }

/* ═══════════════════════════════════════════
   ПОВНИЙ ЧАТ
═══════════════════════════════════════════ */

/* Сторінка чату — займає весь viewport без прокрутки body */
.chat-page-wrap {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #f0f0f0;
    /* Safe area для iPhone з чубчиком */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Шапка */
.chat-page__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #111;
    color: #fff;
    flex-shrink: 0;
    z-index: 10;
}
.chat-page__back {
    color: #ccc;
    text-decoration: none;
    font-size: 22px;
    line-height: 1;
    transition: color 0.2s;
    padding: 4px;
}
.chat-page__back:hover { color: #fff; }
.chat-page__title {
    font-size: 16px;
    font-weight: bold;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Список повідомлень */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #f0f0f0;
    scroll-behavior: smooth;
    /* щоб клавіатура не перекривала на iOS */
    overscroll-behavior: contain;
}

/* Роздільник дня */
.chat-day-sep {
    text-align: center;
    font-size: 11px;
    color: #888;
    margin: 8px 0 4px;
    position: relative;
}
.chat-day-sep::before,
.chat-day-sep::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 28%;
    height: 1px;
    background: #ccc;
}
.chat-day-sep::before { left: 0; }
.chat-day-sep::after  { right: 0; }

/* ── Рядок повідомлення (аватар + бульбашка) ── */
.chat-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    max-width: 80%;
}
.chat-msg-row--mine  {
    align-self: flex-end;
    flex-direction: row-reverse; /* аватар праворуч для своїх — не показуємо */
}
.chat-msg-row--other {
    align-self: flex-start;
}

/* Аватар */
.chat-msg-row__ava {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ccc;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    align-self: flex-end;
    margin-bottom: 2px;
}
.chat-msg-row__ava img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
/* Для своїх повідомлень аватар не показуємо */
.chat-msg-row--mine .chat-msg-row__ava {
    display: none;
}
/* Плейсхолдер-ширина щоб свої не зміщувались */
.chat-msg-row--mine .chat-msg-row__ava-placeholder {
    width: 0;
    flex-shrink: 0;
}

/* Колонка: ім'я + бульбашка */
.chat-msg-row__col {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.chat-msg-row--mine .chat-msg-row__col {
    align-items: flex-end;
}

/* Ім'я над бульбашкою (тільки для чужих) */
.chat-msg__name {
    font-size: 11px;
    color: #888;
    padding: 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}
.chat-msg-row--mine .chat-msg__name { display: none; }

/* Бульбашка */
.chat-msg__bubble {
    padding: 7px 10px 18px 10px; /* знизу місце для часу */
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
    min-width: 60px;
}
.chat-msg-row--mine .chat-msg__bubble {
    background: #111;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-row--other .chat-msg__bubble {
    background: #fff;
    color: #222;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.10);
}

/* Час — всередині бульбашки, правий нижній кут (як у Telegram) */
.chat-msg__time {
    position: absolute;
    right: 8px;
    bottom: 4px;
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
}
.chat-msg-row--mine .chat-msg__time  { color: rgba(255,255,255,0.6); }
.chat-msg-row--other .chat-msg__time { color: #aaa; }

/* ── Форма введення ───────────────────────── */
.chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
    z-index: 10;
}
.chat-input-bar textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 16px; /* 16px — не зумить на iOS */
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 40px;
    line-height: 1.4;
    font-family: inherit;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}
.chat-input-bar textarea:focus { border-color: #333; }

.chat-input-bar button {
    background: #111;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.chat-input-bar button:hover    { background: #333; }
.chat-input-bar button:disabled { background: #ccc; cursor: default; }

/* Банер "не можете писати" */
.chat-no-write {
    padding: 10px 16px;
    background: #f8f8f8;
    border-top: 1px solid #eee;
    text-align: center;
    font-size: 13px;
    color: #777;
    flex-shrink: 0;
}
.chat-no-write a {
    color: #111;
    text-decoration: underline;
}

/* ── Адаптив ──────────────────────────────── */
@media (max-width: 1024px) {
    .chat-msg-row { max-width: 88%; }
}

/* Десктоп: chat-page-wrap не fixed, вбудовується в лейаут */
@media (min-width: 1025px) {
    .chat-page-wrap {
        position: relative;
        inset: auto;
        height: calc(100vh - 120px);
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 2px 12px rgba(0,0,0,0.08);
        border: 1px solid #e0e0e0;
        padding: 0;
    }
}