:root{--bg:#f5f7fb;--card:#fff;--text:#152238;--muted:#7a8799;--primary:#3157d5;--primary2:#203fa8;--border:#e6eaf1;--danger:#c83d4b}
*{box-sizing:border-box}body{margin:0;font-family:Tahoma,Arial,sans-serif;background:var(--bg);color:var(--text)}a{color:var(--primary)}
.hero{max-width:950px;margin:auto;padding:90px 24px;text-align:center}.brand{font-weight:900;font-size:30px}.brand span{color:var(--primary)}.brand.small{font-size:23px;margin:8px 0 30px}
.hero h1{font-size:52px;line-height:1.2;margin:40px 0 20px}.hero p{font-size:19px;color:var(--muted);max-width:660px;margin:auto}
.actions{display:flex;gap:12px;justify-content:center;margin:35px}.btn{display:inline-block;padding:13px 24px;border-radius:13px;text-decoration:none;border:1px solid var(--border);font-weight:700;background:#fff;cursor:pointer}.btn.primary{background:var(--primary);color:#fff;border-color:var(--primary)}.btn.ghost{color:var(--text)}.btn.full{width:100%;margin-top:12px}
.features{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-top:55px}.features div{background:#fff;border:1px solid var(--border);padding:22px;border-radius:18px}
.auth-wrap{min-height:100vh;display:grid;place-items:center;padding:20px}.card{background:#fff;border:1px solid var(--border);border-radius:20px;box-shadow:0 10px 35px #1a2b5010}.auth{width:min(430px,100%);padding:30px}.auth h2{margin-top:0}.auth label{display:block;margin:14px 0 7px;font-weight:700}.auth input,.search input,.composer input{width:100%;padding:13px 14px;border:1px solid var(--border);border-radius:12px;outline:none;background:#fbfcfe}.auth input:focus,.search input:focus,.composer input:focus{border-color:#9db0ef}.muted{color:var(--muted);font-size:13px}.error{background:#fff0f1;color:#a51f2d;padding:12px;border-radius:10px}
.app-shell{display:flex;min-height:100vh}.sidebar{width:250px;background:#111b31;color:#fff;padding:22px;position:fixed;right:0;top:0;bottom:0}.sidebar .muted{color:#a9b3c4}.me-card{display:flex;gap:12px;align-items:center;margin-bottom:25px}.avatar{width:42px;height:42px;border-radius:50%;display:grid;place-items:center;background:#e9edfb;color:var(--primary);font-weight:900;flex:0 0 auto}.sidebar .avatar{background:#2a3c68;color:#fff}.sidebar code{font-size:11px;color:#cad2e3}.nav{width:100%;text-align:right;padding:12px;border:0;border-radius:10px;background:transparent;color:#dbe2f1;cursor:pointer;margin:4px 0}.nav.active,.nav:hover{background:#1e2c4b}.nav.danger{color:#ffadb5}
.main{margin-right:250px;display:grid;grid-template-columns:380px 1fr;width:calc(100% - 250px);min-height:100vh}.left-pane{background:#fff;border-left:1px solid var(--border);padding:18px;overflow:auto}.top{display:flex;align-items:center;justify-content:space-between}.search{margin:14px 0}.section-title{font-size:13px;color:var(--muted);margin:22px 6px 8px}.person{display:flex;align-items:center;gap:10px;width:100%;padding:10px;border-radius:13px;border:0;background:transparent;text-align:right}.person:hover{background:#f6f8fc}.grow{flex:1}.contact{cursor:pointer;color:inherit}.mini{border:1px solid var(--border);background:#fff;border-radius:9px;padding:7px 10px;cursor:pointer}.mini.ok{background:#e9f8ef;color:#168044}.mini.danger{color:var(--danger)}.empty{padding:22px;text-align:center;color:var(--muted)}
.chat-pane{display:flex;min-width:0}.empty-chat{margin:auto;text-align:center;color:var(--muted)}.empty-chat:first-letter{font-size:50px}.chat{display:flex;flex-direction:column;width:100%;height:100vh}.hidden{display:none!important}.chat-head{padding:16px 20px;background:#fff;border-bottom:1px solid var(--border);display:flex;justify-content:space-between;align-items:center}.messages{flex:1;overflow:auto;padding:22px;display:flex;flex-direction:column;gap:9px;background:linear-gradient(#f7f9fd,#f2f5fb)}.bubble{max-width:70%;padding:10px 13px;border-radius:16px;box-shadow:0 2px 10px #26386008}.bubble.mine{align-self:flex-start;background:#3157d5;color:#fff;border-bottom-left-radius:4px}.bubble.theirs{align-self:flex-end;background:#fff;border:1px solid var(--border);border-bottom-right-radius:4px}.bubble small{display:block;font-size:10px;opacity:.7;margin-top:5px}.composer{display:flex;padding:14px;background:#fff;border-top:1px solid var(--border);gap:8px}.composer button{border:0;background:var(--primary);color:#fff;border-radius:11px;padding:0 20px;font-weight:700}
@media(max-width:800px){
 .hero{padding-top:55px}.hero h1{font-size:38px}.features{grid-template-columns:1fr 1fr}.sidebar{display:none}.main{margin:0;width:100%;grid-template-columns:1fr}.chat-pane{position:fixed;inset:0;background:#fff;z-index:5;pointer-events:none}.chat-pane .chat{pointer-events:auto}.empty-chat{display:none}.chat.hidden{display:none!important}.left-pane{border:0}.bubble{max-width:84%}
}

@media(max-width:800px){
  .chat-pane{
    display:none;
  }

  .chat-pane.mobile-open{
    display:flex;
    position:fixed;
    inset:0;
    z-index:50;
    background:#fff;
  }

  .chat-pane.mobile-open .chat{
    display:flex !important;
  }
}

/* ===== WESAL V2 composer / attachments / voice ===== */
.msg-text{white-space:pre-wrap;word-break:break-word}
.voice-player{width:250px;max-width:100%;height:42px}
.file-card{display:flex;gap:8px;align-items:center;color:inherit;text-decoration:none;border:1px solid #ffffff40;border-radius:10px;padding:9px;margin-top:4px}.theirs .file-card{border-color:#e6eaf1;background:#f7f9fc}
.recording-bar{display:flex;align-items:center;gap:9px;background:#fff4f5;border-top:1px solid #ffd9dd;padding:9px 12px;flex:0 0 auto}.recording-bar button{border:0;border-radius:8px;padding:8px 11px;background:#3157d5;color:#fff}.recording-bar .cancel{background:#fff;color:#c83d4b;border:1px solid #f0c9cd}.record-dot{width:10px;height:10px;border-radius:50%;background:#e32738;animation:wesal-pulse 1s infinite}@keyframes wesal-pulse{50%{opacity:.35}}
.icon-btn{border:0;background:#eef2fb;border-radius:50%;width:42px;height:42px;flex:0 0 42px;font-size:20px;cursor:pointer}.send-btn{border:0!important;background:#3157d5!important;color:#fff!important;border-radius:11px!important;padding:12px 15px!important}
.composer{align-items:center;position:relative;z-index:30}.composer #msgInput{color:#111!important;background:#fff!important;opacity:1!important;-webkit-text-fill-color:#111!important}.composer #msgInput::placeholder{color:#8b96a8!important;-webkit-text-fill-color:#8b96a8!important}
@media(max-width:800px){.chat{height:100dvh!important}.messages{min-height:0!important}.composer{position:sticky!important;bottom:0!important;padding-bottom:max(10px,env(safe-area-inset-bottom))!important;background:#fff!important}.composer #msgInput{font-size:16px!important;height:44px!important}.composer.recording-active{display:none!important}}

/* ===== MOBILE COMPOSER FIX V3 ===== */
@media (max-width:800px){

  html, body {
    height:100%;
    overflow:hidden;
  }

  .chat-pane.mobile-open {
    position:fixed !important;
    inset:0 !important;
    height:100% !important;
    min-height:100% !important;
    overflow:hidden !important;
    background:#fff !important;
  }

  .chat-pane.mobile-open .chat {
    display:flex !important;
    flex-direction:column !important;
    position:absolute !important;
    inset:0 !important;
    height:100% !important;
    min-height:0 !important;
  }

  .chat-head {
    flex:0 0 auto !important;
  }

  .messages {
    flex:1 1 auto !important;
    min-height:0 !important;
    overflow-y:auto !important;
    padding-bottom:95px !important;
  }

  .composer {
    position:absolute !important;
    right:0 !important;
    left:0 !important;
    bottom:0 !important;
    z-index:9999 !important;

    display:flex !important;
    align-items:center !important;
    gap:7px !important;

    min-height:68px !important;
    padding:9px 8px max(12px, env(safe-area-inset-bottom)) !important;

    background:#ffffff !important;
    border-top:1px solid #dfe4ec !important;
    box-shadow:0 -4px 18px rgba(0,0,0,.08) !important;
  }

  #msgInput {
    display:block !important;
    visibility:visible !important;
    opacity:1 !important;

    flex:1 1 auto !important;
    min-width:0 !important;
    height:46px !important;

    background:#f5f7fb !important;
    color:#111111 !important;
    -webkit-text-fill-color:#111111 !important;

    border:1px solid #cfd6e3 !important;
    border-radius:23px !important;

    padding:0 16px !important;
    font-size:16px !important;
    line-height:46px !important;
  }

  #msgInput::placeholder {
    color:#8792a3 !important;
    -webkit-text-fill-color:#8792a3 !important;
  }

  .icon-btn {
    display:flex !important;
    align-items:center !important;
    justify-content:center !important;
    width:44px !important;
    height:44px !important;
    flex:0 0 44px !important;
  }

  .send-btn {
    display:block !important;
    height:44px !important;
    padding:0 14px !important;
    flex:0 0 auto !important;
  }

}

/* ===== WESAL REAL MOBILE VIEWPORT FIX ===== */
@media (max-width:800px) {

  body {
    overflow:hidden !important;
  }

  .chat-pane.mobile-open {
    position:fixed !important;
    right:0 !important;
    left:0 !important;
    top:var(--wesal-vtop, 0px) !important;
    bottom:auto !important;

    width:100% !important;
    height:var(--wesal-vh, 100dvh) !important;
    max-height:var(--wesal-vh, 100dvh) !important;

    overflow:hidden !important;
    background:#fff !important;
  }

  .chat-pane.mobile-open .chat {
    position:relative !important;
    inset:auto !important;

    width:100% !important;
    height:100% !important;
    max-height:100% !important;

    display:flex !important;
    flex-direction:column !important;
    overflow:hidden !important;
  }

  .chat-head {
    position:relative !important;
    flex:0 0 auto !important;
  }

  .messages {
    position:relative !important;
    flex:1 1 0 !important;
    min-height:0 !important;
    overflow-y:auto !important;
    padding-bottom:12px !important;
  }

  .composer {
    position:relative !important;
    inset:auto !important;

    flex:0 0 64px !important;
    min-height:64px !important;

    width:100% !important;

    display:flex !important;
    visibility:visible !important;
    opacity:1 !important;

    background:#fff !important;
    z-index:99999 !important;

    padding:8px !important;
    border-top:1px solid #d7dce5 !important;
  }

  #msgInput {
    position:relative !important;
    display:block !important;
    visibility:visible !important;
    opacity:1 !important;

    height:46px !important;
    min-height:46px !important;
    flex:1 1 0 !important;

    color:#111 !important;
    background:#f4f6fa !important;
    -webkit-text-fill-color:#111 !important;

    font-size:16px !important;
    line-height:normal !important;
  }
}


/* ===== WESAL VOICE CALL UI ===== */

.wesal-call-overlay{
    position:fixed;
    inset:0;
    z-index:1000000;
    background:rgba(12,20,38,.72);

    display:flex;
    align-items:center;
    justify-content:center;

    padding:20px;
}

.wesal-call-overlay.hidden{
    display:none !important;
}

.wesal-call-card{
    width:min(390px,100%);
    background:white;
    border-radius:28px;

    padding:35px 22px;

    text-align:center;

    box-shadow:
        0 25px 70px
        rgba(0,0,0,.32);
}

.wesal-call-icon{
    width:88px;
    height:88px;

    display:grid;
    place-items:center;

    margin:0 auto 18px;

    border-radius:50%;

    background:#edf1ff;

    font-size:42px;
}

.wesal-call-card h2{
    margin:8px 0;
}

.wesal-call-status{
    margin-top:12px;
    color:#6f7b8e;
}

.wesal-call-duration{
    font-size:28px;
    font-weight:700;

    margin:22px 0;
}

.wesal-call-actions{
    display:flex;
    gap:12px;

    justify-content:center;

    margin-top:28px;
}

.wesal-call-actions button{
    border:0;

    min-width:110px;

    padding:14px 18px;

    border-radius:16px;

    font-size:17px;

    cursor:pointer;
}

.wesal-answer{
    background:#1caf61;
    color:white;
}

.wesal-reject,
.wesal-hangup{
    background:#db3448;
    color:white;
}

.wesal-call-control{
    background:#eef1f7;
    color:#1b2740;
}

.call-btn{
    color:#176b3a !important;
    font-weight:700;
}


/* WESAL BACKGROUND PUSH */
#wesalPushEnableBtn{
  position:fixed;top:10px;left:10px;z-index:999999;
  border:0;border-radius:12px;padding:9px 12px;
  background:#17213a;color:#fff;font-weight:700;
  box-shadow:0 6px 20px rgba(0,0,0,.18)
}
#wesalPushEnableBtn.enabled{background:#187a46}
#wesalPushEnableBtn.blocked{background:#a73743}
@media(max-width:800px){
  #wesalPushEnableBtn{font-size:12px;padding:7px 9px}
}
