/* ══════════════════════════════════════════════════
   CHAT SYSTEM — Widget + Admin Dashboard Styles
   ══════════════════════════════════════════════════ */

/* ─── Chat Widget Toggle Button ─── */
.chat-toggle-btn {
    position: fixed;
    bottom: 25px;
    right: 90px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #58a6ff, #1f6feb);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(31, 111, 235, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(31, 111, 235, 0.5);
}

.chat-toggle-btn .chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #f85149;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #0d1117;
    animation: chatBadgePulse 1.5s ease infinite;
}

@keyframes chatBadgePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

/* ─── Chat Widget Container ─── */
.chat-widget {
    position: fixed;
    bottom: 92px;
    right: 90px;
    width: 380px;
    height: 520px;
    background: #0d1117;
    border: 1px solid #21262d;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-widget.active {
    display: flex;
}

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

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ─── Widget Header ─── */
.chat-widget-header {
    padding: 16px 20px;
    background: #161b22;
    border-bottom: 1px solid #21262d;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-widget-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #58a6ff, #1f6feb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.chat-widget-header-info {
    flex: 1;
}

.chat-widget-header-name {
    font-size: 15px;
    font-weight: 700;
    color: #e6edf3;
}

.chat-widget-header-status {
    font-size: 12px;
    color: #3fb950;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-widget-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3fb950;
}

.chat-widget-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #8b949e;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-widget-close:hover {
    background: #21262d;
    color: #e6edf3;
}

/* ─── Messages Area ─── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

/* ─── Message Bubbles ─── */
.chat-msg {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-msg-customer {
    align-self: flex-end;
}

.chat-msg-admin {
    align-self: flex-start;
}

.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg-customer .chat-msg-bubble {
    background: #1f6feb;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg-admin .chat-msg-bubble {
    background: #21262d;
    color: #e6edf3;
    border-bottom-left-radius: 4px;
}

.chat-msg-time {
    font-size: 11px;
    color: #484f58;
    padding: 0 4px;
}

.chat-msg-customer .chat-msg-time {
    text-align: right;
}

.chat-msg-admin .chat-msg-time {
    text-align: left;
}

/* Image messages */
.chat-msg-image {
    max-width: 200px;
    border-radius: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.chat-msg-image:hover {
    opacity: 0.85;
}

/* ─── Typing Indicator ─── */
.chat-typing {
    padding: 4px 16px;
    font-size: 12px;
    color: #8b949e;
    font-style: italic;
    min-height: 20px;
    flex-shrink: 0;
}

/* ─── Input Bar ─── */
.chat-input-bar {
    padding: 12px 16px;
    background: #161b22;
    border-top: 1px solid #21262d;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chat-input-bar input[type="file"] {
    display: none;
}

.chat-input-img-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #8b949e;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-input-img-btn:hover {
    background: #21262d;
    color: #58a6ff;
}

.chat-input-text {
    flex: 1;
    padding: 8px 14px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 20px;
    color: #e6edf3;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.chat-input-text:focus {
    border-color: #58a6ff;
}

.chat-input-text::placeholder {
    color: #484f58;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #1f6feb;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: #388bfd;
    transform: scale(1.08);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ─── Connection Status ─── */
.chat-reconnecting {
    padding: 6px 16px;
    background: rgba(210, 153, 34, 0.15);
    color: #d29922;
    font-size: 12px;
    text-align: center;
    display: none;
    flex-shrink: 0;
}

.chat-reconnecting.active {
    display: block;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .chat-toggle-btn {
        bottom: 25px;
        right: 80px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .chat-widget {
        width: calc(100vw - 16px);
        height: calc(100dvh - 130px);
        bottom: 120px;
        right: 8px;
        left: 8px;
        border-radius: 14px;
    }
}

/* ══════════════════════════════════════════════════
   ADMIN CHAT DASHBOARD — Premium Light Redesign
   ══════════════════════════════════════════════════ */

.admin-chat-online-badge {
    font-size: 12px;
    color: #059669;
    background: linear-gradient(135deg, #d1fae5, #ecfdf5);
    padding: 4px 14px;
    border-radius: 20px;
    font-weight: 700;
    border: 1px solid #a7f3d0;
    letter-spacing: 0.3px;
}

.admin-chat-wrap {
    display: flex;
    height: calc(100vh - 230px);
    min-height: 400px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.03), 0 20px 40px -4px rgba(0,0,0,0.06);
}

/* ─── Session Sidebar ─── */
.admin-chat-sidebar {
    width: 360px;
    background: linear-gradient(180deg, #fefefe 0%, #f8fafc 100%);
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.admin-chat-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(135deg, #f8fafc, #ffffff);
}

.admin-chat-search-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 10px 16px;
    transition: all 0.3s ease;
}

.admin-chat-search-wrap:focus-within {
    background: #ffffff;
    border-color: #818cf8;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.08), 0 4px 12px rgba(99, 102, 241, 0.1);
}

.admin-chat-search-wrap i {
    color: #94a3b8;
    font-size: 15px;
    flex-shrink: 0;
}

.admin-chat-search-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #0f172a;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
}

.admin-chat-search-wrap input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

/* ─── Empty Sessions ─── */
.admin-chat-empty-sessions {
    padding: 60px 24px;
    text-align: center;
    color: #94a3b8;
}

.admin-chat-empty-sessions p {
    margin-top: 16px;
    font-size: 15px;
    font-weight: 600;
    color: #475569;
}

.admin-chat-empty-sessions span {
    font-size: 13px;
    line-height: 1.6;
    display: block;
    margin-top: 6px;
    color: #94a3b8;
}

/* ─── Session List ─── */
.admin-chat-session-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.admin-chat-session-list::-webkit-scrollbar {
    width: 4px;
}

.admin-chat-session-list::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}
.admin-chat-session-list::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

.admin-chat-session-item {
    padding: 14px 16px;
    border-bottom: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.admin-chat-session-item:hover {
    background: #f1f5f9;
    transform: translateX(2px);
}

.admin-chat-session-item.active {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border-left: none;
    padding-left: 16px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12);
}

.admin-chat-session-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    position: relative;
}

.admin-chat-session-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid #fff;
    position: absolute;
    bottom: -1px;
    right: -1px;
}

.admin-chat-session-dot.online {
    background: #10b981;
    box-shadow: 0 0 0 2px #fff, 0 0 8px rgba(16, 185, 129, 0.4);
    animation: pulseOnline 2s ease infinite;
}

@keyframes pulseOnline {
    0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 8px rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 2px #fff, 0 0 14px rgba(16, 185, 129, 0.6); }
}

.admin-chat-session-dot.away {
    background: #f59e0b;
}

.admin-chat-session-dot.offline {
    background: #d1d5db;
}

.admin-chat-session-info {
    flex: 1;
    min-width: 0;
}

.admin-chat-session-name {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.2px;
}

.admin-chat-session-preview {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 3px;
}

.admin-chat-session-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.admin-chat-session-time {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

.admin-chat-session-unread {
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    background: linear-gradient(135deg, #ef4444, #f87171);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
    animation: unreadPulse 2s ease infinite;
}

@keyframes unreadPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ─── Chat Panel ─── */
.admin-chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    position: relative;
}

.admin-chat-active {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ─── Empty State ─── */
.admin-chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    color: #94a3b8;
    padding: 40px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.admin-chat-empty-icon {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border: 2px solid #c7d2fe;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: floatIcon 4s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.admin-chat-empty-icon i {
    font-size: 40px;
    color: #6366f1;
}

.admin-chat-empty h4 {
    font-size: 20px;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
    letter-spacing: -0.3px;
}

.admin-chat-empty p {
    font-size: 14px;
    color: #64748b;
    margin: 0;
    text-align: center;
    max-width: 320px;
    line-height: 1.6;
}

/* ─── Panel Header ─── */
.admin-chat-panel-header {
    padding: 16px 24px;
    background: linear-gradient(135deg, #fefefe, #f8fafc);
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.admin-chat-panel-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.admin-chat-panel-info {
    flex: 1;
}

.admin-chat-panel-name {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.2px;
}

.admin-chat-panel-status {
    font-size: 13px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ─── Messages ─── */
.admin-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: linear-gradient(180deg, #fefefe 0%, #f8fafc 50%, #fefefe 100%);
}

.admin-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.admin-chat-messages::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}
.admin-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

.admin-chat-messages .chat-msg {
    max-width: 60%;
}

/* Admin view: admin messages on RIGHT, customer messages on LEFT */
.admin-chat-messages .chat-msg-admin {
    align-self: flex-end;
}

.admin-chat-messages .chat-msg-customer {
    align-self: flex-start;
}

.admin-chat-messages .chat-msg-admin .chat-msg-bubble {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 14px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.admin-chat-messages .chat-msg-admin .chat-msg-time {
    text-align: right;
    color: #94a3b8;
}

.admin-chat-messages .chat-msg-customer .chat-msg-bubble {
    background: #f1f5f9;
    color: #0f172a;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 14px;
    border: 1px solid #e2e8f0;
}

.admin-chat-messages .chat-msg-customer .chat-msg-time {
    text-align: left;
    color: #94a3b8;
}

/* ─── Typing ─── */
.admin-chat-typing {
    padding: 4px 24px;
    font-size: 13px;
    color: #6366f1;
    font-style: italic;
    min-height: 20px;
    flex-shrink: 0;
    font-weight: 500;
}

/* ─── Reply Input Bar ─── */
.admin-chat-input-bar {
    padding: 16px 24px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.admin-chat-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.admin-chat-action-btn:hover {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: #6366f1;
    border-color: #c7d2fe;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.1);
}

.admin-chat-input-wrap {
    flex: 1;
}

.admin-chat-input-wrap input {
    width: 100%;
    padding: 12px 20px;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 14px;
    color: #0f172a;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    transition: all 0.25s ease;
    font-family: inherit;
}

.admin-chat-input-wrap input:focus {
    background: #ffffff;
    border-color: #818cf8;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.08), 0 4px 12px rgba(99, 102, 241, 0.08);
}

.admin-chat-input-wrap input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.admin-chat-send-btn {
    height: 44px;
    padding: 0 22px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
    flex-shrink: 0;
    font-family: inherit;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.admin-chat-send-btn:hover {
    background: linear-gradient(135deg, #818cf8, #a5b4fc);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.admin-chat-send-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.admin-chat-send-btn i {
    font-size: 14px;
}

/* ─── Responsive Admin ─── */
@media (max-width: 960px) {
    .admin-chat-sidebar {
        width: 280px;
    }

    .admin-chat-messages {
        padding: 16px;
    }

    .admin-chat-input-bar {
        padding: 12px 16px;
    }
}

@media (max-width: 768px) {
    .admin-chat-wrap {
        height: calc(100vh - 140px);
    }

    .admin-chat-sidebar {
        width: 240px;
    }

    .admin-chat-send-btn span {
        display: none;
    }

    .admin-chat-send-btn {
        width: 40px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
    }

    .admin-chat-panel-header {
        padding: 12px 16px;
    }

    .admin-chat-messages {
        padding: 14px;
        gap: 8px;
    }

    .admin-chat-messages .chat-msg {
        max-width: 75%;
    }

    .admin-chat-input-bar {
        padding: 10px 12px;
        gap: 8px;
    }

    .admin-chat-input-wrap input {
        padding: 8px 14px;
        font-size: 13px;
    }

    .admin-chat-action-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .admin-chat-empty-icon {
        width: 64px;
        height: 64px;
    }

    .admin-chat-empty-icon i {
        font-size: 28px;
    }

    .admin-chat-empty h4 {
        font-size: 16px;
    }

    .admin-chat-empty p {
        font-size: 13px;
    }
}

@media (max-width: 576px) {
    .admin-chat-wrap {
        flex-direction: column;
        height: calc(100vh - 120px);
        min-height: 400px;
        border-radius: 10px;
    }

    .admin-chat-sidebar {
        width: 100%;
        max-height: 180px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        flex-shrink: 0;
    }

    .admin-chat-session-item {
        padding: 10px 12px;
    }

    .admin-chat-session-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .admin-chat-session-name {
        font-size: 13px;
    }

    .admin-chat-session-preview {
        font-size: 11px;
    }

    .admin-chat-panel {
        min-height: 300px;
    }

    .admin-chat-messages {
        padding: 10px;
    }

    .admin-chat-messages .chat-msg {
        max-width: 85%;
    }

    .admin-chat-input-bar {
        padding: 8px 10px;
        gap: 6px;
    }

    .admin-chat-input-wrap input {
        padding: 8px 12px;
        font-size: 13px;
        border-radius: 8px;
    }

    .admin-chat-send-btn {
        width: 36px;
        height: 36px;
    }

    .admin-chat-action-btn {
        width: 34px;
        height: 34px;
        font-size: 15px;
        border-radius: 8px;
    }

    .admin-chat-search-wrap {
        padding: 6px 10px;
    }

    .admin-chat-search-wrap input {
        font-size: 12px;
    }

    .admin-chat-empty {
        padding: 20px;
    }

    .admin-chat-empty-icon {
        width: 56px;
        height: 56px;
    }

    .admin-chat-empty-icon i {
        font-size: 24px;
    }

    .admin-chat-empty h4 {
        font-size: 15px;
    }

    .admin-chat-empty p {
        font-size: 12px;
    }
}