/* =============================================
   Chat Widget Styles
   Matching Amado Theme: #408bd0 (gold), #131212 (dark), #242424, #6d6d6d, #f5f7fa
   Font: helveticaneuemedium
   ============================================= */

/* ---- Floating Button ---- */
.chat-floating-btn {
    position: fixed;
    bottom: 15px;
    z-index: 10001;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #408bd0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(251, 183, 16, 0.4);
    transition: all 0.3s ease;
    border: 3px solid #fff;
}

html[dir="ltr"] .chat-floating-btn {
    right: 40px;
}

html[dir="rtl"] .chat-floating-btn {
    left: 40px;
}

.chat-floating-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(251, 183, 16, 0.6);
}

.chat-floating-btn.chat-open {
    background-color: #131212;
}

.chat-floating-btn .fa-times {
    color: #fff;
    font-size: 22px;
}

/* Tooltip */
.chat-tooltip {
    position: fixed;
    background-color: #131212;
    color: #408bd0;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    z-index: 10002;
}

.chat-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px;
    border-style: solid;
}

html[dir="ltr"] .chat-tooltip {
    right: 75px;
}

html[dir="ltr"] .chat-tooltip::after {
    left: 100%;
    border-color: transparent transparent transparent #131212;
}

html[dir="rtl"] .chat-tooltip {
    left: 75px;
}

html[dir="rtl"] .chat-tooltip::after {
    right: 100%;
    border-color: transparent #131212 transparent transparent;
}

.chat-floating-btn:hover .chat-tooltip {
    opacity: 1;
    visibility: visible;
}

html[dir="ltr"] .chat-floating-btn:hover .chat-tooltip {
    right: 80px;
}

html[dir="rtl"] .chat-floating-btn:hover .chat-tooltip {
    left: 80px;
}

.chat-btn-logo {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-badge {
    position: absolute;
    top: -4px;
    background-color: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
    animation: chat-badge-pulse 2s infinite;
}

html[dir="ltr"] .chat-badge {
    right: -4px;
}

html[dir="rtl"] .chat-badge {
    left: -4px;
}

@keyframes chat-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ---- Chat Window ---- */
.chat-window {
    position: fixed;
    bottom: 100px;
    z-index: 10001;
    width: 370px;
    max-height: 520px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

html[dir="ltr"] .chat-window {
    right: 50px;
}

html[dir="rtl"] .chat-window {
    left: 50px;
}

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

/* ---- Chat Header ---- */
.chat-header {
    background-color: #131212;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 12px 12px 0 0;
}

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

.chat-header-logo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #408bd0;
}

.chat-header-text h4 {
    color: #fff;
    font-size: 15px;
    margin: 0;
    line-height: 1.3;
    font-weight: 400;
}

.chat-status-online {
    font-size: 12px;
    color: #408bd0;
}

.chat-status-online .fa-circle {
    font-size: 7px;
    color: #2ecc71;
    margin-right: 4px;
    animation: chat-online-pulse 2s infinite;
}

html[dir="rtl"] .chat-status-online .fa-circle {
    margin-right: 0;
    margin-left: 4px;
}

@keyframes chat-online-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- Chat Body ---- */
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f5f7fa;
    min-height: 0; /* Important for flex-shrink */
}


/* ---- Registration Form ---- */
.chat-register-form {
    padding: 30px 25px;
    text-align: center;
}

.chat-welcome-icon {
    width: 70px;
    height: 70px;
    margin: 0 auto 15px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #408bd0;
    box-shadow: 0 4px 15px rgba(251, 183, 16, 0.3);
}

.chat-welcome-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-register-form h5 {
    font-size: 18px;
    color: #242424;
    margin-bottom: 8px;
    font-weight: 400;
}

.chat-register-form p {
    font-size: 13px;
    color: #6d6d6d;
    margin-bottom: 20px;
    line-height: 1.5;
}

.chat-form-group {
    margin-bottom: 12px;
}

.chat-input {
    width: 100%;
    height: 44px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0 15px;
    font-size: 14px;
    color: #242424;
    background-color: #fff;
    transition: all 0.3s ease;
    outline: none;
    font-family: "helveticaneuemedium", sans-serif;
}

.chat-input:focus {
    border-color: #408bd0;
    box-shadow: 0 0 0 3px rgba(251, 183, 16, 0.15);
}

.chat-input-error {
    border-color: #e74c3c;
}

.chat-error-text {
    display: block;
    font-size: 11px;
    color: #e74c3c;
    margin-top: 4px;
    text-align: left;
}

html[dir="rtl"] .chat-error-text {
    text-align: right;
}

.chat-submit-btn {
    width: 100%;
    height: 44px;
    background-color: #408bd0;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 5px;
    font-family: "helveticaneuemedium", sans-serif;
}

.chat-submit-btn:hover {
    background-color: #131212;
}

/* ---- Messages ---- */
.chat-messages {
    padding: 16px;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

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

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

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

.chat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    position: relative;
    animation: chat-msg-appear 0.3s ease;
}

@keyframes chat-msg-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sent (client) - right side */
.chat-message-sent {
    align-self: flex-end;
    background-color: #408bd0;
    color: #fff;
    border-bottom-right-radius: 4px;
}

html[dir="rtl"] .chat-message-sent {
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 4px;
}

/* Received (admin) - left side */
.chat-message-received {
    align-self: flex-start;
    background-color: #fff;
    color: #242424;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

html[dir="rtl"] .chat-message-received {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}

.chat-admin-name {
    display: block;
    font-size: 11px;
    color: #408bd0;
    margin-bottom: 3px;
    font-weight: bold;
}

.chat-message-text {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-message-image {
    margin-bottom: 6px;
    border-radius: 8px;
    overflow: hidden;
}

.chat-message-image img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

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

.chat-message-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    justify-content: flex-end;
}

.chat-message-time {
    font-size: 10px;
    opacity: 0.7;
}

.chat-message-sent .chat-message-time {
    color: rgba(255, 255, 255, 0.8);
}

.chat-message-received .chat-message-time {
    color: #9e9e9e;
}

.chat-message-status {
    display: inline-flex;
    gap: 0;
}

.chat-message-status .fa-check {
    font-size: 10px;
}

.chat-message-status .fa-check + .fa-check {
    margin-left: -6px;
}

html[dir="rtl"] .chat-message-status .fa-check + .fa-check {
    margin-left: 0;
    margin-right: -6px;
}

.chat-read-icon {
    color: #fff;
}

.chat-unread-icon {
    color: rgba(255, 255, 255, 0.5);
}

/* Empty State */
.chat-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #9e9e9e;
}

.chat-empty-state .fa {
    font-size: 40px;
    margin-bottom: 12px;
    color: #ccc;
}

.chat-empty-state p {
    font-size: 13px;
    color: #9e9e9e;
}

/* ---- Chat Footer / Input ---- */
.chat-footer {
    background-color: #fff;
    border-top: 1px solid #eee;
    padding: 10px 12px;
    border-radius: 0 0 12px 12px;
    flex-shrink: 0;
}

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

.chat-attach-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6d6d6d;
    border-radius: 50%;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chat-attach-btn:hover {
    color: #408bd0;
    background-color: #f5f7fa;
}

.chat-attach-btn .fa {
    font-size: 18px;
}

.chat-file-input {
    display: none;
}

.chat-message-input {
    flex: 1;
    height: 40px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 0 16px;
    font-size: 14px;
    color: #242424;
    outline: none;
    transition: all 0.3s ease;
    font-family: "helveticaneuemedium", sans-serif;
}

.chat-message-input:focus {
    border-color: #408bd0;
}

.chat-message-input::placeholder {
    color: #b5b5b5;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background-color: #408bd0;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background-color: #131212;
}

.chat-send-btn .fa {
    font-size: 16px;
}

html[dir="rtl"] .chat-send-btn .fa-paper-plane {
    transform: scaleX(-1);
}

/* Image Preview */
.chat-image-preview {
    position: relative;
    display: inline-block;
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #408bd0;
}

.chat-image-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    display: block;
}

.chat-remove-image {
    position: absolute;
    top: 2px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
}

html[dir="ltr"] .chat-remove-image {
    right: 2px;
}

html[dir="rtl"] .chat-remove-image {
    left: 2px;
}

/* Upload Progress */
.chat-upload-progress {
    height: 3px;
    background-color: #e0e0e0;
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.chat-upload-bar {
    height: 100%;
    width: 60%;
    background-color: #408bd0;
    border-radius: 2px;
    animation: chat-upload-anim 1.5s infinite ease-in-out;
}

@keyframes chat-upload-anim {
    0% { width: 0%; margin-left: 0; }
    50% { width: 60%; }
    100% { width: 0%; margin-left: 100%; }
}

/* ---- Responsive ---- */
@media only screen and (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 20px);
        bottom: 80px;
        max-height: 70vh;
    }

    html[dir="ltr"] .chat-window {
        right: 10px;
    }

    html[dir="rtl"] .chat-window {
        left: 10px;
    }

    .chat-floating-btn {
        width: 52px;
        height: 52px;
        bottom: 20px;
    }

    html[dir="ltr"] .chat-floating-btn {
        right: 25px;
    }

    html[dir="rtl"] .chat-floating-btn {
        left: 25px;
    }

    .chat-btn-logo {
        width: 34px;
        height: 34px;
    }
}

@media only screen and (max-width: 767px) {
    .chat-window {
        bottom: 85px;
    }
}
