/*
 * TuanButtonContact — Frontend CSS v2.0
 * Prefix: .tbc-   |   z-index base: 99999
 * Dùng CSS custom properties inject từ PHP (class-tbc-frontend.php)
 */

/* ── Reset cho plugin ─────────────────────────────────────────────────────── */
.tbc-pc-wrap *,
.tbc-mobile-wrap * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: inherit;
    line-height: 1;
    text-decoration: none;
}

/* ══════════════════════════════════════════════════════════════════════════
   PC WRAPPER — chỉ hiện trên desktop
══════════════════════════════════════════════════════════════════════════ */
.tbc-pc-wrap {
    position: fixed;
    bottom: var(--tbc-bottom, 70px);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.tbc-pc-right { right: var(--tbc-side, 15px); }
.tbc-pc-left  { left:  var(--tbc-side, 15px); }

/* Ẩn PC trên mobile */
@media (max-width: 850px) {
    .tbc-pc-wrap { display: none !important; }
}

/* ── Nút tròn dùng chung PC ──────────────────────────────────────────────── */
.tbc-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    color: #fff;
    position: relative;
    overflow: visible;
    transition: filter 0.2s, transform 0.2s;
    flex-shrink: 0;
}
.tbc-btn svg { width: 24px; height: 24px; fill: #fff; pointer-events: none; }
.tbc-btn img { width: 24px; height: 24px; object-fit: contain; pointer-events: none; }
.tbc-btn:hover {
    filter: brightness(0.88);
    transform: scale(1.08);
}
/* Scroll-top ẩn cho đến khi user scroll */
.tbc-btn-top { opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; }
.tbc-btn-top.tbc-top-show { opacity: 1; visibility: visible; }

/* ── Nút Toggle dọc (PC Classic) ─────────────────────────────────────────── */
.tbc-toggle-btn {
    color: #fff;
    padding: 10px 8px;
    border-radius: 16px;
    writing-mode: vertical-rl;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    transition: filter 0.2s;
}
.tbc-toggle-btn:hover { filter: brightness(0.88); color: #fff; }

/* ── Animations ──────────────────────────────────────────────────────────── */

/* wave — tỏa sóng (mặc định) */
.tbc-anim-wave .tbc-btn::before,
.tbc-anim-wave .tbc-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.55);
    animation: tbc-wave 1.7s infinite;
    pointer-events: none;
}
.tbc-anim-wave .tbc-btn::before { animation-delay: 0.85s; }
@keyframes tbc-wave {
    0%   { transform: scale(1);    opacity: 0.8; }
    70%  { transform: scale(1.85); opacity: 0; }
    100% { transform: scale(1.85); opacity: 0; }
}

/* shake — rung */
.tbc-anim-shake .tbc-btn {
    animation: tbc-shake 0.55s infinite;
}
@keyframes tbc-shake {
    0%,100% { transform: rotate(0deg); }
    20%     { transform: rotate(12deg); }
    40%     { transform: rotate(-12deg); }
    60%     { transform: rotate(8deg); }
    80%     { transform: rotate(-8deg); }
}

/* pulse — nhịp đập */
.tbc-anim-pulse .tbc-btn {
    animation: tbc-pulse 1.4s infinite;
}
@keyframes tbc-pulse {
    0%,100% { transform: scale(1); }
    50%     { transform: scale(1.12); }
}

/* bounce — nảy */
.tbc-anim-bounce .tbc-btn {
    animation: tbc-bounce 1.4s infinite;
}
@keyframes tbc-bounce {
    0%,100% { transform: translateY(0); }
    50%     { transform: translateY(-6px); }
}

/* none — không */
.tbc-anim-none .tbc-btn::before,
.tbc-anim-none .tbc-btn::after { display: none; }

/* Tắt hết animation nếu user cài prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .tbc-btn,
    .tbc-btn::before,
    .tbc-btn::after,
    .tbc-toggle-btn { animation: none !important; }
}

/* ══════════════════════════════════════════════════════════════════════════
   PC / CLASSIC
══════════════════════════════════════════════════════════════════════════ */
.tbc-classic {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.tbc-classic .tbc-btn { box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.tbc-classic .tbc-toggle-btn { box-shadow: 0 4px 10px rgba(0,0,0,0.2); }

/* ══════════════════════════════════════════════════════════════════════════
   PC / BUBBLE-EXPAND
══════════════════════════════════════════════════════════════════════════ */
.tbc-bubble {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Nút chính */
.tbc-bubble-trigger {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    position: relative;
    z-index: 2;
    transition: transform 0.25s, filter 0.2s;
    overflow: visible;
}
.tbc-bubble-trigger svg { width: 26px; height: 26px; fill: #fff; }
.tbc-bubble-trigger:hover { filter: brightness(0.88); transform: scale(1.07); }

.tbc-bubble-icon-close { display: none; font-size: 20px; font-weight: 700; }
.tbc-bubble-trigger[aria-expanded="true"] .tbc-bubble-icon-open  { display: none; }
.tbc-bubble-trigger[aria-expanded="true"] .tbc-bubble-icon-close { display: block; }

/* Nút con */
.tbc-bubble-children {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.25s ease;
    pointer-events: none;
}
.tbc-bubble.is-open .tbc-bubble-children {
    max-height: 500px;
    opacity: 1;
    pointer-events: auto;
}

.tbc-bubble-child {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    position: relative;
    transition: filter 0.2s, transform 0.15s;
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.2s ease, filter 0.2s;
}
.tbc-bubble-child svg { width: 22px; height: 22px; fill: #fff; }
.tbc-bubble.is-open .tbc-bubble-child {
    transform: scale(1);
    opacity: 1;
}
.tbc-bubble-child:hover { filter: brightness(0.88); transform: scale(1.08) !important; }

/* Tooltip label */
.tbc-bubble-tip {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.72);
    color: #fff;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}
.tbc-bubble-child:hover .tbc-bubble-tip { opacity: 1; }

/* Scroll top trong bubble layout */
.tbc-bubble-top {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    transition: filter 0.2s, opacity 0.3s, visibility 0.3s;
    opacity: 0;
    visibility: hidden;
}
.tbc-bubble-top svg { width: 22px; height: 22px; fill: #fff; }
.tbc-bubble-top.tbc-top-show { opacity: 1; visibility: visible; }
.tbc-bubble-top:hover { filter: brightness(0.88); }

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE WRAPPER — chỉ hiện trên mobile
══════════════════════════════════════════════════════════════════════════ */
.tbc-mobile-wrap {
    display: none;
    z-index: 99999;
}
@media (max-width: 850px) {
    .tbc-mobile-wrap { display: block; }
}

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE / FOOTER-5
══════════════════════════════════════════════════════════════════════════ */
#tbc-footer5 {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 99999;
    background: #fff;
    border-top: 1px solid #e8e8e8;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.1);
}
.tbc-footer5-inner {
    display: flex;
    align-items: stretch;
    max-width: 640px;
    margin: 0 auto;
}

.tbc-f5-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 4px 6px;
    color: #444;
    font-size: 10px;
    font-weight: 600;
    gap: 3px;
    position: relative;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s;
    min-width: 0;
}
.tbc-f5-btn svg { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }
.tbc-f5-btn img { width: 22px; height: 22px; object-fit: contain; flex-shrink: 0; }
.tbc-f5-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
}
.tbc-f5-btn:hover { color: var(--tbc-c-phone, #e60000); }

/* Nút center phone */
.tbc-f5-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 6px;
    position: relative;
    text-decoration: none;
    color: #444;
    font-size: 10px;
    font-weight: 600;
    gap: 3px;
    padding-top: 4px;
}
.tbc-f5-center-ring {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #fff;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.18);
    overflow: visible;
    z-index: 1;
}
.tbc-f5-center-ring svg { width: 22px; height: 22px; fill: #fff; }

/* Pulse ring trên nút phone center */
.tbc-f5-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    box-shadow: 0 0 0 0 currentColor;
    animation: tbc-pulse-ring 1.4s infinite;
    opacity: 0.6;
}
.tbc-f5-center-ring:has(.tbc-f5-pulse) { color: var(--tbc-c-phone, #e60000); }
@keyframes tbc-pulse-ring {
    0%   { box-shadow: 0 0 0 0 currentColor; }
    70%  { box-shadow: 0 0 0 12px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* Center text bên dưới */
.tbc-f5-center > span { margin-top: 30px; display: block; }

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE / FLOATING BUBBLE
══════════════════════════════════════════════════════════════════════════ */
#tbc-mob-bubble {
    position: fixed;
    right: 16px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Nút chính */
.tbc-mob-bubble-trigger {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.28);
    position: relative;
    z-index: 2;
    transition: transform 0.25s, filter 0.2s;
    animation: tbc-wave 1.7s infinite;
    overflow: visible;
}
.tbc-mob-bubble-trigger::before,
.tbc-mob-bubble-trigger::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
    animation: tbc-wave 1.7s infinite;
    pointer-events: none;
}
.tbc-mob-bubble-trigger::before { animation-delay: 0.85s; }
.tbc-mob-bubble-trigger svg { width: 26px; height: 26px; fill: #fff; }
.tbc-mob-bubble-trigger:hover { filter: brightness(0.88); transform: scale(1.06); }

.tbc-mob-icon-close { display: none; font-size: 22px; font-weight: 700; color: #fff; }
.tbc-mob-bubble-trigger[aria-expanded="true"] .tbc-mob-icon-open  { display: none; }
.tbc-mob-bubble-trigger[aria-expanded="true"] .tbc-mob-icon-close { display: block; }

/* Nút con */
.tbc-mob-bubble-children {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.25s ease;
    pointer-events: none;
}
#tbc-mob-bubble.is-open .tbc-mob-bubble-children {
    max-height: 600px;
    opacity: 1;
    pointer-events: auto;
}

.tbc-mob-bubble-child {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 3px 10px rgba(0,0,0,0.22);
    position: relative;
    transform: scale(0.7);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.2s ease, filter 0.2s;
}
.tbc-mob-bubble-child svg { width: 22px; height: 22px; fill: #fff; }
#tbc-mob-bubble.is-open .tbc-mob-bubble-child {
    transform: scale(1);
    opacity: 1;
}
.tbc-mob-bubble-child:hover { filter: brightness(0.88); }

/* Tooltip */
.tbc-mob-bubble-tip {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.72);
    color: #fff;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}
.tbc-mob-bubble-child:active .tbc-mob-bubble-tip { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
    .tbc-mob-bubble-trigger,
    .tbc-mob-bubble-trigger::before,
    .tbc-mob-bubble-trigger::after { animation: none !important; }
}

/* ══════════════════════════════════════════════════════════════════════════
   MoMo MODAL (frontend)
══════════════════════════════════════════════════════════════════════════ */
#tbc-momo-modal {
    position: fixed;
    inset: 0;
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
}
#tbc-momo-modal[hidden] { display: none !important; }
.tbc-momo-bd {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(2px);
    cursor: pointer;
}
.tbc-momo-box {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 14px;
    max-width: 92vw;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    text-align: center;
}
.tbc-momo-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 10px;
    color: #1a1f36;
}
.tbc-momo-box img {
    display: block;
    max-width: 80vw;
    max-height: 65vh;
    width: auto;
    height: auto;
    margin: 0 auto;
    border-radius: 8px;
}
.tbc-momo-x {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: #f3f3f3;
    cursor: pointer;
    font-size: 18px;
    line-height: 30px;
    color: #666;
}
.tbc-momo-x:hover { background: #e5e5e5; }
