/* ===== AFANLY Website - Live Chat Widget Styles ===== */
/* Theme Unified: Perfectly integrates with Light Mode and Dark Mode */
/* Zero Emoji Policy - Clean, Minimalist, Corporate Navy/Blue Design */

.afanly-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1040; /* Berada tepat di bawah header namun di atas konten */
    font-family: var(--font-primary, system-ui, -apple-system, sans-serif);
}

/* Floating Launch Button */
.afanly-chat-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--primary-color, #2563eb);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(37, 99, 235, 0.35);
    transition: all 0.2s ease;
}

.afanly-chat-btn:hover {
    background: var(--primary-hover, #1d4ed8);
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(37, 99, 235, 0.45);
}

.afanly-chat-badge {
    background: #ef4444;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Chat Card Window */
.afanly-chat-window {
    display: none;
    flex-direction: column;
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 380px;
    height: 530px;
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: afanlyChatSlide 0.25s ease-out forwards;
}

.afanly-chat-window.open {
    display: flex;
}

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

/* Chat Header */
.afanly-chat-header {
    background: var(--bg-secondary, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.afanly-chat-header-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color, #0f172a);
    margin: 0;
}

.afanly-chat-header-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary, #475569);
    margin-top: 2px;
}

.afanly-chat-close-btn {
    background: transparent;
    border: 1px solid var(--border-color, #cbd5e1);
    color: var(--text-color, #0f172a);
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.15s;
}

.afanly-chat-close-btn:hover {
    background: var(--border-color, #e2e8f0);
}

/* Chat Form Panel (Before Starting) */
.afanly-chat-form-pane {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: var(--card-bg, #ffffff);
    color: var(--text-color, #0f172a);
}

.afanly-chat-form-notice {
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.82rem;
    color: var(--primary-color, #2563eb);
    line-height: 1.45;
    margin-bottom: 16px;
}

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

.afanly-chat-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, #475569);
    margin-bottom: 5px;
}

.afanly-chat-input,
.afanly-chat-textarea {
    width: 100%;
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 0.86rem;
    color: var(--text-color, #0f172a);
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.afanly-chat-input:focus,
.afanly-chat-textarea:focus {
    outline: none;
    border-color: var(--primary-color, #2563eb);
}

.afanly-chat-textarea {
    resize: none;
    height: 65px;
}

.afanly-chat-submit-btn {
    width: 100%;
    background: var(--primary-color, #2563eb);
    color: #ffffff;
    border: none;
    padding: 11px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
}

.afanly-chat-submit-btn:hover {
    background: var(--primary-hover, #1d4ed8);
}

/* Chat Body (Messages Pane) */
.afanly-chat-messages-pane {
    display: none;
    flex-direction: column;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

.afanly-chat-staff-bar {
    background: var(--bg-secondary, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    padding: 8px 14px;
    font-size: 0.78rem;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.afanly-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
}

.afanly-chat-history {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    background: var(--card-bg, #ffffff);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubbles */
.afanly-bubble {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 8px;
    font-size: 0.84rem;
    line-height: 1.45;
    word-break: break-word;
}

.afanly-bubble.customer {
    align-self: flex-end;
    background: var(--primary-color, #2563eb);
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.afanly-bubble.admin {
    align-self: flex-start;
    background: var(--bg-secondary, #f1f5f9);
    border: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-color, #0f172a);
    border-bottom-left-radius: 2px;
}

.afanly-bubble.system {
    align-self: center;
    max-width: 90%;
    background: var(--bg-secondary, #f8fafc);
    border: 1px dashed var(--border-color, #cbd5e1);
    color: var(--text-secondary, #64748b);
    font-size: 0.78rem;
    text-align: center;
    border-radius: 6px;
    padding: 8px 12px;
}

.afanly-bubble-meta {
    font-size: 0.7rem;
    margin-bottom: 3px;
    font-weight: 600;
}

.afanly-bubble.customer .afanly-bubble-meta {
    color: rgba(255, 255, 255, 0.85);
    text-align: right;
}

.afanly-bubble.admin .afanly-bubble-meta {
    color: var(--primary-color, #2563eb);
}

.afanly-bubble-time {
    font-size: 0.68rem;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

/* Chat Footer (Input) */
.afanly-chat-footer {
    background: var(--bg-secondary, #f8fafc);
    border-top: 1px solid var(--border-color, #e2e8f0);
    padding: 10px 14px;
    display: flex;
    gap: 8px;
}

.afanly-chat-msg-input {
    flex: 1;
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 0.86rem;
    color: var(--text-color, #0f172a);
}

.afanly-chat-msg-input:focus {
    outline: none;
    border-color: var(--primary-color, #2563eb);
}

.afanly-chat-send-btn {
    background: var(--primary-color, #2563eb);
    color: #ffffff;
    border: none;
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
}

.afanly-chat-send-btn:hover {
    background: var(--primary-hover, #1d4ed8);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .afanly-chat-widget {
        bottom: 16px;
        right: 16px;
    }
    .afanly-chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 85vh;
        border-radius: 14px 14px 0 0;
    }
}
