/* ============================================
   Chat / Messages Page — Luxury Light Theme
   Canvas #f4efe6 · Card #ffffff · Border #e8e2d8
   Obsidian #18181b · Copper #b86d26 · Muted #6b7280
   ============================================ */

.chat-shell {
    padding: 1.5rem clamp(1.25rem, 2.5vw, 2.5rem);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    color: #18181b;
    background: #f4efe6;
    min-height: 100vh;
    box-sizing: border-box;
}

/* ── Role Switcher ── */
.ch-role-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #18181b;
    border-radius: 16px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1.25rem;
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.ch-role-text {
    font-size: 0.8125rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
}

.ch-role-text strong {
    color: #b86d26;
    font-weight: 700;
}

.ch-role-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    background: rgba(184, 109, 38, 0.2);
    color: #f3ad67;
    border: 1px solid rgba(184, 109, 38, 0.35);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ch-role-btn:hover {
    background: #b86d26;
    color: #ffffff;
}

/* ── Chat Container ── */
.ch-container {
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid #e8e2d8;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    height: calc(100vh - 220px);
    min-height: 520px;
    display: grid;
    grid-template-columns: 320px 1fr;
}

/* ── Sidebar ── */
.ch-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e8e2d8;
    height: 100%;
    overflow: hidden;
    background: #ffffff;
}

.ch-sidebar-header {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid #e8e2d8;
}

.ch-sidebar-title {
    font-size: 1rem;
    font-weight: 700;
    color: #18181b;
    margin: 0 0 0.75rem 0;
    letter-spacing: -0.01em;
}

.ch-new-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    background: #18181b;
    color: #ffffff;
    border: none;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ch-new-btn:hover {
    background: #b86d26;
}

.ch-search {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #f0ebe1;
}

.ch-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e8e2d8;
    border-radius: 10px;
    font-size: 0.8125rem;
    color: #18181b;
    background: #faf7f2;
    transition: all 0.15s ease;
    box-sizing: border-box;
}

.ch-search-input:focus {
    outline: none;
    border-color: #b86d26;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(184, 109, 38, 0.12);
}

.ch-search-input::placeholder {
    color: #9ca3af;
}

/* ── Conversation List ── */
.ch-convos {
    flex: 1;
    overflow-y: auto;
}

.ch-convo {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    border-bottom: 1px solid #f0ebe1;
    transition: all 0.15s ease;
}

.ch-convo:hover {
    background: #faf7f2;
}

.ch-convo.active {
    background: rgba(184, 109, 38, 0.08);
    border-left: 3px solid #b86d26;
}

.ch-convo-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.ch-convo-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.ch-convo-avatar.owner {
    background: rgba(184, 109, 38, 0.12);
    color: #b86d26;
}
.ch-convo-avatar.client {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}
.ch-convo-avatar.support {
    background: rgba(24, 24, 27, 0.08);
    color: #18181b;
}

.ch-online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.ch-convo-body {
    flex: 1;
    min-width: 0;
}

.ch-convo-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}

.ch-convo-name {
    font-size: 0.84rem;
    font-weight: 700;
    color: #18181b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ch-convo-time {
    font-size: 0.625rem;
    color: #9ca3af;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.ch-convo-preview {
    font-size: 0.75rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

.ch-convo-badge {
    font-size: 0.625rem;
    font-weight: 700;
    background: #b86d26;
    color: #ffffff;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    min-width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
    align-self: center;
}

/* ── Chat Window ── */
.ch-window {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: #ffffff;
}

.ch-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.95rem 1.25rem;
    border-bottom: 1px solid #e8e2d8;
    background: #ffffff;
}

.ch-window-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ch-window-info h6 {
    font-size: 0.88rem;
    font-weight: 700;
    color: #18181b;
    margin: 0;
}

.ch-window-status {
    font-size: 0.6875rem;
    color: #6b7280;
}

.ch-window-status .online {
    color: #059669;
    font-weight: 600;
}

.ch-window-actions {
    display: flex;
    gap: 0.35rem;
}

.ch-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ch-action-btn:hover {
    background: #faf7f2;
    color: #18181b;
}

/* ── Messages Area ── */
.ch-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: #faf7f2;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ch-msg {
    display: flex;
    max-width: 75%;
}

.ch-msg-sent {
    align-self: flex-end;
}

.ch-msg-received {
    align-self: flex-start;
}

.ch-bubble {
    padding: 0.65rem 0.95rem;
    border-radius: 14px;
    position: relative;
    line-height: 1.45;
}

.ch-msg-sent .ch-bubble {
    background: #18181b;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ch-msg-received .ch-bubble {
    background: #ffffff;
    color: #18181b;
    border-bottom-left-radius: 4px;
    border: 1px solid #e8e2d8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.ch-bubble p {
    font-size: 0.84rem;
    margin: 0;
}

.ch-bubble-meta {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.25rem;
}

.ch-bubble-time {
    font-size: 0.625rem;
    opacity: 0.65;
}

.ch-bubble-read {
    font-size: 0.6875rem;
}

.ch-msg-sent .ch-bubble-read {
    color: #b86d26;
}

.ch-msg-sent .ch-bubble-read.unread {
    color: rgba(255, 255, 255, 0.4);
}

/* Typing Indicator */
.ch-typing {
    display: flex;
    gap: 0.25rem;
    padding: 0.35rem 0;
}

.ch-typing span {
    width: 6px;
    height: 6px;
    background: #b86d26;
    border-radius: 50%;
    animation: chTyping 1.4s infinite;
}

.ch-typing span:nth-child(2) { animation-delay: 0.2s; }
.ch-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chTyping {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ── Message Input ── */
.ch-input-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid #e8e2d8;
    background: #ffffff;
}

.ch-input-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.ch-input-icon:hover {
    color: #b86d26;
    background: #faf7f2;
}

.ch-input-field {
    flex: 1;
    padding: 0.55rem 0.85rem;
    border: 1px solid #e8e2d8;
    border-radius: 10px;
    font-size: 0.84rem;
    color: #18181b;
    background: #faf7f2;
    transition: all 0.15s ease;
    box-sizing: border-box;
}

.ch-input-field:focus {
    outline: none;
    border-color: #b86d26;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(184, 109, 38, 0.12);
}

.ch-input-field::placeholder {
    color: #9ca3af;
}

.ch-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #b86d26;
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(184, 109, 38, 0.3);
}

.ch-send-btn:hover {
    background: #a25c1a;
    transform: translateY(-1px);
}

/* ── Empty State ── */
.ch-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: #9ca3af;
}

.ch-empty i {
    font-size: 2.75rem;
    color: rgba(184, 109, 38, 0.3);
}

.ch-empty-title {
    font-size: 1rem;
    font-weight: 700;
    color: #18181b;
}

.ch-empty-desc {
    font-size: 0.8125rem;
    color: #6b7280;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 992px) {
    .ch-container {
        grid-template-columns: 260px 1fr;
    }
}

@media (max-width: 768px) {
    .chat-shell {
        padding: 1rem;
    }
    .ch-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 180px);
    }
    .ch-sidebar {
        display: none;
    }
    .ch-role-bar {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}
