/* =========================================================
   RABBIT CALL RESPONSIVE V7
   Pulito e leggero:
   - niente swipe down
   - X floating chat
   - videocall/call mobile realmente bilanciata
   ========================================================= */

:root{
  --r7-safe-top: env(safe-area-inset-top, 0px);
  --r7-safe-bottom: env(safe-area-inset-bottom, 0px);
  --r7-dark: #020617;
  --r7-panel: #0b1224;
  --r7-line: rgba(148,163,184,.18);
  --r7-z: 2147482800;
}

#rc22CloseMobile{
  display:none;
}

@media (max-width:768px){

  /* =======================================================
     FLOATING CHAT: SOLO X, NO SWIPE
     ======================================================= */

  #rc22Panel.open{
    transition:none !important;
  }

  #rc22Panel.rc22-dragging,
  #rc22Panel.rc22-closing{
    transform:none !important;
    opacity:1 !important;
  }

  #rc22CloseMobile{
    display:grid !important;
    position:absolute !important;
    top:12px !important;
    right:12px !important;
    width:46px !important;
    height:46px !important;
    border-radius:17px !important;
    border:1px solid #dbe5f2 !important;
    background:#fff !important;
    color:#0f172a !important;
    place-items:center !important;
    font-size:22px !important;
    font-weight:950 !important;
    z-index:40 !important;
    box-shadow:0 10px 26px rgba(15,23,42,.10) !important;
    cursor:pointer !important;
  }

  #rc22Panel.open .rc22-thread-head{
    position:relative !important;
    padding-right:72px !important;
  }

  #rc22Panel.open .rc22-swipe-handle{
    display:none !important;
  }

  /* =======================================================
     CALL / VIDEO CALL MOBILE
     ======================================================= */

  html.rc22-mobile-call-open,
  body.rc22-mobile-call-open{
    overflow:hidden !important;
    height:100% !important;
    background:var(--r7-dark) !important;
  }

  /*
    Root call: 3 aree vere.
    Header: piccolo.
    Body: video + chat live.
    Controls: fissi in basso.
  */
  #rc22Call.show{
    position:fixed !important;
    inset:0 !important;
    width:100vw !important;
    height:100dvh !important;
    max-width:none !important;
    max-height:none !important;
    z-index:var(--r7-z) !important;
    display:grid !important;
    grid-template-rows:auto minmax(0,1fr) auto !important;
    overflow:hidden !important;
    background:var(--r7-dark) !important;
    color:#fff !important;
  }

  #rc22Call.show .rc22-call-head{
    min-height:calc(74px + var(--r7-safe-top)) !important;
    padding:calc(9px + var(--r7-safe-top)) 12px 9px !important;
    display:grid !important;
    grid-template-columns:minmax(0,1fr) 50px !important;
    align-items:center !important;
    gap:10px !important;
    background:var(--r7-panel) !important;
    border-bottom:1px solid var(--r7-line) !important;
  }

  #rc22Call.show .rc22-call-title{
    min-width:0 !important;
    overflow:hidden !important;
  }

  #rc22Call.show .rc22-call-title b{
    display:block !important;
    max-width:100% !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
    white-space:nowrap !important;
    font-size:19px !important;
    line-height:1.08 !important;
    letter-spacing:-.035em !important;
    color:#fff !important;
  }

  #rc22Call.show .rc22-call-title small{
    display:block !important;
    margin-top:4px !important;
    max-width:100% !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
    white-space:nowrap !important;
    font-size:14px !important;
    line-height:1.18 !important;
    font-weight:900 !important;
    color:#9df0bd !important;
  }

  #rc22Call.show #rc22CallX{
    width:50px !important;
    height:50px !important;
    min-width:50px !important;
    border-radius:18px !important;
    padding:0 !important;
    font-size:22px !important;
    display:grid !important;
    place-items:center !important;
    justify-self:end !important;
  }

  /*
    Body: la chat live è parte del layout, non laterale, non nascosta.
    Usiamo minmax/clamp per adattarci a Safari mobile e Chrome mobile.
  */
  #rc22Call.show .rc22-call-body{
    min-height:0 !important;
    height:100% !important;
    width:100% !important;
    display:grid !important;
    grid-template-columns:1fr !important;
    grid-template-rows:minmax(0, 1fr) clamp(176px, 30dvh, 240px) !important;
    gap:8px !important;
    padding:8px 8px 6px !important;
    overflow:hidden !important;
    background:var(--r7-dark) !important;
  }

  /*
    Video stage: object-fit contain per vedere tutta l'immagine.
    Se vuoi effetto pieno cinema si usa cover, ma tu ora vuoi vederla tutta.
  */
  #rc22Call.show .rc22-stage{
    position:relative !important;
    min-height:0 !important;
    height:100% !important;
    width:100% !important;
    border-radius:22px !important;
    overflow:hidden !important;
    background:#050a18 !important;
    border:1px solid var(--r7-line) !important;
    display:grid !important;
    place-items:center !important;
  }

  #rc22Call.show #rc22Remote,
  #rc22Call.show .rc22-stage > video,
  #rc22Call.show video#rc22Remote{
    width:100% !important;
    height:100% !important;
    max-width:100% !important;
    max-height:100% !important;
    object-fit:contain !important;
    object-position:center center !important;
    background:#050a18 !important;
    border-radius:22px !important;
  }

  #rc22Call.show .rc22-placeholder{
    position:absolute !important;
    inset:0 !important;
    display:grid !important;
    place-items:center !important;
    text-align:center !important;
    padding:18px !important;
    color:rgba(226,232,240,.86) !important;
    font-size:16px !important;
    font-weight:850 !important;
    line-height:1.36 !important;
    overflow:hidden !important;
  }

  /*
    Local preview piccola, non copre chat e non invade controlli.
  */
  #rc22Call.show .rc22-local{
    position:absolute !important;
    right:12px !important;
    bottom:12px !important;
    width:96px !important;
    height:128px !important;
    border-radius:20px !important;
    overflow:hidden !important;
    border:2px solid rgba(255,255,255,.24) !important;
    background:#020617 !important;
    z-index:5 !important;
    box-shadow:0 14px 42px rgba(0,0,0,.38) !important;
  }

  #rc22Call.show .rc22-local video{
    width:100% !important;
    height:100% !important;
    object-fit:cover !important;
  }

  /*
    Chat live: forzata visibile e dimensionata.
  */
  #rc22Call.show .rc22-live{
    display:grid !important;
    visibility:visible !important;
    opacity:1 !important;
    grid-template-rows:auto minmax(0,1fr) auto !important;
    min-height:0 !important;
    height:100% !important;
    width:100% !important;
    overflow:hidden !important;
    border-radius:22px !important;
    background:#fff !important;
    color:#0f172a !important;
    border:1px solid rgba(226,232,240,.94) !important;
    box-shadow:0 -8px 26px rgba(0,0,0,.15) !important;
  }

  #rc22Call.show .rc22-live-head{
    min-height:38px !important;
    padding:8px 12px !important;
    display:flex !important;
    align-items:center !important;
    justify-content:space-between !important;
    gap:8px !important;
    border-bottom:1px solid #e2e8f0 !important;
    background:#fff !important;
    color:#0f172a !important;
    font-size:14px !important;
    font-weight:950 !important;
  }

  #rc22Call.show .rc22-live-head small{
    color:#64748b !important;
    font-size:11px !important;
    font-weight:800 !important;
    white-space:nowrap !important;
  }

  #rc22Call.show #rc22LiveList,
  #rc22Call.show .rc22-live-list{
    min-height:0 !important;
    height:100% !important;
    overflow-y:auto !important;
    overflow-x:hidden !important;
    padding:8px 10px !important;
    background:#f8fbff !important;
    display:flex !important;
    flex-direction:column !important;
    gap:7px !important;
    -webkit-overflow-scrolling:touch !important;
  }

  #rc22Call.show .rc22-live-msg,
  #rc22Call.show #rc22LiveList .rc22-empty{
    max-width:90% !important;
    width:max-content !important;
    padding:8px 10px !important;
    border-radius:14px !important;
    background:#fff !important;
    border:1px solid #e2e8f0 !important;
    color:#0f172a !important;
    font-size:14px !important;
    line-height:1.3 !important;
    word-break:break-word !important;
    overflow-wrap:anywhere !important;
  }

  #rc22Call.show .rc22-live-msg.me{
    align-self:flex-end !important;
    background:#2563eb !important;
    border-color:#2563eb !important;
    color:#fff !important;
  }

  #rc22Call.show #rc22LiveForm{
    min-height:52px !important;
    display:grid !important;
    grid-template-columns:minmax(0,1fr) 56px !important;
    align-items:center !important;
    gap:8px !important;
    padding:7px 9px !important;
    border-top:1px solid #e2e8f0 !important;
    background:#fff !important;
  }

  #rc22Call.show #rc22LiveInput{
    min-width:0 !important;
    width:100% !important;
    height:40px !important;
    border-radius:14px !important;
    padding:0 11px !important;
    font-size:16px !important;
    border:1px solid #cbd5e1 !important;
    background:#fff !important;
  }

  #rc22Call.show #rc22LiveForm button{
    width:56px !important;
    height:40px !important;
    border-radius:14px !important;
    padding:0 !important;
    font-size:13px !important;
    font-weight:950 !important;
  }

  /*
    Controlli: sempre visibili, anche con browser bottom bar.
  */
  #rc22Call.show .rc22-call-controls{
    min-height:calc(76px + var(--r7-safe-bottom)) !important;
    padding:9px 8px calc(9px + var(--r7-safe-bottom)) !important;
    display:grid !important;
    grid-template-columns:1fr 1fr 1fr !important;
    align-items:center !important;
    gap:8px !important;
    background:var(--r7-panel) !important;
    border-top:1px solid var(--r7-line) !important;
  }

  #rc22Call.show .rc22-call-controls button{
    min-width:0 !important;
    width:100% !important;
    height:54px !important;
    border-radius:18px !important;
    padding:0 6px !important;
    font-size:15px !important;
    font-weight:950 !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
    white-space:nowrap !important;
  }
}

/*
  Schermi molto bassi: priorità a video + controlli, chat più compatta ma presente.
*/
@media (max-width:768px) and (max-height:720px){
  #rc22Call.show .rc22-call-head{
    min-height:calc(64px + var(--r7-safe-top)) !important;
  }

  #rc22Call.show .rc22-call-title b{
    font-size:17px !important;
  }

  #rc22Call.show .rc22-call-title small{
    font-size:12px !important;
  }

  #rc22Call.show .rc22-call-body{
    grid-template-rows:minmax(0, 1fr) clamp(142px, 25dvh, 190px) !important;
    gap:6px !important;
    padding:6px !important;
  }

  #rc22Call.show .rc22-live-head{
    min-height:32px !important;
    padding:6px 10px !important;
  }

  #rc22Call.show #rc22LiveForm{
    min-height:46px !important;
    padding:5px 8px !important;
  }

  #rc22Call.show #rc22LiveInput,
  #rc22Call.show #rc22LiveForm button{
    height:36px !important;
  }

  #rc22Call.show .rc22-call-controls{
    min-height:calc(66px + var(--r7-safe-bottom)) !important;
    padding-top:7px !important;
    padding-bottom:calc(7px + var(--r7-safe-bottom)) !important;
  }

  #rc22Call.show .rc22-call-controls button{
    height:50px !important;
  }

  #rc22Call.show .rc22-local{
    width:84px !important;
    height:112px !important;
  }
}

@media (max-width:390px){
  #rc22Call.show .rc22-call-body{
    grid-template-rows:minmax(0, 1fr) clamp(158px, 28dvh, 215px) !important;
  }

  #rc22Call.show .rc22-call-controls{
    gap:6px !important;
  }

  #rc22Call.show .rc22-call-controls button{
    font-size:14px !important;
  }
}
