/* === ОСНОВНОЙ КОНТЕЙНЕР === */
body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    padding: 20px;
    background: #f5f7fa;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* === ЗАГОЛОВОК === */
header {
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

header h1 {
    margin: 0;
    font-size: 1.4em;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

header h1 .channel-label {
    font-size: 0.9em;
    color: #bdc3c7;
    font-weight: normal;
}

header h1 .channel-id {
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    background: #34495e;
    color: #1abc9c;
    padding: 4px 8px;
    border-radius: 6px;
    word-break: break-all;
    text-align: center;
    white-space: normal;
    max-width: 100%;
    line-height: 1.2;
    font-weight: bold;
}

header button {
    padding: 8px 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* === ОБЛАСТЬ ЧАТА (прокручиваемая) === */
.chat {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    position: relative; /* 🔥 Чтобы drop-zone был внутри */
}

/* === ЗОНА ПЕРЕТАСКИВАНИЯ — МЕЖДУ ЧАТОМ И ПАНЕЛЬЮ ВВОДА === */
.drop-zone {
    background: #f0f9ff;
    border: 2px dashed #27ae60;
    border-radius: 8px;
    color: #27ae60;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 16px;
    text-align: center;
    opacity: 0;
    height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, height 0.3s ease;
    margin: 0 12px 8px;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;

}

.drop-zone.highlight {
    opacity: 1;
    height: 48px; /* ✅ Достаточно для строки текста */
    pointer-events: auto;
}


/* === СООБЩЕНИЯ === */
.message {
    padding: 10px 14px;
    border-radius: 10px;
    max-width: 80%;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.message.received {
    background: #e8f4f8;
    align-self: flex-start;
    text-align: left;
}

.message.sent {
    background: #d4edda;
    align-self: flex-end; /* ✅ Вместо margin-left: auto */
    text-align: right;
}

/* === ПАНЕЛЬ ВВОДА === */
.controls {
    padding: 12px;
    display: flex;
    gap: 8px;
    background: white;
    border-top: 1px solid #eee;
    position: sticky;
    bottom: 0;
    z-index: 10;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.05);
}

.controls input[type="text"] {
    flex: 1; /* 🔥 Занимает всё свободное место */
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    min-width: 0;
}

.controls button {
    padding: 10px 12px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: background 0.2s;
}

.controls button:hover {
    background: #219a52;
}

/* === ИНФО-ПАНЕЛЬ === */
.info {
    padding: 10px 15px;
    background: #f0f0f0;
    font-size: 0.9em;
    color: #555;
    border-top: 1px solid #eee;
    position: sticky;
    bottom: 0;
    z-index: 9;
}

/* === ИМЯ ПОЛЬЗОВАТЕЛЯ === */
#my-name-badge {
    color: #1e90ff;
    font-size: 0.95em;
    margin: 5px 0 0;
    font-weight: 500;
    padding: 6px 12px;
    background: #f0f8ff;
    border-radius: 6px;
    display: inline-block;
    border: 1px solid #d0ebff;
}

/* === ИЗОБРАЖЕНИЯ В ЧАТЕ === */
.chat img.chat-image {
    max-width: var(--chat-image-width, 80%);
    height: auto;
    border-radius: 8px;
    margin-top: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    display: block;
}

/* === АДАПТИВНОСТЬ === */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 8px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        height: calc(100vh - 20px);
    }

    header {
        padding: 12px 15px;
        gap: 8px;
    }

    header h1 {
        font-size: 1.2em;
        max-width: 160px;
    }

    .chat {
        padding: 12px;
        gap: 6px;
    }

    .message {
        max-width: 85%;
        padding: 8px 12px;
        font-size: 13px;
    }

    .controls {
        padding: 10px;
        gap: 6px;
    }

    .controls input[type="text"] {
        padding: 8px;
        font-size: 13px;
    }

    .controls button {
        padding: 8px 10px;
        font-size: 13px;
    }

    .info {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    #my-name-badge {
        font-size: 0.9em;
        padding: 5px 10px;
    }
}

@media (max-width: 380px) {
    .controls {
        flex-wrap: wrap;
    }

    .controls input[type="text"] {
        min-width: 120px;
        flex: 1;
    }

    .controls button {
        padding: 8px 10px;
        font-size: 12px;
        min-width: 70px;
    }

    header h1 {
        max-width: 120px;
        font-size: 1.1em;
    }
}
