/* Modern Chat System CSS */
:root {
    --chat-primary: #4f46e5;
    --chat-primary-hover: #4338ca;
    --chat-secondary: #6b7280;
    --chat-light: #374151;
    --chat-dark: #1f2937;
    --chat-success: #10b981;
    --chat-danger: #ef4444;
    --chat-warning: #f59e0b;
    --chat-info: #3b82f6;

    --chat-bg: #1e1e1e;
    --chat-text: #e5e7eb;
    --chat-border: #374151;
    --chat-shadow: rgba(0, 0, 0, 0.3);

    --chat-radius: 10px;
    --chat-radius-sm: 6px;
    --chat-transition: all 0.2s ease;

    --chat-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Main Container */
.admin-chat-container {
    position: fixed;
    bottom: 0;
    right: 20px;
    z-index: 9999;
    font-family: var(--chat-font);
    font-size: 14px;
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-end;
    gap: 12px;
}

/* User Panel */
.admin-chat-user-panel {
    width: 270px;
    background: var(--chat-bg);
    border-radius: var(--chat-radius) var(--chat-radius) 0 0;
    box-shadow: 0 -5px 20px var(--chat-shadow);
    overflow: hidden;
    transition: var(--chat-transition);
    border: 1px solid var(--chat-border);
    border-bottom: none;
    display: flex;
    flex-direction: column;
}

.admin-chat-panel-header {
    background: var(--chat-primary);
    color: white;
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--chat-transition);
}

.admin-chat-panel-header:hover {
    background: var(--chat-primary-hover);
}

.admin-chat-panel-title {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.admin-chat-toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: var(--chat-transition);
}

.admin-chat-user-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--chat-secondary) transparent;
}

.admin-chat-user-list::-webkit-scrollbar {
    width: 6px;
}

.admin-chat-user-list::-webkit-scrollbar-track {
    background: transparent;
}

.admin-chat-user-list::-webkit-scrollbar-thumb {
    background-color: var(--chat-secondary);
    border-radius: 10px;
}

.admin-chat-user-panel.collapsed .admin-chat-user-list {
    display: none;
}

.admin-chat-empty-state {
    color: var(--chat-secondary);
    text-align: center;
    padding: 16px;
    font-style: italic;
}

/* User Item */
.admin-chat-user-item {
    padding: 10px 12px;
    border-radius: var(--chat-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: var(--chat-transition);
    margin-bottom: 6px;
}

.admin-chat-user-item:hover {
    background-color: var(--chat-light);
    transform: translateY(-2px);
}

.admin-chat-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    background-color: var(--chat-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    overflow: hidden;
    flex-shrink: 0;
}

.admin-chat-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-chat-user-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.admin-chat-username {
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--chat-text);
}

.admin-chat-status {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: var(--chat-secondary);
}

.admin-chat-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    transition: var(--chat-transition);
}

.admin-chat-status-indicator.online {
    background-color: var(--chat-success);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.admin-chat-status-indicator.offline {
    background-color: var(--chat-secondary);
}

/* Chat Window */
.admin-chat-window {
    width: 320px;
    height: 420px;
    background: var(--chat-bg);
    border-radius: var(--chat-radius) var(--chat-radius) 0 0;
    box-shadow: 0 -5px 20px var(--chat-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--chat-border);
    border-bottom: none;
    transition: var(--chat-transition);
}

.admin-chat-window.minimized {
    height: 48px;
}

.admin-chat-window-header {
    background: var(--chat-primary);
    color: white;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: var(--chat-transition);
}

.admin-chat-window-header:hover {
    background: var(--chat-primary-hover);
}

.admin-chat-window-header.offline-user {
    background: var(--chat-secondary);
}

.admin-chat-window-title {
    display: flex;
    align-items: center;
    overflow: hidden;
}

.admin-chat-window-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 10px;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--chat-primary);
    font-size: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.admin-chat-window-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-chat-window-status {
    font-size: 11px;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    opacity: 0.8;
}

.admin-chat-window-actions {
    display: flex;
    gap: 8px;
}

.admin-chat-window-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--chat-transition);
}

.admin-chat-window-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.admin-chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: var(--chat-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--chat-secondary) transparent;
}

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

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

.admin-chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--chat-secondary);
    border-radius: 10px;
}

.admin-chat-window.minimized .admin-chat-messages,
.admin-chat-window.minimized .admin-chat-input-container {
    display: none;
}

.admin-chat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--chat-radius-sm);
    position: relative;
    word-break: break-word;
    line-height: 1.5;
    transition: var(--chat-transition);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.admin-chat-message.sent {
    align-self: flex-end;
    background: var(--chat-primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.admin-chat-message.received {
    align-self: flex-start;
    background: var(--chat-light);
    color: var(--chat-text);
    border-bottom-left-radius: 2px;
}

.admin-chat-message-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
    text-align: right;
}

.admin-chat-system-message {
    align-self: center;
    font-size: 12px;
    color: var(--chat-secondary);
    background: var(--chat-light);
    padding: 6px 12px;
    border-radius: 100px;
    margin: 6px 0;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.admin-chat-input-container {
    padding: 12px;
    border-top: 1px solid var(--chat-border);
    display: flex;
    background-color: var(--chat-bg);
}

.admin-chat-input {
    flex-grow: 1;
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    background: var(--chat-bg);
    color: var(--chat-text);
    transition: var(--chat-transition);
}

.admin-chat-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.admin-chat-input::placeholder {
    color: var(--chat-secondary);
}

.admin-chat-send-btn {
    background: var(--chat-primary);
    color: white;
    border: none;
    border-radius: var(--chat-radius-sm);
    width: 40px;
    height: 40px;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--chat-transition);
    flex-shrink: 0;
}

.admin-chat-send-btn:hover {
    background: var(--chat-primary-hover);
    transform: translateY(-2px);
}

.admin-chat-send-btn:disabled {
    background: var(--chat-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.admin-chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--chat-secondary);
    text-align: center;
    padding: 20px;
}

.admin-chat-empty-icon {
    font-size: 24px;
    margin-bottom: 10px;
    height: 50px;
    width: 50px;
    border-radius: 50%;
    background: var(--chat-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

/* Responsive Styles */
@media screen and (max-width: 768px) {
    .admin-chat-container {
        right: 10px;
        left: 10px;
        flex-direction: column;
        align-items: flex-end;
    }

    .admin-chat-window {
        width: 100%;
        max-width: 100%;
        height: 380px;
    }

    .admin-chat-user-panel {
        width: 100%;
        max-width: 100%;
    }

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

@media screen and (max-width: 480px) {
    .admin-chat-container {
        right: 0;
        left: 0;
        bottom: 0;
    }

    .admin-chat-window {
        height: 350px;
        border-radius: var(--chat-radius) var(--chat-radius) 0 0;
        border-left: none;
        border-right: none;
    }

    .admin-chat-user-panel {
        border-radius: var(--chat-radius) var(--chat-radius) 0 0;
        border-left: none;
        border-right: none;
    }

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

    .admin-chat-input-container {
        padding: 8px;
    }

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

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

    .admin-chat-panel-header,
    .admin-chat-window-header {
        padding: 10px 12px;
    }

    .admin-chat-user-item {
        padding: 8px 10px;
    }

    .admin-chat-message {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Landscape orientation on mobile */
@media screen and (max-height: 480px) and (orientation: landscape) {
    .admin-chat-window {
        height: 280px;
    }

    .admin-chat-user-panel .admin-chat-user-list {
        max-height: 200px;
    }
}

/* For very small screens */
@media screen and (max-width: 320px) {
    .admin-chat-window-title {
        font-size: 13px;
    }

    .admin-chat-window-actions {
        gap: 4px;
    }

    .admin-chat-window-btn {
        width: 20px;
        height: 20px;
    }

    .admin-chat-message {
        max-width: 90%;
    }
}
