/* ══════════════════════════════════════════════
   AkorCum Chat Widget — Light & Modern UI
   Sağ alt köşe: Online kişiler + Mini sohbet pencereleri
   ══════════════════════════════════════════════ */

/* ── Chat Dock (Sağ Alt Bar) ────────────────── */
.chat-dock {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 9990;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding-right: 16px;
    pointer-events: none;
}

.chat-dock > * {
    pointer-events: auto;
}

/* ── Contacts Panel (Online Kişiler) ────────── */
.chat-contacts-panel {
    width: 320px;
    background: #ffffff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.06), 0 0 40px rgba(139, 92, 246, 0.04);
    border: 1px solid #f1f5f9;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
}

.chat-contacts-panel:hover {
    box-shadow: 0 -6px 32px rgba(0, 0, 0, 0.08), 0 0 50px rgba(139, 92, 246, 0.06);
}

.chat-contacts-panel.collapsed {
    height: 54px !important;
}

.chat-contacts-panel.collapsed .contacts-body {
    display: none;
}

/* Contacts Header */
.contacts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    cursor: pointer;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    user-select: none;
    transition: background 0.2s;
}

.contacts-header:hover {
    background: #f8fafc;
}

.contacts-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.contacts-header-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 6px;
}

.contacts-online-count {
    font-size: 11px;
    font-weight: 600;
    color: #6d28d9;
    background: #ede9fe;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.contacts-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.contacts-header-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    color: #475569;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.contacts-header-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Contacts Search */
.contacts-search {
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
}

.contacts-search input {
    width: 100%;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: #1e293b;
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
}

.contacts-search input:focus {
    border-color: #8b5cf6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.contacts-search input::placeholder {
    color: #94a3b8;
}

/* Contacts Body */
.contacts-body {
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    padding-bottom: 12px;
    background: #ffffff;
}

/* Contact Item */
.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.contact-item:hover {
    background: #f8fafc;
}

.contact-item-avatar {
    position: relative;
    flex-shrink: 0;
}

.contact-item-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.contact-online-dot {
    position: absolute;
    bottom: 2px;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    transition: background 0.3s;
}

.contact-online-dot.online {
    background: #22c55e;
}

.contact-online-dot.offline {
    background: #cbd5e1;
}

.contact-item-info {
    flex: 1;
    min-width: 0;
}

.contact-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-item-status {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.contact-item-status.online {
    color: #16a34a;
}

.contact-unread {
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #8b5cf6;
    color: white;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
}

/* Section Title */
.contacts-section-title {
    padding: 16px 20px 8px;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* Empty State */
.contacts-empty {
    padding: 32px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

/* ══════════════════════════════════════════════
   Mini Chat Window
   ══════════════════════════════════════════════ */

.mini-chat {
    width: 340px;
    height: 460px;
    background: #ffffff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid #f1f5f9;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: miniChatSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mini-chat.minimized {
    height: 54px !important;
}

.mini-chat.minimized .mini-chat-body,
.mini-chat.minimized .mini-chat-typing,
.mini-chat.minimized .mini-chat-input {
    display: none;
}

@keyframes miniChatSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Mini Chat Header */
.mini-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    user-select: none;
    transition: background 0.2s;
    min-height: 54px;
}

.mini-chat-header:hover {
    background: #f8fafc;
}

.mini-chat-header-avatar {
    position: relative;
    flex-shrink: 0;
}

.mini-chat-header-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.mini-chat-header-dot {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #ffffff;
}

.mini-chat-header-dot.online {
    background: #22c55e;
}

.mini-chat-header-dot.offline {
    background: #cbd5e1;
}

.mini-chat-header-info {
    flex: 1;
    min-width: 0;
}

.mini-chat-header-name {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-chat-header-status {
    font-size: 11px;
    color: #16a34a;
    margin-top: 1px;
}

.mini-chat-header-status.offline {
    color: #64748b;
}

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

.mini-chat-header-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.mini-chat-header-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.mini-chat-header-btn.close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* Mini Chat Body (Messages) */
.mini-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    background: #ffffff;
}

.mini-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
    animation: miniMsgIn 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

@keyframes miniMsgIn {
    from { opacity: 0; transform: scale(0.95) translateY(4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.mini-msg.sent {
    align-self: flex-end;
    background: #7c3aed;
    color: white;
    border-bottom-right-radius: 4px;
}

.mini-msg.received {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

.mini-msg-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 4px;
    text-align: right;
    display: block;
}

.mini-msg.received .mini-msg-time {
    color: #64748b;
    text-align: left;
}

.mini-msg-system {
    align-self: center;
    font-size: 11px;
    color: #94a3b8;
    background: #f8fafc;
    border-radius: 12px;
    padding: 4px 12px;
    margin: 8px 0;
}

/* Typing Indicator */
.mini-chat-typing {
    padding: 0 16px 8px;
    font-size: 11px;
    color: #8b5cf6;
    font-style: italic;
    display: none;
    align-items: center;
    gap: 6px;
    height: 20px;
    background: #ffffff;
}

.mini-chat-typing.active {
    display: flex;
}

.mini-typing-dots {
    display: flex;
    gap: 3px;
}

.mini-typing-dots span {
    width: 5px;
    height: 5px;
    background: #8b5cf6;
    border-radius: 50%;
    animation: miniTypingBounce 1.4s infinite;
}

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

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

/* Mini Chat Input */
.mini-chat-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid #f1f5f9;
    background: #ffffff;
}

.mini-chat-input textarea {
    flex: 1;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    color: #1e293b;
    font-size: 13px;
    outline: none;
    resize: none;
    max-height: 80px;
    font-family: 'Inter', sans-serif;
    line-height: 1.4;
    transition: all 0.2s;
}

.mini-chat-input textarea:focus {
    border-color: #8b5cf6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.mini-chat-input textarea::placeholder {
    color: #94a3b8;
}

.mini-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #7c3aed;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    opacity: 0.6;
    margin-bottom: 2px;
}

.mini-chat-send.active {
    opacity: 1;
}

.mini-chat-send.active:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

/* ── Loading Spinner ─────────────────────────── */
.mini-chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: #94a3b8;
    font-size: 13px;
    gap: 8px;
}

.mini-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e2e8f0;
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════════
   User Search Modal — Kullanıcı Arama
   ══════════════════════════════════════════════ */

.chat-user-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatModalFadeIn 0.2s ease;
}

@keyframes chatModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chat-user-search-modal {
    width: 440px;
    max-width: 90vw;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatModalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chatModalSlideUp {
    from { transform: translateY(20px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.chat-user-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #f1f5f9;
}

.chat-user-search-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.chat-user-search-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-user-search-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

.chat-user-search-input-wrap {
    padding: 16px 24px;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
}

.chat-user-search-input-wrap input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    color: #1e293b;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
}

.chat-user-search-input-wrap input:focus {
    border-color: #8b5cf6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.chat-user-search-input-wrap input::placeholder {
    color: #94a3b8;
}

.chat-user-search-input-wrap svg {
    position: absolute;
    left: 36px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.chat-user-search-results {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    padding-bottom: 16px;
}

.chat-user-result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 24px;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-user-result-item:hover {
    background: #f8fafc;
}

.chat-user-result-avatar {
    position: relative;
    flex-shrink: 0;
}

.chat-user-result-avatar img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chat-user-result-avatar .user-online-dot {
    position: absolute;
    bottom: 2px;
    right: 0px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ffffff;
}

.chat-user-result-avatar .user-online-dot.online {
    background: #22c55e;
}

.chat-user-result-avatar .user-online-dot.offline {
    background: #cbd5e1;
}

.chat-user-result-info {
    flex: 1;
    min-width: 0;
}

.chat-user-result-name {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
}

.chat-user-result-username {
    font-size: 13px;
    color: #64748b;
    margin-top: 2px;
}

.chat-user-result-status {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.chat-user-result-status.online {
    color: #16a34a;
    background: #dcfce7;
}

.chat-user-result-status.offline {
    color: #64748b;
    background: #f1f5f9;
}

.chat-user-search-empty {
    padding: 40px 24px;
    text-align: center;
    color: #64748b;
    font-size: 14px;
}

.chat-user-search-section {
    padding: 16px 24px 8px;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
    .chat-dock {
        display: none !important;
    }
}

@media (max-width: 1200px) {
    .mini-chat {
        width: 320px;
    }
    
    .chat-contacts-panel {
        width: 280px;
    }
}
