/**
 * Website Chat Widget Styles
 *
 * Includes all styles from the main chat widget plus website-specific additions
 */

/* Widget Container */
#chat-widget {
    position: fixed;
    bottom: 90px; /* Above WhatsApp button */
    right: 24px;
    z-index: 10001;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#chat-widget.dragging {
    transition: none;
}

#chat-widget.dragging .chat-widget-button {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(54, 139, 193, 0.5);
}

/* Floating Button */
.chat-widget-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #368BC1;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(54, 139, 193, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.chat-widget-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(54, 139, 193, 0.5);
}

.chat-widget-button.hidden {
    display: none;
}

.chat-widget-button .chat-icon {
    width: 26px;
    height: 26px;
    color: white;
}

.chat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Status Dot on Button */
.chat-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    background: #9ca3af;
    transition: background 0.2s ease;
}

.chat-status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.chat-status-dot.offline {
    background: #ef4444;
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* Header */
.chat-header {
    padding: 16px 20px;
    background: #368BC1;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

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

.chat-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9ca3af;
}

.chat-status-indicator.online {
    background: #34d399;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.chat-status-indicator.offline {
    background: #f87171;
}

.chat-header-title {
    font-weight: 600;
    font-size: 16px;
}

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

.chat-header-actions button {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chat-header-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-header-actions button svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* Body */
.chat-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Start Screen */
.chat-start-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
}

.chat-start-icon {
    width: 80px;
    height: 80px;
    background: #f3f4f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.chat-start-icon svg {
    width: 40px;
    height: 40px;
    color: #368BC1;
}

.chat-start-screen h3 {
    margin: 0 0 8px;
    font-size: 20px;
    color: #1f2937;
}

.chat-start-screen p {
    margin: 0 0 20px;
    color: #6b7280;
    font-size: 14px;
}

.chat-language-notice {
    margin: -12px 0 16px !important;
    color: #9ca3af !important;
    font-size: 12px !important;
    font-style: italic;
}

/* Name Input Field - Website specific */
.chat-name-field {
    width: 100%;
    margin-bottom: 12px;
}

.chat-name-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.chat-name-input:focus {
    outline: none;
    border-color: #368BC1;
    box-shadow: 0 0 0 3px rgba(54, 139, 193, 0.1);
}

.chat-name-input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

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

.chat-initial-message {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    resize: none;
    margin-bottom: 16px;
    font-family: inherit;
    box-sizing: border-box;
}

.chat-initial-message:focus {
    outline: none;
    border-color: #368BC1;
    box-shadow: 0 0 0 3px rgba(54, 139, 193, 0.1);
}

.chat-start-btn {
    width: 100%;
    padding: 14px 24px;
    background: #368BC1;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-start-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(54, 139, 193, 0.4);
}

.chat-start-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.chat-offline-notice {
    color: #ef4444;
    font-size: 13px;
    margin-top: 12px;
}

/* Error Message */
.chat-error-message {
    width: 100%;
    padding: 10px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    animation: fadeIn 0.2s ease;
}

/* Messages Screen */
.chat-messages-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

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

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

.chat-message {
    max-width: 85%;
    animation: fadeIn 0.2s ease;
}

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

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

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

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

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

.chat-message.user .message-content {
    background: #368BC1;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.admin .message-content {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.chat-message.system .message-content {
    background: transparent;
    color: #6b7280;
    font-size: 13px;
    text-align: center;
    padding: 8px 16px;
}

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

.chat-message.user .message-time {
    text-align: right;
}

/* Typing Indicator */
.chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    color: #6b7280;
}

.typing-dots {
    display: flex;
    gap: 2px;
}

.typing-dots span {
    animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.3;
    }
    30% {
        opacity: 1;
    }
}

/* Input Area */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    line-height: 1.4;
    overflow-y: hidden;
    box-sizing: border-box;
}

.chat-input:focus {
    outline: none;
    border-color: #368BC1;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    background: #368BC1;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

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

.chat-send-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Ended Bar */
.chat-ended-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.chat-ended-bar span {
    color: #6b7280;
    font-size: 14px;
}

.chat-new-btn {
    padding: 8px 16px;
    background: #368BC1;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.chat-new-btn:hover {
    background: #5a6fd6;
}

/* Confirmation Modal */
.chat-widget-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10010;
    animation: fadeIn 0.2s ease;
}

.chat-widget-modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.chat-widget-modal h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.chat-widget-modal p {
    margin: 0 0 20px 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
}

.chat-widget-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.chat-widget-modal-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.2s ease;
}

.chat-widget-modal-btn.cancel {
    background: #f3f4f6;
    color: #374151;
}

.chat-widget-modal-btn.cancel:hover {
    background: #e5e7eb;
}

.chat-widget-modal-btn.confirm {
    background: #ef4444;
    color: white;
}

.chat-widget-modal-btn.confirm:hover {
    background: #dc2626;
}

/* Tooltip */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    background: #333;
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.875rem;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10002;
    pointer-events: none;
}

[data-tooltip]::after {
    content: '';
    position: absolute;
    border: 6px solid transparent;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10002;
    pointer-events: none;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

[data-tooltip-position="left"]::before {
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
}

[data-tooltip-position="left"]::after {
    right: calc(100% + 4px);
    top: 50%;
    transform: translateY(-50%);
    border-left-color: #333;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #chat-widget {
        bottom: 76px; /* Above WhatsApp button (16 + 50 + 10 gap) */
        right: 16px;
    }

    .chat-widget-button {
        width: 50px;
        height: 50px;
    }

    .chat-widget-button .chat-icon svg {
        width: 24px;
        height: 24px;
    }

    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    /* Hide tooltip on mobile */
    [data-tooltip]::before,
    [data-tooltip]::after {
        display: none;
    }
}
