/* ============================================
   LIVE CHAT WIDGET STYLES
   XidmətTap.az - Real-time Customer Support
   ============================================ */

/* Chat Button */
.chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

.chat-button i {
    color: white;
    font-size: 28px;
    transition: transform 0.3s ease;
}

.chat-button.chat-open i {
    transform: rotate(360deg);
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f43f5e;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 6px rgba(244, 63, 94, 0);
    }
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 130px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    position: relative;
    width: 45px;
    height: 45px;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.status-indicator.online {
    background: #10b981;
    animation: pulse-online 2s infinite;
}

.status-indicator.offline {
    background: #6b7280;
}

@keyframes pulse-online {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
    }
}

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

.chat-header-text p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

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

.chat-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.chat-action-btn i {
    font-size: 18px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Welcome Message */
.chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.chat-welcome i {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 15px;
}

.chat-welcome h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: #1e293b;
}

.chat-welcome p {
    font-size: 14px;
    margin: 0;
}

/* Chat Message */
.chat-message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeInMessage 0.3s ease;
}

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

.chat-message.user-message {
    justify-content: flex-end;
}

.message-avatar {
    width: 32px;
    height: 32px;
    margin-right: 8px;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message-content {
    max-width: 75%;
}

.message-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    word-wrap: break-word;
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.agent-message .message-bubble {
    border-bottom-left-radius: 4px;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 11px;
    color: #94a3b8;
}

.user-message .message-meta {
    justify-content: flex-end;
}

.message-status i {
    font-size: 12px;
}

.message-status .text-primary {
    color: #667eea !important;
}

.message-status .text-danger {
    color: #f43f5e !important;
}

/* Message Image */
.message-image {
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    max-width: 250px;
}

.message-image img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-image img:hover {
    transform: scale(1.05);
}

/* Message File */
.message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(102, 126, 234, 0.1);
    padding: 12px;
    border-radius: 12px;
    margin-top: 8px;
}

.message-file i {
    font-size: 24px;
    color: #667eea;
}

.message-file span {
    flex: 1;
    font-size: 13px;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-download {
    color: #667eea;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.file-download:hover {
    transform: scale(1.2);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 20px;
    background: #f8f9fa;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Chat Input */
.chat-input-container {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 16px;
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f8f9fa;
    border-radius: 24px;
    padding: 8px 12px;
}

.chat-attach-btn {
    background: transparent;
    border: none;
    color: #64748b;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-attach-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.chat-attach-btn i {
    font-size: 20px;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    padding: 8px;
    outline: none;
    font-family: inherit;
    max-height: 120px;
}

.chat-input::placeholder {
    color: #94a3b8;
}

.chat-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-send-btn i {
    font-size: 16px;
    color: white !important;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

/* Quick Replies */
.chat-quick-replies {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.quick-reply-btn {
    background: white;
    border: 1px solid #e5e7eb;
    color: #64748b;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-reply-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        position: fixed;
        z-index: 9999;
    }

    .chat-button {
        bottom: 20px;
        right: 8px; /* Çox solda - mobil ekranda tam görünsün */
        width: 56px;
        height: 56px;
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
        z-index: 9998;
    }

    .chat-button i {
        font-size: 24px;
    }

    .chat-badge {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }

    /* Header adjustments */
    .chat-header {
        padding: 12px 16px;
        min-height: 60px;
    }

    .chat-avatar {
        width: 40px;
        height: 40px;
    }

    .chat-header-text h4 {
        font-size: 15px;
    }

    .chat-header-text p {
        font-size: 11px;
    }

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

    /* Messages area */
    .chat-messages {
        padding: 12px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    .message-content {
        max-width: 80%;
    }

    .message-bubble {
        padding: 10px 14px;
        font-size: 14px;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        margin-right: 6px;
    }

    .message-meta {
        font-size: 10px;
        margin-top: 3px;
    }

    /* Welcome screen */
    .chat-welcome {
        padding: 30px 16px;
    }

    .chat-welcome i {
        font-size: 42px;
    }

    .chat-welcome h3 {
        font-size: 18px;
    }

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

    /* Input area */
    .chat-input-container {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom)); /* iOS safe area */
        background: white;
        border-top: 1px solid #e5e7eb;
    }

    .chat-input-wrapper {
        padding: 6px 10px;
        border-radius: 20px;
    }

    .chat-input {
        font-size: 15px; /* Prevent zoom on iOS */
        padding: 6px;
        max-height: 100px;
    }

    .chat-attach-btn,
    .chat-send-btn {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }

    .chat-attach-btn i,
    .chat-send-btn i {
        font-size: 18px;
    }

    /* Quick replies */
    .chat-quick-replies {
        gap: 6px;
        margin-top: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: 4px;
    }

    .quick-reply-btn {
        padding: 7px 12px;
        font-size: 12px;
        display: inline-block;
    }

    /* File/Image previews */
    .message-image {
        max-width: 200px;
    }

    .message-file {
        padding: 10px;
        font-size: 12px;
    }

    /* Typing indicator */
    .typing-indicator {
        padding: 8px 16px;
    }

    .typing-indicator span {
        width: 7px;
        height: 7px;
    }
}

/* Small phones (iPhone SE, etc) */
@media (max-width: 375px) {
    .chat-button {
        bottom: 16px;
        right: 6px; /* Kiçik ekranlarda tamamilə solda */
        width: 52px;
        height: 52px;
    }

    .chat-button i {
        font-size: 22px;
    }

    .message-bubble {
        font-size: 13px;
        padding: 9px 12px;
    }

    .chat-input {
        font-size: 16px; /* Prevent zoom */
    }

    .quick-reply-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-window {
        height: 100vh;
        height: 100dvh;
    }

    .chat-messages {
        padding: 8px 12px;
    }

    .chat-header {
        padding: 8px 12px;
        min-height: 50px;
    }

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

/* Prevent bounce scrolling on iOS */
@supports (-webkit-touch-callout: none) {
    .chat-messages {
        overscroll-behavior: contain;
    }

    .chat-window {
        position: fixed;
        -webkit-overflow-scrolling: touch;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .chat-window {
        background: #1e293b;
    }

    .chat-messages {
        background: #0f172a;
    }

    .agent-message .message-bubble {
        background: #334155;
        color: white;
    }

    .chat-welcome {
        color: #cbd5e1;
    }

    .chat-welcome h3 {
        color: white;
    }

    .chat-input-wrapper {
        background: #334155;
    }

    .chat-input {
        color: white;
    }

    .chat-input::placeholder {
        color: #64748b;
    }

    .quick-reply-btn {
        background: #334155;
        border-color: #475569;
        color: #cbd5e1;
    }

    .quick-reply-btn:hover {
        background: #667eea;
        color: white;
        border-color: #667eea;
    }

    .message-file {
        background: rgba(102, 126, 234, 0.15);
    }

    .message-file span {
        color: white;
    }
}

/* Print Styles */
@media print {
    .chat-button,
    .chat-window {
        display: none !important;
    }
}
