/* client/css/chat/chat.css */

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: #1a1a1a;
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid #444;
    background-color: #2a2a2a;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-header h3 {
    margin: 0;
    color: #ff8c00;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-row {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    max-width: 80%;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #ff8c00;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.message-content-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.message-sender {
    font-size: 0.9rem;
    color: #ff8c00;
}

.message-time {
    font-size: 0.7rem;
    color: #aaa;
}

.message-text {
    color: #f0f0f0;
    overflow-wrap: break-word;
    word-wrap: break-word;
    white-space: pre-wrap;
    max-width: 100%;
}

.message-input-area {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-top: 1px solid #444;
    background-color: #2a2a2a;
    flex-shrink: 0;
    gap: 0.5rem;
}

.message-input-area textarea {
    flex: 1;
    padding: 0.4rem 0.5rem;
    background-color: #1a1a1a;
    border: 1px solid #444;
    color: #fff;
    margin-right: 0;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.4;
    height: 38px;
    min-height: 38px;
    max-height: 128px;
    overflow-y: auto;
    box-sizing: border-box;
}

.message-input-area button {
    background-color: #ff8c00;
    color: #1a1a1a;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: bold;
    align-self: center;
    flex-shrink: 0;
}

.message-input-area button:hover {
    background-color: #e67e00;
}

/* === Панель активного личного звонка (1-1) === */
.call-active-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: #2a2a2a;
    border-bottom: 2px solid #ff8c00;
    flex-shrink: 0;
    height: 500px;
    box-sizing: border-box;
    position: relative;
}

.call-active-panel .participants {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    margin: auto 0;
    height: 100%;
}

.call-active-panel .participant {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 480px;
    height: 270px;
    position: relative;
}

.call-active-panel .participant-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: #ff8c00;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    font-weight: bold;
    border: 3px solid #ff8c00;
}

.call-active-panel .participant-video {
    width: 480px;
    height: 270px;
    border-radius: 8px;
    object-fit: contain;
    background-color: #000;
    border: 3px solid #ff8c00;
}

.volume-control {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
}

.volume-control input[type=range] {
    width: 120px;
    height: 2px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    margin: 0 auto;
    display: block;
}

.volume-control input[type=range]::-webkit-slider-runnable-track {
    height: 2px;
    background: linear-gradient(to right, #ff8c00 0%, #ff8c00 var(--volume, 0%), #444 var(--volume, 0%), #444 100%);
    border-radius: 1px;
}

.volume-control input[type=range]::-moz-range-track {
    height: 2px;
    background: linear-gradient(to right, #ff8c00 0%, #ff8c00 var(--volume, 0%), #444 var(--volume, 0%), #444 100%);
    border-radius: 1px;
}

.volume-control input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #ff8c00;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -5px;
    border: none;
}

.volume-control input[type=range]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #ff8c00;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.watch-control {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.watch-button, .unwatch-button, .pip-button {
    background: #ff8c00;
    border: none;
    color: #1a1a1a;
    font-size: 0.9rem;
    padding: 0.3rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.watch-button:hover, .unwatch-button:hover, .pip-button:hover {
    background: #e67e00;
}

.pip-button {
    font-size: 1rem;
    padding: 0.3rem 0.8rem;
}

.call-actions {
    display: flex;
    gap: 1rem;
    margin-top: auto;
    margin-bottom: 0.5rem;
}

.mic-button,
.screen-button {
    background: #444;
    border: none;
    color: white;
    font-size: 1.2rem;
    padding: 0.4rem 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.mic-button:hover,
.screen-button:hover {
    background: #555;
}

.hangup-button {
    background: #ff4d4d;
    border: none;
    color: white;
    font-size: 1.2rem;
    padding: 0.4rem 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.hangup-button:hover {
    background: #ff1a1a;
}

.chat-container.has-call .messages-list {
    height: calc(100% - 500px - 60px);
}

/* === Стили для списка диалогов (сайдбар) === */
.dialogs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.dialogs-header h3 {
    margin: 0;
    color: #ff8c00;
}

.add-dialog-btn {
    background: #ff8c00;
    color: #1a1a1a;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.add-dialog-btn:hover {
    background: #e67e00;
}

.group-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 10px;
    background: #ff8c00;
    border-radius: 50%;
    padding: 2px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-actions {
    display: flex;
    align-items: center;
    margin-left: auto;
    padding-left: 0.5rem;
}

.dialog-actions button {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.2rem;
    opacity: 0.7;
    transition: color 0.2s, opacity 0.2s;
}

.dialog-actions button:hover {
    opacity: 1;
    color: #ff4d4d;
}

/* === Модальное окно создания группы === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #2a2a2a;
    border: 2px solid #ff8c00;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    color: #f0f0f0;
}

.modal h3 {
    margin-top: 0;
    color: #ff8c00;
}

.modal label {
    display: block;
    margin: 1rem 0 0.5rem;
}

.modal input[type=text] {
    width: 100%;
    padding: 0.5rem;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #fff;
}

.friends-select {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #444;
    padding: 0.5rem;
    background: #1a1a1a;
}

.friend-checkbox {
    display: block;
    margin: 0.3rem 0;
    cursor: pointer;
}

.friend-checkbox input {
    margin-right: 0.5rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: flex-end;
}

.modal-buttons button {
    padding: 0.5rem 1.5rem;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

.modal-buttons button:first-child {
    background: #ff8c00;
    color: #1a1a1a;
}

.modal-buttons button:last-child {
    background: #444;
    color: #fff;
}

/* === Контейнер чата с боковой панелью === */
.chat-container.with-sidebar {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #1a1a1a;
}

.chat-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.group-sidebar {
    width: 260px;
    flex: 0 0 auto;
    background-color: #2a2a2a;
    border-left: 1px solid #444;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.group-sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.group-sidebar-header h4 {
    margin: 0;
    color: #ff8c00;
    font-size: 1rem;
}

.group-sidebar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.member-count {
    background-color: #444;
    color: #fff;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.8rem;
}

.members-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    gap: 0.5rem;
    border-radius: 4px;
    cursor: default;
}

.member-item:hover {
    background-color: #333;
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #ff8c00;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    flex-shrink: 0;
}

.member-nickname {
    flex: 1;
    color: #f0f0f0;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-badge {
    font-size: 0.7rem;
    color: #aaa;
    margin-left: 0.2rem;
    flex-shrink: 0;
}

.member-badge.creator {
    color: gold;
}

.member-badge.admin {
    color: #ff8c00;
}

.add-member-btn {
    background: #ff8c00;
    color: #1a1a1a;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-left: 0.5rem;
}

.add-member-btn:hover {
    background: #e67e00;
}

.remove-member-btn {
    background: none;
    border: none;
    color: #ff4d4d;
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.2rem;
    opacity: 0.7;
}

.remove-member-btn:hover {
    opacity: 1;
    color: #ff1a1a;
}

.leave-group-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.2rem;
    opacity: 0.8;
    transition: color 0.2s, opacity 0.2s;
}

.leave-group-btn:hover {
    color: #ff4d4d;
    opacity: 1;
}

.chat-container.with-sidebar.sidebar-hidden .group-sidebar {
    display: none;
}

.toggle-sidebar-btn {
    background: none;
    border: none;
    color: #ff8c00;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.5rem;
    flex-shrink: 0;
}

.toggle-sidebar-btn:hover {
    color: #e67e00;
}

/* === Панель группового звонка === */
.group-call-panel {
    background-color: #2a2a2a;
    border-bottom: 2px solid #ff8c00;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-shrink: 0;
}

.call-participants-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    align-items: center;
    min-height: 150px;
}

.call-participant {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
    min-width: 90px;
    min-height: 220px;
    justify-content: flex-start;
}

.call-participant .participant-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background-color: #ff8c00;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.participant-avatar-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 0.5rem;
    padding-top: 25px;
}

.participant-avatar-wrapper .watch-screen-btn {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff8c00;
    border: none;
    color: #1a1a1a;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    white-space: nowrap;
    z-index: 2;
    transition: background 0.2s;
}

.participant-avatar-wrapper .watch-screen-btn:hover {
    background: #e67e00;
}

.participant-screen-container {
    position: relative;
    width: 360px;
    height: 203px;
    margin-bottom: 0.5rem;
    background: #000;
    border: 2px solid #ff8c00;
    border-radius: 8px;
    overflow: hidden;
}

.participant-screen-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.screen-controls {
    position: absolute;
    top: 10px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    pointer-events: none;
}

.screen-controls button {
    pointer-events: auto;
    background: #ff8c00;
    border: none;
    color: #1a1a1a;
    font-size: 0.9rem;
    padding: 0.3rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.screen-controls button:hover {
    background: #e67e00;
}

.participant-volume {
    margin-top: 0.3rem;
    width: 100%;
    display: flex;
    justify-content: center;
    min-height: 30px;
}

.participant-volume input[type=range] {
    width: 120px;
    height: 2px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    margin: 0 auto;
    display: block;
}

.participant-volume input[type=range]::-webkit-slider-runnable-track {
    height: 2px;
    background: linear-gradient(to right, #ff8c00 0%, #ff8c00 var(--volume, 0%), #444 var(--volume, 0%), #444 100%);
    border-radius: 1px;
}

.participant-volume input[type=range]::-moz-range-track {
    height: 2px;
    background: linear-gradient(to right, #ff8c00 0%, #ff8c00 var(--volume, 0%), #444 var(--volume, 0%), #444 100%);
    border-radius: 1px;
}

.participant-volume input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #ff8c00;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -5px;
    border: none;
}

.participant-volume input[type=range]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #ff8c00;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.call-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 0.5rem;
}

.call-controls button {
    background: #444;
    border: none;
    color: white;
    font-size: 1.2rem;
    padding: 0.5rem 1.5rem;
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.2s;
}

.call-controls button:hover {
    background: #555;
}

.call-controls .end-call-btn {
    background: #ff4d4d;
}

.call-controls .end-call-btn:hover {
    background: #ff1a1a;
}

.group-call-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.5rem;
    color: #ff8c00;
    transition: color 0.2s;
    flex-shrink: 0;
}
.group-call-button:hover {
    color: #e67e00;
}
.group-call-button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.join-call-btn {
    background: #ff8c00;
    border: none;
    color: #1a1a1a;
    font-size: 1.2rem;
    padding: 0.5rem 1.5rem;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
    margin-top: 0.5rem;
}

.join-call-btn:hover {
    background: #e67e00;
}

.call-info {
    color: #ff8c00;
    font-size: 1.2rem;
    text-align: center;
    padding: 1rem;
}

/* Активный диалог */
.dialog-item.active {
    background-color: #3a3a3a;
    border-left: 3px solid #ff8c00;
}