/* KwikConnectHub - Messages Page Styles */

:root {
    --emerald: #059669;
    --emerald-light: #d1fae5;
    --emerald-dark: #065f46;
    --teal: #0d9488;
    --surface: #f8faf9;
    --white: #ffffff;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --radius: 14px;
    --radius-sm: 10px;
    --navbar-h: 64px;
    --conv-w: 320px;
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow: hidden; }
body { font-family: 'Inter', sans-serif; background: var(--surface); color: var(--text); margin: 0; height: 100vh; overflow: hidden; }
::selection { background: var(--emerald-light); color: var(--emerald-dark); }
:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* ── NAVBAR ── */
.navbar {
    position: fixed; top: 0; width: 100%;
    height: var(--navbar-h);
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.nav-inner {
    max-width: 100%; padding: 0 1.5rem;
    height: 100%; display: flex; align-items: center; gap: 1rem;
}

.nav-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.nav-logo-mark {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--emerald), var(--teal));
    border-radius: 9px; display: flex; align-items: center;
    justify-content: center; color: white; font-weight: 800; font-size: 0.9rem;
}
.nav-logo-text {
    font-weight: 700; font-size: 1.1rem;
    background: linear-gradient(135deg, var(--emerald-dark), var(--teal));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.nav-spacer { flex: 1; }
.nav-right  { display: flex; align-items: center; gap: 0.5rem; }

.nav-avatar-wrap {
    position: relative; display: flex; align-items: center;
    gap: 8px; cursor: pointer; padding: 6px 10px;
    border-radius: var(--radius-sm); transition: background 0.2s;
}
.nav-avatar-wrap:hover { background: var(--border-light); }
.nav-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--emerald), var(--teal));
    color: white; font-weight: 700; font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.nav-avatar-name { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.nav-chevron { width: 14px; height: 14px; color: var(--text-muted); }

.avatar-dropdown {
    position: absolute; top: calc(100% + 6px); right: 0;
    width: 200px; background: var(--white);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-md); z-index: 200; padding: 0.4rem;
}
.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 0.6rem 0.75rem; border-radius: 8px;
    font-size: 0.875rem; color: var(--text);
    text-decoration: none; transition: background 0.15s;
}
.dropdown-item i { width: 15px; height: 15px; color: var(--text-muted); }
.dropdown-item:hover { background: var(--border-light); }
.dropdown-item.danger { color: #ef4444; }
.dropdown-item.danger i { color: #ef4444; }
.dropdown-divider { height: 1px; background: var(--border); margin: 0.3rem 0; }

/* ── MESSAGES LAYOUT ── */
.messages-layout {
    display: flex;
    height: calc(100vh - var(--navbar-h));
    margin-top: var(--navbar-h);
    overflow: hidden;
}

/* ── CONVERSATIONS PANEL ── */
.conv-panel {
    width: var(--conv-w);
    flex-shrink: 0;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.conv-header {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
.conv-title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin: 0; }

.conv-search-wrap {
    position: relative; padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.conv-search-icon {
    position: absolute; left: 1.75rem; top: 50%;
    transform: translateY(-50%); width: 15px; height: 15px;
    color: var(--text-muted); pointer-events: none;
}
.conv-search-input {
    width: 100%; padding: 0.55rem 0.85rem 0.55rem 2.25rem;
    border: 1.5px solid var(--border); border-radius: 50px;
    font-family: 'Inter', sans-serif; font-size: 0.82rem;
    background: var(--surface); outline: none; transition: all 0.2s;
}
.conv-search-input:focus { border-color: var(--emerald); background: var(--white); }

.conv-list { flex: 1; overflow-y: auto; }

/* Conversation item */
.conv-item {
    display: flex; align-items: center; gap: 10px;
    padding: 0.85rem 1.25rem; cursor: pointer;
    transition: background 0.15s; border-bottom: 1px solid var(--border-light);
}
.conv-item:hover { background: var(--surface); }
.conv-item.active { background: var(--emerald-light); }

.conv-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, var(--emerald-light), #a7f3d0);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; color: var(--emerald-dark);
    flex-shrink: 0; overflow: hidden; position: relative;
}
.conv-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.online-badge {
    position: absolute; bottom: 1px; right: 1px;
    width: 11px; height: 11px;
    background: #22c55e; border-radius: 50%; border: 2px solid white;
}

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

.conv-name {
    font-size: 0.875rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 3px;
}
.conv-preview {
    font-size: 0.78rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-preview.unread { color: var(--text); font-weight: 500; }

.conv-meta {
    display: flex; flex-direction: column;
    align-items: flex-end; gap: 4px; flex-shrink: 0;
}
.conv-time { font-size: 0.72rem; color: var(--text-muted); }

.unread-badge {
    min-width: 18px; height: 18px;
    background: var(--emerald); color: white;
    border-radius: 50px; font-size: 0.68rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* Empty state */
.conv-empty {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 0.5rem; padding: 2rem; text-align: center; color: var(--text-muted);
}
.conv-empty i  { width: 40px; height: 40px; opacity: 0.3; }
.conv-empty h3 { font-size: 0.9rem; font-weight: 600; color: var(--text); margin: 0; }
.conv-empty p  { font-size: 0.8rem; margin: 0; }

/* ── CHAT PANEL ── */
.chat-panel {
    flex: 1; display: flex;
    flex-direction: column; overflow: hidden;
    background: var(--surface);
}

/* Empty state */
.chat-empty-state {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 0.75rem; text-align: center; padding: 2rem;
    color: var(--text-muted);
}
.chat-empty-icon {
    width: 72px; height: 72px;
    background: var(--border-light); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 0.5rem;
}
.chat-empty-icon i { width: 32px; height: 32px; color: #d1d5db; }
.chat-empty-state h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin: 0; }
.chat-empty-state p  { font-size: 0.875rem; margin: 0; }

/* Active chat */
.chat-active {
    flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

/* Chat header */
.chat-header {
    display: flex; align-items: center; gap: 10px;
    padding: 1rem 1.25rem; background: var(--white);
    border-bottom: 1px solid var(--border); flex-shrink: 0;
}

.back-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 4px; display: flex;
    align-items: center; transition: color 0.2s;
}
.back-btn i { width: 20px; height: 20px; }
.back-btn:hover { color: var(--text); }

.chat-header-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, var(--emerald-light), #a7f3d0);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; color: var(--emerald-dark);
    flex-shrink: 0; overflow: hidden;
}
.chat-header-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.chat-header-info { flex: 1; min-width: 0; }
.chat-name   { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.chat-status { display: flex; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--text-muted); }

.status-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #d1d5db; flex-shrink: 0;
}
.status-dot.online { background: #22c55e; }

.chat-header-actions { display: flex; gap: 4px; }

/* Messages area */
.messages-area {
    flex: 1; overflow-y: auto;
    padding: 1.25rem; display: flex;
    flex-direction: column; gap: 0.75rem;
}

/* Message bubbles */
.msg-group {
    display: flex; gap: 8px; align-items: flex-end;
    max-width: 72%;
}
.msg-group.sent { margin-left: auto; flex-direction: row-reverse; }

.msg-group-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--emerald-light), #a7f3d0);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; color: var(--emerald-dark);
    flex-shrink: 0; overflow: hidden;
}
.msg-group-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.msg-bubbles { display: flex; flex-direction: column; gap: 3px; }

.msg-bubble {
    padding: 0.6rem 0.9rem;
    border-radius: 18px;
    font-size: 0.875rem; line-height: 1.55;
    max-width: 100%; word-break: break-word;
}

.msg-group.received .msg-bubble {
    background: var(--white); color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.msg-group.sent .msg-bubble {
    background: var(--emerald); color: white;
    border-bottom-right-radius: 4px;
}

.msg-time {
    font-size: 0.68rem; color: var(--text-muted);
    padding: 0 0.25rem;
    align-self: flex-end;
}
.msg-group.sent .msg-time { color: rgba(255,255,255,0.7); }

/* Date divider */
.date-divider {
    display: flex; align-items: center; gap: 0.75rem;
    font-size: 0.72rem; color: var(--text-muted);
    margin: 0.5rem 0;
}
.date-divider::before,
.date-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* Typing indicator */
.typing-indicator {
    padding: 0 1.25rem 0.5rem;
    font-size: 0.78rem; color: var(--text-muted);
    display: flex; align-items: center; gap: 6px;
}
.typing-dots { display: flex; gap: 3px; }
.typing-dots span {
    width: 5px; height: 5px; background: #d1d5db;
    border-radius: 50%; animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-4px); }
}

/* Message input */
.message-input-wrap {
    display: flex; align-items: center; gap: 8px;
    padding: 0.85rem 1.25rem;
    background: var(--white); border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.icon-btn {
    width: 38px; height: 38px; background: none; border: none;
    cursor: pointer; color: var(--text-muted); border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; flex-shrink: 0;
}
.icon-btn i { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--border-light); color: var(--text); }

.msg-input-box {
    flex: 1; position: relative; display: flex; align-items: center;
}

.msg-input {
    width: 100%; padding: 0.7rem 2.5rem 0.7rem 1rem;
    border: 1.5px solid var(--border); border-radius: 50px;
    font-family: 'Inter', sans-serif; font-size: 0.875rem;
    background: var(--surface); outline: none; transition: all 0.2s;
}
.msg-input:focus { border-color: var(--emerald); background: var(--white); box-shadow: 0 0 0 3px rgba(5,150,105,0.08); }

.emoji-btn {
    position: absolute; right: 10px;
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 0; display: flex; align-items: center;
    transition: color 0.15s;
}
.emoji-btn i { width: 17px; height: 17px; }
.emoji-btn:hover { color: #f59e0b; }

.send-btn {
    width: 40px; height: 40px; flex-shrink: 0;
    background: var(--emerald); border: none; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; color: white;
}
.send-btn i { width: 17px; height: 17px; }
.send-btn:hover { background: var(--emerald-dark); box-shadow: 0 3px 10px rgba(5,150,105,0.35); transform: scale(1.05); }
.send-btn:active { transform: scale(0.96); }

/* ── TOAST ── */
.toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    background: #111827; color: white;
    padding: 0.85rem 1.25rem; border-radius: 12px;
    font-size: 0.875rem; display: flex; align-items: center;
    gap: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 300; transform: translateY(20px); opacity: 0;
    transition: all 0.3s ease;
}
.toast i { width: 16px; height: 16px; color: #6ee7b7; }
.toast.show { transform: translateY(0); opacity: 1; }

/* ── UTILITY ── */
.hidden { display: none !important; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .conv-panel { width: 100%; position: absolute; z-index: 10; }
    .conv-panel.hidden-mobile { display: none; }
    .chat-active .back-btn { display: flex !important; }
    .nav-avatar-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .typing-dots span { animation: none; }
    .send-btn:hover  { transform: none; }
}
