/* =============================================
   SOR Chat WA - Public Frontend Styles v1.2.0
   ============================================= */

/* ==========================================
   GROUP CONTAINER (position fixed anchor)
   ========================================== */
.sor-group {
    position: fixed;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.sor-pos-bottom-right  { bottom: 24px; right: 24px; align-items: flex-end; }
.sor-pos-bottom-left   { bottom: 24px; left: 24px;  align-items: flex-start; }
.sor-pos-bottom-center { bottom: 24px; left: 50%; transform: translateX(-50%); align-items: center; }

/* ==========================================
   SINGLE CHATBOX ITEM (not fixed — lives inside .sor-group)
   ========================================== */
.sor-chatbox-item {
    --sor-cb-color: #25D366;
    position: relative;
}

/* ==========================================
   STACK (multiple chatboxes same position)
   ========================================== */
.sor-stack {
    display: flex;
    flex-direction: column;
    align-items: inherit; /* inherits from .sor-group */
    gap: 0;
    position: relative;
}

/* List of items that slides up/down */
.sor-stack-list {
    display: flex;
    flex-direction: column-reverse; /* newest on bottom, near toggle */
    align-items: inherit;
    gap: 8px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    transition:
        max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        opacity    0.25s ease,
        margin-bottom 0.3s ease;
}

.sor-stack-list.sor-stack-open {
    max-height: 600px; /* big enough for many items */
    opacity: 1;
    margin-bottom: 12px;
}

/* Each item row inside stack */
.sor-stack-item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    animation: sorSlideUp 0.25s ease forwards;
}

.sor-pos-bottom-left .sor-stack-item-row  { flex-direction: row-reverse; }
.sor-pos-bottom-center .sor-stack-item-row { flex-direction: row; }

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

/* Label chip in stack */
.sor-stack-item-label {
    background: #fff;
    color: #111827;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Small round button used in stacked row */
.sor-btn-sm-round {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: var(--sor-cb-color) !important;
    color: #fff !important;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(0,0,0,.2) !important;
    transition: transform .15s, box-shadow .15s !important;
    flex-shrink: 0;
}
.sor-btn-sm-round:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 4px 14px rgba(0,0,0,.28) !important;
    color: #fff !important;
}
.sor-btn-sm-round svg { width: 22px; height: 22px; }

/* ---- Stack toggle button ---- */
.sor-stack-toggle {
    position: relative;
    width: 58px; height: 58px;
    border-radius: 50%;
    background: #25D366;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.28);
    transition: background .2s, transform .2s, box-shadow .2s;
    flex-shrink: 0;
}
.sor-stack-toggle svg { width: 28px; height: 28px; }
.sor-stack-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,.32);
}
.sor-stack-toggle.sor-stack-open {
    background: #ef4444;
}
.sor-stack-icon-close {
    font-size: 24px;
    line-height: 1;
    font-weight: 300;
}

/* Badge showing count */
.sor-stack-badge {
    position: absolute;
    top: -2px; right: -2px;
    min-width: 20px; height: 20px;
    background: #ef4444;
    color: #fff;
    font-size: 11px; font-weight: 800;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.sor-stack-toggle.sor-stack-open .sor-stack-badge { display: none; }

/* ==========================================
   BASE WA BUTTON (standalone, single chatbox)
   ========================================== */
.sor-btn-wa {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sor-cb-color);
    color: #fff;
    border-radius: 50%;
    width: 58px; height: 58px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    transition: transform .2s, box-shadow .2s;
    cursor: pointer;
}
.sor-btn-wa svg { width: 28px; height: 28px; }
.sor-btn-wa:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,.3);
    color: #fff;
}

/* ---- Tooltip (standalone only) ---- */
.sor-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: #333;
    color: #fff;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    animation: sorFadeIn .3s ease;
    max-width: 200px;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
}
.sor-tooltip::after {
    content: '';
    position: absolute;
    top: 100%; right: 18px;
    border: 6px solid transparent;
    border-top-color: #333;
}
.sor-pos-bottom-left .sor-tooltip  { right: auto; left: 0; }
.sor-pos-bottom-left .sor-tooltip::after { right: auto; left: 18px; }
.sor-pos-bottom-center .sor-tooltip { left: 50%; transform: translateX(-50%); right: auto; }
.sor-pos-bottom-center .sor-tooltip::after { left: 50%; transform: translateX(-50%); right: auto; }

/* ---- Layout 2: Button + Label ---- */
.sor-btn-with-label {
    border-radius: 29px !important;
    width: auto !important;
    padding: 0 18px 0 12px;
    gap: 8px;
}
.sor-btn-with-label svg { width: 24px; height: 24px; flex-shrink: 0; }
.sor-btn-label { font-size: 14px; font-weight: 700; }

/* ---- Layout 3: Oval ---- */
.sor-btn-oval {
    border-radius: 29px !important;
    width: auto !important;
    padding: 0 20px;
    height: 50px;
    gap: 10px;
    font-size: 14px; font-weight: 700;
}

/* ---- Layout 4: Card ---- */
.sor-card-wa {
    display: flex; align-items: center; gap: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    transition: transform .2s, box-shadow .2s;
    min-width: 180px;
}
.sor-card-wa:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.sor-card-wa-icon {
    width: 44px; height: 44px; flex-shrink: 0;
    background: var(--sor-cb-color);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white;
}
.sor-card-wa-icon svg { width: 24px; height: 24px; }
.sor-card-wa-text { display: flex; flex-direction: column; gap: 2px; }
.sor-card-wa-subtitle { font-size: 11px; color: #6b7280; }
.sor-card-wa-title { font-size: 13px; font-weight: 700; color: #111827; }

/* ---- Layout 5: Bubble ---- */
.sor-bubble-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.sor-pos-bottom-left .sor-bubble-wrap { align-items: flex-start; }
.sor-bubble-message {
    background: #fff;
    border-radius: 12px 12px 0 12px;
    padding: 10px 14px;
    font-size: 13px; color: #111827;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    max-width: 200px;
    display: flex; align-items: center; gap: 8px;
    animation: sorFadeIn .3s ease;
}
.sor-pos-bottom-left .sor-bubble-message { border-radius: 12px 12px 12px 0; }
.sor-bubble-close {
    background: none; border: none; cursor: pointer;
    font-size: 16px; color: #9ca3af; padding: 0; line-height: 1; flex-shrink: 0;
}
.sor-bubble-close:hover { color: #ef4444; }

/* ---- Layout 6: Floating Bar ---- */
.sor-layout-6 {
    position: fixed !important;
    bottom: 0; right: 0; left: 0;
    width: 100%;
    z-index: 9999;
}
.sor-floating-bar {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: var(--sor-cb-color); color: white;
    padding: 14px 20px;
    text-decoration: none; font-size: 15px; font-weight: 700;
    box-shadow: 0 -2px 10px rgba(0,0,0,.15);
    transition: opacity .2s;
}
.sor-floating-bar:hover { opacity: .9; color: white; }

/* ---- Layout 7: Chat Window ---- */
.sor-window-toggle {
    width: 58px; height: 58px; border-radius: 50%;
    background: var(--sor-cb-color); color: white; border: none;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    transition: transform .2s, box-shadow .2s;
    font-size: 26px; line-height: 1;
}
.sor-window-toggle svg { width: 28px; height: 28px; }
.sor-window-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.sor-chat-window {
    position: absolute; bottom: 70px; right: 0;
    width: 300px;
    background: #fff; border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,.2);
    overflow: hidden;
    animation: sorFadeIn .2s ease;
}
.sor-pos-bottom-left .sor-chat-window { right: auto; left: 0; }
.sor-chat-window-header {
    background: var(--sor-cb-color); padding: 14px 16px;
    display: flex; align-items: center; gap: 10px;
}
.sor-chat-window-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    color: white;
}
.sor-chat-window-name { display: block; color: white; font-weight: 700; font-size: 14px; }
.sor-chat-window-status { display: flex; align-items: center; gap: 5px; font-size: 12px; color: rgba(255,255,255,.8); }
.sor-online-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; display: inline-block; }
.sor-chat-window-body { padding: 16px; background: #f0f2f5; min-height: 80px; }
.sor-chat-message { display: flex; flex-direction: column; align-items: flex-start; }
.sor-chat-bubble {
    background: white; padding: 8px 12px; border-radius: 0 8px 8px 8px;
    font-size: 13px; color: #111827; box-shadow: 0 1px 2px rgba(0,0,0,.1); max-width: 90%;
}
.sor-chat-time { font-size: 10px; color: #9ca3af; margin-top: 4px; }
.sor-chat-window-footer { padding: 12px 16px; border-top: 1px solid #e5e7eb; }
.sor-chat-window-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--sor-cb-color); color: white;
    padding: 10px 16px; border-radius: 8px;
    text-decoration: none; font-size: 14px; font-weight: 700;
    transition: opacity .15s; width: 100%;
}
.sor-chat-window-btn:hover { opacity: .9; color: white; }

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes sorFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
@keyframes sorShake {
    0%, 100% { transform: rotate(0deg); }
    10%, 30%, 50%, 70%, 90% { transform: rotate(-8deg); }
    20%, 40%, 60%, 80%      { transform: rotate(8deg); }
}
@keyframes sorPulse {
    0%   { box-shadow: 0 0 0 0 rgba(37,211,102,.6); }
    70%  { box-shadow: 0 0 0 14px rgba(37,211,102,0); }
    100% { box-shadow: 0 0 0 0 rgba(37,211,102,0); }
}

.sor-anim-shake .sor-btn-wa       { animation: sorShake 1.5s ease-in-out 2s 3; }
.sor-anim-pulse .sor-btn-wa       { animation: sorPulse 1.5s infinite; }
.sor-anim-shake .sor-window-toggle { animation: sorShake 1.5s ease-in-out 2s 3; }
.sor-anim-pulse .sor-window-toggle { animation: sorPulse 1.5s infinite; }
.sor-anim-shake .sor-stack-toggle  { animation: sorShake 1.5s ease-in-out 2s 3; }
.sor-anim-pulse .sor-stack-toggle  { animation: sorPulse 1.5s infinite; }

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 480px) {
    .sor-pos-bottom-right { bottom: 16px; right: 16px; }
    .sor-pos-bottom-left  { bottom: 16px; left: 16px; }
    .sor-chat-window { width: 270px; }
    .sor-btn-with-label .sor-btn-label,
    .sor-btn-oval span { font-size: 12px; }
    .sor-stack-item-label { max-width: 140px; font-size: 12px; }
}
