/* =================================================
   Modern OrderHelp Chat Styles (WoodMart Safe)
================================================== */

/* Container must NOT be fixed */
#orderhelp-chat-container {
    position: relative !important;
    z-index: 900;
}

/* ===============================
   Chat Icon (ONLY fixed element)
=============================== */
#orderhelp-chat-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;

    width: 64px;
    height: 64px;
    background: linear-gradient(135deg,#25D366,#128C7E);
    color: #fff;
    font-size: 28px;
    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    box-shadow: 0 8px 26px rgba(0,0,0,0.20);
    transition: transform .18s ease, box-shadow .18s ease;

    z-index: 900;
}

/* hover/focus */
#orderhelp-chat-icon:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 36px rgba(0,0,0,0.28);
}

/* Pulse for unread */
#orderhelp-chat-icon.pulse {
    animation: pulseAnim 1.2s ease;
}
@keyframes pulseAnim {
    0% { transform: scale(1); box-shadow: 0 0 0 rgba(37,211,102,0.5); }
    50% { transform: scale(1.15); box-shadow: 0 0 18px rgba(37,211,102,0.45); }
    100% { transform: scale(1); box-shadow: 0 0 0 rgba(37,211,102,0); }
}

/* Unread badge */
.unread-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ff3b3b;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    border-radius: 999px;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

/* ===============================
   Chat Box (fixed & isolated)
=============================== */
#orderhelp-chat-box {
    position: fixed;
    bottom: 96px;
    right: 20px;

    width: 360px;
    max-width: calc(100vw - 40px);
    max-height: 76vh;

    background: rgba(255,255,255,0.985);
    border-radius: 14px;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 12px 40px rgba(0,0,0,0.26);

    display: none;
    flex-direction: column;
    overflow: hidden;

    opacity: 0;
    transform: translateY(12px);
    transition: transform .22s ease, opacity .22s ease;

    backdrop-filter: blur(6px);
    z-index: 900;
}

/* visible */
#orderhelp-chat-box.show {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* ===============================
   Header
=============================== */
#orderhelp-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: linear-gradient(135deg,#25D366,#128C7E);
    color: #fff;
    font-weight: 600;
    font-size: 15px;
}

#orderhelp-chat-header .agent {
    display:flex;
    flex-direction: column;
}
#orderhelp-chat-header .status {
    font-size: 12px;
    opacity: 0.8;
}

/* ===============================
   Messages
=============================== */
#orderhelp-chat-messages {
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Message bubble */
.msg {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.04);
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
    opacity: 0;
    transform: translateY(8px);
}
.msg.appear {
    animation: fadeInUp 0.35s ease forwards;
}
@keyframes fadeInUp {
    to { opacity: 1; transform: translateY(0); }
}

.user-msg { background: #85f72a; align-self: flex-end; }
.admin-msg { background: #91fffc; align-self: flex-start; }

.msg .time {
    display: block;
    font-size: 11px;
    color: rgba(0,0,0,0.55);
    margin-top: 6px;
    text-align: right;
}

/* Typing indicator */
#typing-indicator .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #aaa;
    display: inline-block;
    margin-right: 4px;
    animation: blink 1.2s infinite ease-in-out;
}
#typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
#typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
    0%,80%,100% { opacity:0.2 }
    40% { opacity:1; transform:translateY(-3px); }
}

/* Input */
.input-container {
    display:flex;
    gap:8px;
    padding:10px;
    border-top:1px solid rgba(0,0,0,0.04);
    align-items:center;
    background:#fff;
}
.input-container input {
    flex:1;
    padding:10px 12px;
    border-radius:10px;
    border:1px solid rgba(0,0,0,0.06);
    font-size:14px;
}
.input-container button {
    padding:9px 14px;
    border-radius:10px;
    border:none;
    background:linear-gradient(135deg,#25D366,#128C7E);
    color:#fff;
    font-weight:700;
    cursor:pointer;
}

/* Register form */
.register-form {
    display:flex;
    flex-direction:column;
    gap:8px;
    padding:6px 0;
}
.register-form input {
    width:100%;
    padding:9px 10px;
    border-radius:8px;
    border:1px solid rgba(0,0,0,0.08);
    font-size:14px;
}
.register-form button {
    padding:9px 12px;
    border-radius:8px;
    border:none;
    background:linear-gradient(135deg,#25D366,#128C7E);
    color:#fff;
    font-weight:600;
    cursor:pointer;
}

/* ===============================
   Mobile Fixes
=============================== */
@media (max-width: 480px) {
    #orderhelp-chat-box {
        width: 100vw;
        right: 0;
        bottom: 0;
        border-radius: 14px 14px 0 0;
    }
}

/* ===============================
   WoodMart Compatibility
=============================== */
body.wd-side-cart-open #orderhelp-chat-icon,
body.wd-side-cart-open #orderhelp-chat-box {
    display: none !important;
}
