/*
 * Riza Chat – Frontend Styles
 * All dynamic values come from inline CSS variables on #hcc-widget.
 */

/* ── Reset / Base ──────────────────────────────────────────────────── */
#hcc-widget,
#hcc-widget * {
    box-sizing: border-box;
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ── Widget wrapper ────────────────────────────────────────────────── */
#hcc-widget {
    position: fixed;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--hcc-gap, 12px);
    /* Position set per direction class below */
}

.hcc-bottom-right {
    bottom: var(--hcc-bottom, 30px);
    right:  var(--hcc-side,   30px);
    left:   auto;
    align-items: flex-end;
}

.hcc-bottom-left {
    bottom: var(--hcc-bottom, 30px);
    left:   var(--hcc-side,   30px);
    right:  auto;
    align-items: flex-start;
}

/* ── Toggle button ─────────────────────────────────────────────────── */
.hcc-btn {
    width:   var(--hcc-size, 60px);
    height:  var(--hcc-size, 60px);
    border-radius: 50%;
    border: none;
    background-color: var(--hcc-color, #128C7E);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 4px 18px rgba(0,0,0,.28);
    transition: transform .25s ease, box-shadow .25s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    outline: none;
}

.hcc-btn:focus-visible {
    outline: 3px solid rgba(255,255,255,.7);
    outline-offset: 2px;
}

.hcc-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 22px rgba(0,0,0,.35);
}

.hcc-btn:active {
    transform: scale(.95);
}

/* Pulse ring */
.hcc-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--hcc-color, #128C7E);
    opacity: .35;
    animation: hcc-pulse 2.4s ease-out infinite;
    pointer-events: none;
}

#hcc-widget.hcc-open .hcc-btn::after {
    animation: none;
    opacity: 0;
}

@keyframes hcc-pulse {
    0%   { transform: scale(1);   opacity: .35; }
    70%  { transform: scale(1.55); opacity: 0;  }
    100% { transform: scale(1);   opacity: 0;  }
}

/* Toggle icons (open / close) */
.hcc-btn-ico {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .22s ease, transform .22s ease;
    will-change: opacity, transform;
}

.hcc-btn-ico svg { width: 26px; height: 26px; display: block; }

.hcc-ico-open  { opacity: 1; transform: rotate(0deg) scale(1); }
.hcc-ico-close { opacity: 0; transform: rotate(-90deg) scale(.7); }

#hcc-widget.hcc-open .hcc-ico-open  { opacity: 0; transform: rotate(90deg) scale(.7); }
#hcc-widget.hcc-open .hcc-ico-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* ── Popup ─────────────────────────────────────────────────────────── */
.hcc-popup {
    display: flex;
    flex-direction: column;
    gap: var(--hcc-gap, 12px);

    /* Hidden state */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity .28s ease,
        visibility 0s .28s;     /* delay visibility until fade-out done */
}

#hcc-widget.hcc-open .hcc-popup {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition:
        opacity .28s ease,
        visibility 0s 0s;
}

.hcc-channels {
    display: flex;
    flex-direction: column;
    gap: var(--hcc-gap, 12px);
}

/* ── Channel buttons ───────────────────────────────────────────────── */
.hcc-ch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 60px;
    background-color: var(--hcc-ch-bg, #128C7E);
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    direction: rtl;
    box-shadow: 0 3px 14px rgba(0,0,0,.22);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

.hcc-ch:hover,
.hcc-ch:focus-visible {
    color: #fff;
    text-decoration: none;
    filter: brightness(1.12);
    box-shadow: 0 5px 20px rgba(0,0,0,.32);
    outline: none;
}

.hcc-bottom-right .hcc-ch:hover { transform: translateX(-4px); }
.hcc-bottom-left  .hcc-ch:hover { transform: translateX( 4px); }

.hcc-ch:active { transform: scale(.96); }

.hcc-ch-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hcc-ch-icon svg,
.hcc-ch-icon img {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
}

.hcc-ch-label { line-height: 1; letter-spacing: 0; }

/* ── Entry animations ──────────────────────────────────────────────── */

/* slide-up */
.hcc-anim-slide-up .hcc-ch {
    transform: translateY(14px);
    opacity: 0;
    transition: transform .28s ease, opacity .28s ease;
}

#hcc-widget.hcc-open.hcc-anim-slide-up .hcc-ch {
    transform: translateY(0);
    opacity: 1;
}

/* fade */
.hcc-anim-fade .hcc-ch {
    opacity: 0;
    transition: opacity .3s ease;
}

#hcc-widget.hcc-open.hcc-anim-fade .hcc-ch {
    opacity: 1;
}

/* scale */
.hcc-anim-scale .hcc-ch {
    transform: scale(.6);
    opacity: 0;
    transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .28s ease;
}

#hcc-widget.hcc-open.hcc-anim-scale .hcc-ch {
    transform: scale(1);
    opacity: 1;
}

/* Stagger delays (applied in open state so exit has no delay) */
#hcc-widget.hcc-open .hcc-ch:nth-child(1) { transition-delay:  .00s; }
#hcc-widget.hcc-open .hcc-ch:nth-child(2) { transition-delay:  .05s; }
#hcc-widget.hcc-open .hcc-ch:nth-child(3) { transition-delay:  .10s; }
#hcc-widget.hcc-open .hcc-ch:nth-child(4) { transition-delay:  .15s; }
#hcc-widget.hcc-open .hcc-ch:nth-child(5) { transition-delay:  .20s; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .hcc-ch { font-size: 13px; padding: 9px 14px; }
}

/* ── Reduced motion ────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .hcc-btn,
    .hcc-btn::after,
    .hcc-btn-ico,
    .hcc-popup,
    .hcc-ch { animation: none !important; transition: none !important; }
}
