/**
 * Modern Live Chat Widget
 * Fortune Writers - Professional Academic Support Chat
 */

/* ==========================================
   FLOATING CHAT BUTTON
   ========================================== */

.chat-float {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
}

.chat-button {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a2463 0%, #1e3a8a 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(10, 36, 99, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    transition: all 0.3s ease;
    position: relative;
    animation: pulse 2s infinite;
}

.chat-button:hover {
    background: linear-gradient(135deg, #ffd700 0%, #f59e0b 100%);
    color: #0a2463;
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(255, 215, 0, 0.5);
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    animation: bounce 1s infinite;
}

.chat-button-tooltip {
    position: absolute;
    right: 75px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    color: #0a2463;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.chat-button-tooltip::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid white;
}

.chat-button:hover .chat-button-tooltip {
    opacity: 1;
    right: 80px;
}

/* ==========================================
   CHAT WIDGET CONTAINER
   ========================================== */

.chat-widget-container {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 420px;
    height: 650px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    animation: slideUp 0.4s ease-out;
}

.chat-widget-container.active {
    display: flex;
}

/* ==========================================
   CHAT HEADER
   ========================================== */

.chat-header {
    background: linear-gradient(135deg, #0a2463 0%, #1e3a8a 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.chat-agent-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700 0%, #f59e0b 100%);
    color: #0a2463;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: bold;
    border: 3px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

.chat-agent-avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid white;
}

.chat-agent-details h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.chat-agent-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    opacity: 0.95;
    margin-top: 2px;
}

.chat-status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

/* ==========================================
   CHAT WELCOME / CATEGORY SELECTION
   ========================================== */

.chat-welcome-screen {
    padding: 30px 20px;
    text-align: center;
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
}

.chat-welcome-screen h3 {
    color: #0a2463;
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.chat-welcome-screen p {
    color: #6b7280;
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 25px;
}

.chat-categories {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.chat-category-btn {
    padding: 16px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.chat-category-btn:hover {
    border-color: #0a2463;
    background: #f0f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(10, 36, 99, 0.1);
}

.chat-category-btn .icon {
    font-size: 1.75rem;
    margin-bottom: 8px;
    display: block;
}

.chat-category-btn .label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0a2463;
    display: block;
}

.chat-trust-badges {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    margin-top: 20px;
}

.chat-trust-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: #6b7280;
}

.chat-trust-badge i {
    font-size: 1.25rem;
    color: #10b981;
}

/* ==========================================
   CHAT MESSAGES AREA
   ========================================== */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
    display: none;
}

.chat-messages.active {
    display: block;
}

.chat-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: messageSlideIn 0.3s ease-out;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #0a2463;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: bold;
    flex-shrink: 0;
}

.chat-message.user .chat-message-avatar {
    background: #10b981;
}

.chat-message-content {
    max-width: 75%;
}

.chat-message-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-size: 0.875rem;
    line-height: 1.5;
    color: #374151;
}

.chat-message.user .chat-message-bubble {
    background: #0a2463;
    color: white;
}

.chat-message-time {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 8px;
}

.chat-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    width: fit-content;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* ==========================================
   CHAT INPUT AREA
   ========================================== */

.chat-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: none;
}

.chat-input-area.active {
    display: block;
}

.chat-input-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input {
    width: 100%;
    padding: 12px 45px 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-size: 0.875rem;
    outline: none;
    transition: all 0.3s ease;
}

.chat-input:focus {
    border-color: #0a2463;
    box-shadow: 0 0 0 3px rgba(10, 36, 99, 0.1);
}

.chat-attach-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-attach-btn:hover {
    color: #0a2463;
    background: #f3f4f6;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a2463 0%, #1e3a8a 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: linear-gradient(135deg, #ffd700 0%, #f59e0b 100%);
    color: #0a2463;
    transform: scale(1.1);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Privacy notice */
.chat-privacy-notice {
    padding: 12px 20px;
    background: #f0f9ff;
    border-top: 1px solid #e0e7ff;
    font-size: 0.75rem;
    color: #6b7280;
    text-align: center;
    line-height: 1.4;
}

.chat-privacy-notice i {
    color: #0a2463;
    margin-right: 4px;
}

/* ==========================================
   ANIMATIONS
   ========================================== */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 768px) {
    .chat-widget-container {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .chat-float {
        bottom: 20px;
        right: 20px;
    }
    
    .chat-button {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .chat-button-tooltip {
        display: none;
    }
    
    .chat-categories {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .chat-float {
        bottom: 15px;
        right: 15px;
    }
    
    .chat-button {
        width: 55px;
        height: 55px;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .chat-trust-badges {
        flex-direction: column;
        gap: 12px;
    }
}

/* ==========================================
   EMAIL COLLECTION FORM
   ========================================== */

.chat-email-collection {
    padding: 30px 25px;
    text-align: center;
    animation: fadeIn 0.3s ease-in-out;
}

.chat-email-header {
    margin-bottom: 25px;
}

.chat-email-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.chat-email-header p {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.email-collection-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.email-collection-form .form-group {
    text-align: left;
}

.email-collection-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin-bottom: 6px;
}

.email-collection-form .form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.email-collection-form .form-control:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.email-collection-form .btn-primary {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 10px;
}

.email-collection-form .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.email-collection-form .btn-primary:active {
    transform: translateY(0);
}

.btn-link {
    background: none;
    border: none;
    color: #4A90E2;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    padding: 8px;
    transition: color 0.2s ease;
}

.btn-link:hover {
    color: #357ABD;
    text-decoration: underline;
}

.btn-block {
    width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   FILE ATTACHMENTS
   ========================================== */

.chat-file-attachment {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
}

.chat-file-download {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
}

.chat-file-download:hover {
    background: #e9ecef;
    border-color: #4A90E2;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chat-file-download > .fas:first-child {
    font-size: 24px;
    color: #4A90E2;
}

.chat-file-download > .fas:last-child {
    font-size: 18px;
    color: #666;
    margin-left: auto;
}

.chat-file-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.chat-file-name {
    font-weight: 500;
    font-size: 14px;
    color: #333;
    word-break: break-word;
}

.chat-file-size {
    font-size: 12px;
    color: #666;
}

.chat-image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.chat-image-preview:hover {
    transform: scale(1.02);
}

.chat-file-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 13px;
    color: #666;
}

.chat-file-info .fas {
    color: #4A90E2;
}

.chat-attach-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 8px;
    font-size: 18px;
    transition: color 0.2s ease, transform 0.2s ease;
}

.chat-attach-btn:hover {
    color: #4A90E2;
    transform: scale(1.1);
}

.chat-attach-btn:active {
    transform: scale(0.95);
}

/* User messages - align file attachments to right */
.chat-message.user .chat-file-attachment {
    align-items: flex-end;
}

/* Bot messages - align file attachments to left */
.chat-message.bot .chat-file-attachment {
    align-items: flex-start;
}