/**
 * TapReach Frontend v2.4.0
 */

/* ═══ Root Container ═══ */
#tapreach-root{position:fixed;z-index:99999;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;-webkit-font-smoothing:antialiased;box-sizing:border-box}
#tapreach-root *,#tapreach-root *::before,#tapreach-root *::after{box-sizing:border-box}
#tapreach-root.tr-bottom-right{bottom:0;right:0}
#tapreach-root.tr-bottom-left{bottom:0;left:0}
#tapreach-root.tr-top-right{top:0;right:0}
#tapreach-root.tr-top-left{top:0;left:0}
body.admin-bar #tapreach-root.tr-top-right,body.admin-bar #tapreach-root.tr-top-left{top:32px}

/* ═══ FAB Button ═══ */
.tr-fab{width:60px;height:60px;border-radius:50%;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 20px rgba(0,0,0,.2);transition:transform .2s,box-shadow .2s;position:relative;outline:none;-webkit-tap-highlight-color:transparent}
.tr-fab:hover{transform:scale(1.08);box-shadow:0 6px 28px rgba(0,0,0,.25)}
.tr-fab:active{transform:scale(.95)}
.tr-fab.open .tr-fab-icon{transform:rotate(45deg)}
.tr-fab-icon{width:28px;height:28px;transition:transform .3s ease}
.tr-fab-icon svg{width:100%;height:100%;fill:currentColor}
.tr-fab.pulse::before{content:'';position:absolute;inset:-6px;border-radius:50%;background:inherit;opacity:.3;animation:trPulse 2s infinite}
@keyframes trPulse{0%,100%{transform:scale(1);opacity:.3}50%{transform:scale(1.25);opacity:0}}

/* ═══ Tooltip ═══ */
.tr-tooltip{position:absolute;padding:8px 14px;border-radius:8px;font-size:13px;font-weight:500;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .3s;box-shadow:0 4px 12px rgba(0,0,0,.15)}
.tr-tooltip.show{opacity:1}
.tr-fab:hover .tr-tooltip{opacity:1}
.tr-bottom-right .tr-tooltip,.tr-top-right .tr-tooltip{right:calc(100% + 12px);top:50%;transform:translateY(-50%)}
.tr-bottom-left .tr-tooltip,.tr-top-left .tr-tooltip{left:calc(100% + 12px);top:50%;transform:translateY(-50%)}

/* ═══ Greeting Bubble — speech bubble above/below FAB ═══ */
.tr-greeting{position:absolute;padding:10px 16px;border-radius:16px;font-size:14px;font-weight:500;box-shadow:0 8px 30px rgba(0,0,0,.15);cursor:pointer;line-height:1.3;display:none;flex-direction:row;align-items:center;gap:8px;white-space:normal;max-width:280px;z-index:1}
.tr-greeting-text{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical}
/* Arrow pointing down toward FAB (bottom positions: bubble above) */
.tr-greeting::after{content:'';position:absolute;width:0;height:0;border-style:solid;border-color:transparent}
.tr-bottom-right .tr-greeting,.tr-bottom-left .tr-greeting{bottom:calc(100% + 12px);animation:trGreetInUp .4s ease}
.tr-bottom-right .tr-greeting{right:0}
.tr-bottom-left .tr-greeting{left:0}
.tr-bottom-right .tr-greeting::after,.tr-bottom-left .tr-greeting::after{bottom:-8px;border-width:8px 8px 0 8px;border-top-color:var(--tr-greet-bg,#1e293b)}
.tr-bottom-right .tr-greeting::after{right:16px}
.tr-bottom-left .tr-greeting::after{left:16px}
/* Arrow pointing up toward FAB (top positions: bubble below) */
.tr-top-right .tr-greeting,.tr-top-left .tr-greeting{top:calc(100% + 12px);animation:trGreetInDown .4s ease}
.tr-top-right .tr-greeting{right:0}
.tr-top-left .tr-greeting{left:0}
.tr-top-right .tr-greeting::after,.tr-top-left .tr-greeting::after{top:-8px;border-width:0 8px 8px 8px;border-bottom-color:var(--tr-greet-bg,#1e293b)}
.tr-top-right .tr-greeting::after{right:16px}
.tr-top-left .tr-greeting::after{left:16px}
@keyframes trGreetInUp{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
@keyframes trGreetInDown{from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:none}}
.tr-greeting-close{flex-shrink:0;width:20px;height:20px;display:flex;align-items:center;justify-content:center;font-size:14px;opacity:.6;cursor:pointer;background:rgba(255,255,255,.15);border:none;color:inherit;border-radius:50%;line-height:1;-webkit-tap-highlight-color:transparent;padding:0}.tr-greeting-close:hover{opacity:1;background:rgba(255,255,255,.25)}

/* ═══ Panel ═══ */
.tr-panel{position:absolute;background:#fff;border-radius:16px;box-shadow:0 12px 50px rgba(0,0,0,.18);overflow:hidden;opacity:0;transform:scale(.9) translateY(10px);transition:opacity .3s ease,transform .3s ease;pointer-events:none;width:340px}
.tr-panel.open{opacity:1;transform:scale(1) translateY(0);pointer-events:auto}
/* Detach panel from scrollbar edge — use negative calc to push it inward */
.tr-bottom-right .tr-panel{bottom:calc(100% + 14px);right:4px}
.tr-bottom-left .tr-panel{bottom:calc(100% + 14px);left:4px}
.tr-top-right .tr-panel{top:calc(100% + 14px);right:4px}
.tr-top-left .tr-panel{top:calc(100% + 14px);left:4px}

/* ═══ Panel Header ═══ */
.tr-panel-header{padding:20px 24px 16px;position:relative}
.tr-panel-title{font-size:18px;font-weight:700;margin:0 0 4px;line-height:1.3}
.tr-panel-subtitle{font-size:13px;opacity:.55;margin:0}
.tr-panel-close{position:absolute;top:14px;right:14px;width:28px;height:28px;border-radius:50%;border:none;background:rgba(0,0,0,.06);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:16px;color:inherit;transition:background .2s;-webkit-tap-highlight-color:transparent}.tr-panel-close:hover{background:rgba(0,0,0,.12)}
.tr-panel-offline{padding:10px 24px;font-size:13px;opacity:.7;font-style:italic}

/* ═══ Channels ═══ */
.tr-channels{padding:0 16px 16px;display:flex;flex-direction:column;gap:4px;max-height:320px;overflow-y:auto}
.tr-channel{display:flex;align-items:center;gap:14px;padding:12px 16px;border-radius:12px;text-decoration:none;color:inherit;transition:background .2s,transform .15s;cursor:pointer;-webkit-tap-highlight-color:transparent}
.tr-channel:hover{background:rgba(0,0,0,.04);transform:translateX(3px)}
.tr-channel:active{background:rgba(0,0,0,.06);transform:scale(.98)}
.tr-channel-icon{width:40px;height:40px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:#fff;flex-shrink:0;box-shadow:0 2px 8px rgba(0,0,0,.1);position:relative}
.tr-channel-icon svg{width:20px;height:20px}
.tr-channel-badge{position:absolute;bottom:-2px;right:-2px;width:16px;height:16px;border-radius:50%;background:rgba(0,0,0,.55);color:#fff;font-size:9px;font-weight:700;display:flex;align-items:center;justify-content:center;line-height:1;border:1.5px solid #fff}
.tr-channel-text{flex:1;min-width:0;overflow:hidden}
.tr-channel-label{font-size:14px;font-weight:600;display:block;line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tr-channel-sub{font-size:11px;opacity:.5;display:block;margin-top:1px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:inherit;letter-spacing:.2px;font-weight:400}
.tr-channel-arrow{opacity:.25;flex-shrink:0;display:flex;align-items:center;transition:opacity .2s}
.tr-channel-arrow svg{width:16px;height:16px}
.tr-channel:hover .tr-channel-arrow{opacity:.6}

/* ═══ Panel Avatar ═══ */
.tr-panel-avatar{position:absolute;top:16px;right:50px;width:44px;height:44px;border-radius:50%;object-fit:cover;border:2px solid #22c55e;box-shadow:0 2px 8px rgba(0,0,0,.1)}

/* ═══ Panel Footer (Branding) ═══ */
.tr-panel-footer{padding:8px 16px;text-align:center;border-top:1px solid rgba(0,0,0,.06);font-size:10px}
.tr-panel-footer a{color:inherit;opacity:.4;text-decoration:none;font-weight:400;transition:opacity .2s}
.tr-panel-footer a:hover{opacity:.65}
.tr-panel-footer a strong{font-weight:600}

/* ═══ Tablet ═══ */
@media(max-width:768px){
    .tr-greeting{max-width:240px}
}

/* ═══ Mobile ═══ */
@media(max-width:600px){
    #tapreach-root{padding:14px!important}
    .tr-fab{width:54px!important;height:54px!important}
    .tr-fab-icon{width:24px;height:24px}

    .tr-panel{
        position:fixed!important;
        left:12px!important;
        right:12px!important;
        width:auto!important;
        max-width:none!important;
        border-radius:16px;
        overflow:hidden;
        display:flex;
        flex-direction:column;
    }
    .tr-bottom-right .tr-panel,
    .tr-bottom-left .tr-panel{
        bottom:78px!important;
        top:auto!important;
        max-height:calc(100vh - 100px);
        max-height:calc(100dvh - 100px);
    }
    .tr-top-right .tr-panel,
    .tr-top-left .tr-panel{
        top:78px!important;
        bottom:auto!important;
        max-height:calc(100vh - 100px);
        max-height:calc(100dvh - 100px);
    }
    body.admin-bar .tr-top-right .tr-panel,
    body.admin-bar .tr-top-left .tr-panel{
        top:110px!important;
    }
    .tr-panel-header{padding:16px 18px 10px}
    .tr-panel-title{font-size:16px}
    .tr-panel-close{top:12px;right:12px;width:32px;height:32px;font-size:18px}
    .tr-channels{
        padding:0 10px 10px;
        gap:2px;
        max-height:none;
        overflow-y:auto;
        flex:1;
        -webkit-overflow-scrolling:touch;
    }
    .tr-channel{padding:10px 12px;gap:10px;border-radius:10px;min-height:44px}
    .tr-channel:hover{transform:none}
    .tr-channel-icon{width:36px;height:36px}
    .tr-channel-icon svg{width:18px;height:18px}
    .tr-channel-label{font-size:13px}
    .tr-channel-arrow{display:none}
    .tr-panel-avatar{width:36px;height:36px;top:12px;right:48px}
    .tr-tooltip{display:none!important}
    .tr-greeting{
        max-width:min(220px,calc(100vw - 100px));
        font-size:13px;
        padding:8px 12px;
        border-radius:14px;
        gap:6px;
    }
    .tr-bottom-right .tr-greeting,.tr-bottom-left .tr-greeting{bottom:calc(100% + 10px)}
    .tr-top-right .tr-greeting,.tr-top-left .tr-greeting{top:calc(100% + 10px)}
}

/* ═══ Contact Form ═══ */
.tr-contact-form{padding:12px 16px 16px;display:flex;flex-direction:column;gap:10px}
.tr-form-input{width:100%;padding:10px 14px;border:1px solid rgba(0,0,0,.12);border-radius:10px;font-size:14px;font-family:inherit;background:rgba(0,0,0,.02);transition:border-color .2s,box-shadow .2s;outline:none;resize:none}
.tr-form-input:focus{border-color:rgba(99,102,241,.5);box-shadow:0 0 0 3px rgba(99,102,241,.1)}
.tr-form-textarea{min-height:70px}
.tr-form-submit{width:100%;padding:12px;border:none;border-radius:10px;font-size:14px;font-weight:600;font-family:inherit;cursor:pointer;transition:opacity .2s,transform .15s}
.tr-form-submit:hover{opacity:.9}
.tr-form-submit:active{transform:scale(.98)}
.tr-form-submit:disabled{opacity:.6;cursor:not-allowed}
.tr-form-status{font-size:13px;text-align:center;min-height:18px}
.tr-form-back{position:absolute;top:14px;left:14px;width:28px;height:28px;border-radius:50%;border:none;background:rgba(0,0,0,.06);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:16px;color:inherit;transition:background .2s;-webkit-tap-highlight-color:transparent;padding:0}.tr-form-back:hover{background:rgba(0,0,0,.12)}

/* ═══ Very Small Screens ═══ */
@media(max-width:380px){
    #tapreach-root{padding:10px!important}
    .tr-fab{width:48px!important;height:48px!important}
    .tr-fab-icon{width:22px;height:22px}
    .tr-panel{left:8px!important;right:8px!important;border-radius:14px}
    .tr-panel-header{padding:14px 16px 8px}
    .tr-panel-title{font-size:15px}
    .tr-channel{padding:8px 10px;gap:8px}
    .tr-channel-icon{width:32px;height:32px}
    .tr-channel-icon svg{width:16px;height:16px}
    .tr-channel-label{font-size:12px}
    .tr-greeting{max-width:170px;font-size:12px;padding:6px 10px;border-radius:12px}
}
