@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #4F46E5; /* Indigo */
    --primary-hover: #4338CA;
    --secondary: #10B981; /* Emerald */
    --bg-color: #F3F4F6;
    --chat-bg: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    
    --msg-user-bg: linear-gradient(135deg, #4F46E5, #3B82F6);
    --msg-user-text: #FFFFFF;
    --msg-admin-bg: #F3F4F6;
    --msg-admin-text: #1F2937;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --radius-lg: 16px;
    --radius-md: 12px;
}

/* Scrollbar Styling for Chat only */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 10px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* ------------- Customer Chat Widget ------------- */
.chat-widget-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--msg-user-bg);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 1000;
}

.chat-widget-btn:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.chat-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 350px;
    height: 500px;
    background: var(--chat-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
}

.chat-container.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.chat-header {
    background: var(--msg-user-bg);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    font-weight: 600;
    font-size: 16px;
    margin: 0;
}

.chat-header p {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 4px;
}

.chat-header .close-btn {
    cursor: pointer;
    font-size: 20px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-header .close-btn:hover {
    opacity: 1;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #FAFAFA;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: var(--msg-user-bg);
    color: var(--msg-user-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.15);
}

.message.admin {
    align-self: flex-start;
    background: var(--msg-admin-bg);
    color: var(--msg-admin-text);
    border-bottom-left-radius: 4px;
}

.chat-input-area {
    padding: 15px;
    background: var(--chat-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input-area input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 15px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: var(--primary);
}

.chat-input-area button {
    background: var(--msg-user-bg);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.chat-input-area button:hover {
    transform: scale(1.1);
}

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

/* ------------- Admin Dashboard ------------- */
.admin-body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    padding: 20px;
    font-family: 'Inter', sans-serif;
}

.admin-layout {
    display: flex;
    width: 100%;
    max-width: 1400px;
    height: 100%;
    background: var(--chat-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.05);
}

.admin-sidebar {
    width: 350px;
    min-width: 300px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: #F9FAFB;
    z-index: 10;
}

.admin-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    background: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.admin-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    letter-spacing: -0.5px;
}

.btn-delete-old {
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    font-weight: 500;
}
.btn-delete-old:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    filter: brightness(1.1);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.conversation-item {
    padding: 16px 20px;
    margin-bottom: 8px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.conversation-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(79, 70, 229, 0.2);
}
.conversation-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.conv-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conv-id {
    font-weight: 600;
    font-size: 15px;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}
.conversation-item.active .conv-id, 
.conversation-item.active .conv-time, 
.conversation-item.active .conv-msg {
    color: white;
}

.conv-time {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.conv-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conv-msg {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.conv-badge {
    background: #EF4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 20px;
    margin-left: 10px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.admin-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
}

.admin-chat-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(10px);
    z-index: 5;
}

.admin-chat-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.admin-chat-header h3::before {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    background: #10B981;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 20px;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
}
.empty-state i {
    font-size: 64px;
    background: -webkit-linear-gradient(45deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.8;
}
.empty-state h2 {
    font-weight: 500;
    font-size: 20px;
}

.admin-chat-area .chat-messages {
    padding: 30px;
    background: #F8FAFC;
}

.admin-chat-area .chat-input-area {
    padding: 20px 30px;
    background: white;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.02);
}
.admin-chat-area .chat-input-area input {
    padding: 15px 25px;
    border-radius: 30px;
    font-size: 15px;
    background: #F1F5F9;
    border: 1px solid transparent;
}
.admin-chat-area .chat-input-area input:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}
.admin-chat-area .chat-input-area button {
    width: 50px;
    height: 50px;
    font-size: 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

/* Responsive */
@media (max-width: 900px) {
    .admin-body {
        padding: 0;
    }
    .admin-layout {
        flex-direction: column;
        border-radius: 0;
        height: 100%;
        border: none;
    }
    .admin-sidebar {
        width: 100%;
        height: 35vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .admin-chat-area {
        height: 65vh;
    }
}

/* ------------- Image Preview ------------- */
.chat-image-preview {
    padding: 10px 20px;
    background: #F8FAFC;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    position: relative;
}
.chat-image-preview img {
    height: 60px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.chat-image-preview .remove-preview {
    background: #EF4444;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    margin-left: -18px;
    margin-top: -8px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.chat-image-preview .remove-preview:hover {
    background: #DC2626;
    transform: scale(1.1);
}

/* ------------- File Upload & Lightbox ------------- */
.btn-upload-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #F3F4F6;
    color: #6B7280;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 5px;
}
.btn-upload-image:hover {
    background: #E5E7EB;
    color: var(--primary);
    transform: scale(1.05);
}
.admin-chat-area .btn-upload-image {
    width: 50px;
    height: 50px;
    font-size: 18px;
}

.chat-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}
.chat-lightbox .lightbox-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    object-fit: contain;
}
.chat-lightbox .close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    transition: 0.2s;
}
.chat-lightbox .close-lightbox:hover {
    color: #F87171;
    transform: scale(1.1);
}
