/* ============================================
   NYAYDWAR - LIVE CHAT SYSTEM
   Custom Chat Widget Styles
   ============================================ */

/* Chat Widget Container */
.nd-chat-widget {
    position: fixed;
    bottom: 170px;
    right: 15px;
    z-index: 997;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Chat Toggle Button */
.nd-chat-toggle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 3px 15px rgba(124, 58, 237, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.nd-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(124, 58, 237, 0.5);
}

.nd-chat-toggle.active {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

.nd-chat-toggle .nd-chat-icon-open,
.nd-chat-toggle .nd-chat-icon-close {
    position: absolute;
    transition: all 0.3s ease;
}

.nd-chat-toggle .nd-chat-icon-close {
    opacity: 0;
    transform: rotate(-90deg);
}

.nd-chat-toggle.active .nd-chat-icon-open {
    opacity: 0;
    transform: rotate(90deg);
}

.nd-chat-toggle.active .nd-chat-icon-close {
    opacity: 1;
    transform: rotate(0);
}

/* Unread Badge */
.nd-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: nd-pulse 2s infinite;
}

@keyframes nd-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Window */
.nd-chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 150px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

.nd-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.nd-chat-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    padding: 20px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 15px;
}

.nd-chat-avatar {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.nd-chat-header-info h4 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 4px;
}

.nd-chat-header-info p {
    font-size: 0.8125rem;
    opacity: 0.9;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nd-chat-status {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: nd-pulse 2s infinite;
}

.nd-chat-close {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.nd-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Pre-chat Form */
.nd-chat-prechat {
    flex: 1;
    padding: 25px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.nd-chat-prechat h5 {
    font-size: 1rem;
    font-weight: 600;
    color: #1e3a8a;
    margin: 0 0 20px;
    text-align: center;
}

.nd-chat-prechat .nd-form-group {
    margin-bottom: 15px;
}

.nd-chat-prechat label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.nd-chat-prechat input,
.nd-chat-prechat select,
.nd-chat-prechat textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.nd-chat-prechat input:focus,
.nd-chat-prechat select:focus,
.nd-chat-prechat textarea:focus {
    outline: none;
    border-color: #2563eb;
}

.nd-chat-prechat textarea {
    resize: none;
    height: 80px;
}

.nd-chat-start-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    margin-top: 10px;
}

.nd-chat-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.nd-chat-start-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Chat Messages Area */
.nd-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 15px;
    background: #f8fafc;
}

.nd-chat-body.active {
    display: flex;
}

/* Message Bubbles */
.nd-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: nd-fadeIn 0.3s ease;
}

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

.nd-message.incoming {
    align-self: flex-start;
}

.nd-message.outgoing {
    align-self: flex-end;
}

.nd-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.9375rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.nd-message.incoming .nd-message-bubble {
    background: #fff;
    color: #374151;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.nd-message.outgoing .nd-message-bubble {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.nd-message-time {
    font-size: 0.6875rem;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

.nd-message.outgoing .nd-message-time {
    text-align: right;
}

/* Typing Indicator */
.nd-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.nd-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: nd-typing 1.4s infinite ease-in-out;
}

.nd-typing span:nth-child(1) { animation-delay: 0s; }
.nd-typing span:nth-child(2) { animation-delay: 0.2s; }
.nd-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes nd-typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* Welcome Message */
.nd-welcome-message {
    text-align: center;
    padding: 20px;
    color: #6b7280;
    font-size: 0.875rem;
}

.nd-welcome-message i {
    font-size: 2rem;
    color: #2563eb;
    margin-bottom: 10px;
    display: block;
}

/* Chat Input Area */
.nd-chat-footer {
    padding: 15px 20px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    display: none;
}

.nd-chat-footer.active {
    display: block;
}

.nd-chat-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f3f4f6;
    border-radius: 25px;
    padding: 5px 5px 5px 20px;
}

.nd-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 0.9375rem;
    font-family: inherit;
    outline: none;
}

.nd-chat-input::placeholder {
    color: #9ca3af;
}

.nd-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.nd-chat-send:hover {
    transform: scale(1.05);
}

.nd-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Quick Replies */
.nd-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 15px 20px 0;
}

.nd-quick-reply {
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 0.8125rem;
    color: #2563eb;
    cursor: pointer;
    transition: all 0.2s;
}

.nd-quick-reply:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* Mobile Responsive */
@media screen and (max-width: 480px) {
    .nd-chat-widget {
        bottom: 80px;
        right: 15px;
    }
    
    .nd-chat-toggle {
        width: 54px;
        height: 54px;
        font-size: 1.25rem;
    }
    
    .nd-chat-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 160px);
        bottom: 70px;
        right: -5px;
        border-radius: 16px;
    }
    
    .nd-chat-header {
        padding: 15px;
    }
    
    .nd-chat-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .nd-chat-header-info h4 {
        font-size: 1rem;
    }
    
    .nd-chat-body {
        padding: 15px;
    }
    
    .nd-message-bubble {
        font-size: 0.875rem;
        padding: 10px 14px;
    }
}

/* Admin Chat Panel Styles */
.nd-admin-chat {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.nd-admin-chat-list {
    border-right: 1px solid #e5e7eb;
    height: 600px;
    overflow-y: auto;
}

.nd-admin-chat-item {
    padding: 15px 20px;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.nd-admin-chat-item:hover,
.nd-admin-chat-item.active {
    background: #f8fafc;
}

.nd-admin-chat-item .avatar {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    flex-shrink: 0;
}

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

.nd-admin-chat-item .info h6 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0 0 3px;
    color: #1f2937;
}

.nd-admin-chat-item .info p {
    font-size: 0.8125rem;
    color: #6b7280;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nd-admin-chat-item .meta {
    text-align: right;
    flex-shrink: 0;
}

.nd-admin-chat-item .meta .time {
    font-size: 0.75rem;
    color: #9ca3af;
}

.nd-admin-chat-item .meta .unread {
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    font-size: 0.6875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 5px;
    margin-left: auto;
}

/* Mobile Responsive Chat Widget */
@media (max-width: 768px) {
    .nd-chat-widget {
        bottom: 145px;
        right: 12px;
    }
    
    .nd-chat-toggle {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .nd-chat-window {
        width: calc(100vw - 30px);
        max-width: 350px;
        height: 400px;
        bottom: 55px;
        right: 0;
    }
}
