/* chat-style.css */
body, html {
    margin: 0;
    padding: 0;
    height: 100dvh !important;
    overflow: hidden !important; /* Prevent body scroll, layout handles it */
}

body {
    display: flex;
    flex-direction: column;
}

.site-header {
    margin-top: 32px !important;
}

header {
    flex-shrink: 0;
    z-index: 100;
}

/* Remove footer from view if it exists */
footer, .footer {
    display: none !important;
}

.chat-layout {
    display: flex;
    flex: 1;
    position: relative;
    overflow: hidden; /* inner elements will scroll */
    background: var(--bg-color, #f4f6f9);
    font-family: 'Inter', sans-serif;
}

/* ── Sidebar ── */
.chat-sidebar {
    width: 300px;
    background: #ffffff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
}

.icon-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px 8px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background: #e9ecef;
    color: #FF6B00;
}

.room-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.room-item {
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.room-item:hover {
    background: #f8f9fa;
}

.room-item.active {
    background: #FFF3E0;
    border-left: 4px solid #FF6B00;
}

.room-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #FF6B00;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-right: 12px;
}

.room-icon.global {
    background: #198754;
}

.room-details {
    flex: 1;
    overflow: hidden;
}

.room-name {
    font-weight: 600;
    color: #333;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-desc-small {
    font-size: 0.8rem;
    color: #888;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Main Chat Area ── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #f4f6f9;
}

.room-header {
    padding: 15px 20px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #333;
    cursor: pointer;
    margin-right: 15px;
}

.room-info h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
}

.room-desc {
    font-size: 0.85rem;
    color: #6c757d;
}

.room-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.action-btn {
    background: #FFF3E0;
    color: #FF6B00;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

.action-btn:hover {
    background: #FFE0C2;
}

.room-stats {
    font-size: 0.9rem;
    color: #6c757d;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.welcome-message {
    text-align: center;
    margin-top: auto;
    margin-bottom: auto;
    color: #6c757d;
}

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 80%;
}

.chat-message.self {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #ccc;
}

.msg-content-wrapper {
    display: flex;
    flex-direction: column;
}

.msg-bubble {
    background: #ffffff;
    padding: 10px 14px;
    border-radius: 0 12px 12px 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    position: relative;
    word-break: break-word;
}

.chat-message.self .msg-bubble {
    background: #FF6B00;
    color: white;
    border-radius: 12px 0 12px 12px;
}

.msg-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.msg-author {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
}

.chat-message.self .msg-author {
    display: none;
}

.msg-time {
    font-size: 0.75rem;
    color: #888;
}

.chat-message.self .msg-time {
    color: rgba(255,255,255,0.8);
}

.msg-image {
    max-width: 100%;
    max-height: 250px;
    width: auto;
    object-fit: contain;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
}

.msg-reply-box {
    background: rgba(0,0,0,0.05);
    border-left: 3px solid #FF6B00;
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.chat-message.self .msg-reply-box {
    background: rgba(255,255,255,0.2);
    border-left-color: #fff;
}

.msg-reply-author {
    font-weight: bold;
    display: block;
    margin-bottom: 2px;
}

/* ── Chat Input ── */
.chat-input-area {
    background: #ffffff;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
}

.reply-preview, .image-preview-box {
    background: #f8f9fa;
    border-left: 4px solid #FF6B00;
    padding: 8px 12px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

#imagePreview {
    max-height: 60px;
    border-radius: 4px;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #f4f6f9;
    padding: 8px 15px;
    border-radius: 24px;
    border: 1px solid #e0e0e0;
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    max-height: 120px;
    padding: 8px 0;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
}

.send-btn {
    color: #FF6B00;
    background: #FFF3E0;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: #FF6B00;
    color: white;
}

/* ── Modals ── */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fff;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h4 {
    margin: 0;
    font-size: 1.25rem;
    color: #333;
}

.close-modal {
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    color: #888;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #333;
}

.modal-body input[type="text"], 
.modal-body textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.modal-body input[type="text"]:focus, 
.modal-body textarea:focus {
    outline: none;
    border-color: #FF6B00;
}

.modal-body .btn {
    width: 100%;
    padding: 12px;
    background: #FF6B00;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.modal-body .btn:hover {
    background: #E65100;
}

/* ── Responsive ── */
.sidebar-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 990;
}

@media (max-width: 768px) {
    .chat-sidebar {
        position: absolute;
        left: -300px;
        height: 100%;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
        z-index: 1000;
    }

    .chat-sidebar.open {
        transform: translateX(300px);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .msg-image {
        max-height: 200px;
    }

    .mobile-toggle-btn {
        display: block;
    }

    .desktop-only {
        display: none;
    }
}
