/* ===================================
   CHAT WIDGET - MOBILE FIRST DESIGN
   =================================== */

/* Floating Chat Button */
.chat-widget-button {
    position: fixed;
    bottom: 15px;
    right: 15px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.chat-widget-button:hover,
.chat-widget-button:active {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

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

/* Status indicator dot */
.chat-widget-button .chat-status-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 12px;
    height: 12px;
    background-color: #dc3545;
    border-radius: 50%;
    border: 2px solid white;
    transition: background-color 0.3s;
}

.chat-widget-button .chat-status-dot.online {
    background-color: #28a745;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Chat Window - Mobile First (Full Screen) */
.chat-widget-window {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    z-index: 10000;
    overflow: hidden;
}

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

.chat-header-info {
    flex: 1;
}

.chat-header-info h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

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

.chat-notification-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px 10px;
    line-height: 1;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    border-radius: 6px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.chat-staff-status {
    display: flex;
    align-items: center;
    font-size: 12px;
    margin-top: 4px;
    opacity: 0.9;
}

.chat-staff-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #dc3545;
    margin-right: 6px;
}

.chat-staff-status .status-dot.online {
    background-color: #90ee90;
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    line-height: 1;
    transition: opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-width: 40px;
    min-height: 40px;
}

.chat-close-btn:hover,
.chat-close-btn:active {
    opacity: 0.8;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

/* Individual Message */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: slideIn 0.3s ease;
}

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

.chat-message.visitor {
    align-self: flex-end;
}

.chat-message.staff {
    align-self: flex-start;
}

.chat-message.system {
    align-self: center;
    max-width: 90%;
}

.message-sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #6c757d;
    padding: 0 4px;
}

.message-text {
    padding: 12px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.5;
    font-size: 14px;
}

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

.chat-message.staff .message-text {
    background: white;
    color: #333;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: 4px;
}

.chat-message.system .message-text {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    text-align: center;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 12px;
}

.chat-message.system.error .message-text {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.message-time {
    font-size: 10px;
    color: #6c757d;
    margin-top: 4px;
    align-self: flex-end;
    padding: 0 4px;
}

.chat-message.staff .message-time {
    align-self: flex-start;
}

/* Chat Input Area */
.chat-input-area {
    border-top: 1px solid #dee2e6;
    background: white;
    padding: 0;
}

#chat-message-form {
    padding: 12px;
}

.chat-input-area .input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input-area input[type="text"] {
    flex: 1;
    border-radius: 24px;
    border: 1px solid #dee2e6;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
}

.chat-input-area input[type="text"]:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input-area button {
    border-radius: 50%;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    transition: opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.chat-input-area button:hover:not(:disabled),
.chat-input-area button:active:not(:disabled) {
    opacity: 0.9;
}

.chat-input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Name Form */
#chat-name-form {
    padding: 20px;
}

#chat-name-form .form-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
    color: #333;
}

#chat-name-form .form-control {
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 14px;
    border: 1px solid #dee2e6;
    width: 100%;
}

#chat-name-form .form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

#chat-name-form .btn {
    border-radius: 8px;
    padding: 12px;
    font-weight: 600;
    font-size: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    width: 100%;
    cursor: pointer;
    transition: opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

#chat-name-form .btn:hover,
#chat-name-form .btn:active {
    opacity: 0.9;
}

/* Connection Status */
#chat-connection-status {
    text-align: center;
    font-size: 11px;
    padding: 6px;
    color: #6c757d;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* ======================================
   RESPONSIVE - TABLET & DESKTOP
   ====================================== */

/* Tablet (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .chat-widget-button {
        width: 60px;
        height: 60px;
        bottom: 20px;
        right: 20px;
    }
    
    .chat-widget-button i {
        font-size: 28px;
    }
    
    .chat-widget-window {
        bottom: 20px;
        right: 20px;
        left: auto;
        top: auto;
        width: 380px;
        height: 550px;
        max-height: calc(100vh - 40px);
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    }
    
    .chat-header {
        border-radius: 16px 16px 0 0;
    }
    
    .message-text {
        font-size: 15px;
    }
}

/* Desktop (992px and up) */
@media (min-width: 992px) {
    .chat-widget-window {
        width: 400px;
        height: 600px;
    }
    
    .chat-message {
        max-width: 75%;
    }
}

/* Large Desktop (1200px and up) */
@media (min-width: 1200px) {
    .chat-widget-window {
        width: 420px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .chat-widget-button,
    .chat-message,
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Chat Input Toolbar (Emoji & Upload Buttons) */
.chat-input-toolbar {
    display: flex;
    gap: 4px;
    align-items: center;
}

.chat-input-toolbar button {
    min-width: 40px;
    min-height: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent !important;
    color: #667eea;
    border: none;
    font-size: 20px;
    cursor: pointer;
    border-radius: 50%;
}

.chat-input-toolbar button:hover:not(:disabled) {
    background: rgba(102, 126, 234, 0.1) !important;
}

/* Emoji Picker */
.chat-emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 12px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 1000;
    max-width: 280px;
}

.chat-emoji-picker.show {
    display: block;
}

.chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.chat-emoji-grid button {
    min-width: 32px;
    min-height: 32px;
    width: 32px;
    height: 32px;
    padding: 4px;
    font-size: 18px;
    background: none !important;
    border: none;
    cursor: pointer;
    border-radius: 4px;
}

.chat-emoji-grid button:hover {
    background: #f0f0f0 !important;
}

/* File input hidden */
#chat-file-input {
    display: none;
}

/* File Attachment Link Styling */
.file-attachment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.file-attachment:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.5);
    color: #5568d3;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.file-attachment i {
    font-size: 18px;
}

/* Image preview in chat */
.message-text img {
    display: block;
    margin-top: 4px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.message-text img:hover {
    transform: scale(1.02);
}
