*{box-sizing:border-box}

:root{
  font-family:'Segoe UI',Roboto,Arial,sans-serif;
  color:#183153;
  background:#eef4fb;
}

html,body{
  margin:0;
  padding:0;
  width:100%;
}

body{
  min-height:100vh;
  background:
    radial-gradient(circle at 10% 0%,rgba(20,119,248,.12),transparent 30%),
    linear-gradient(180deg,#eaf3ff,#f7fbff);
}

button,input,textarea{font:inherit}
button{cursor:pointer}
button:disabled{opacity:.55;cursor:not-allowed}
.hidden{display:none!important}

/* APP */
.app-shell{
  width:100%;
  max-width:760px;
  min-height:100vh;
  margin:0 auto;
  background:#fff;
  box-shadow:0 0 30px rgba(18,62,120,.10);
}

/* HEADER */
.topbar{
  position:sticky;
  top:0;
  z-index:40;
  padding:13px 15px;
  background:linear-gradient(135deg,#1477f8,#084bc3);
  color:#fff;
  box-shadow:0 5px 18px rgba(8,75,195,.18);
}

.brand{display:flex;align-items:center;gap:10px}

.brand-icon{
  width:42px;
  height:42px;
  flex:0 0 42px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:50%;
  background:#fff;
  color:#0b5ed7;
  font-size:1.25rem;
}

.topbar strong{display:block;font-size:1.03rem}
.topbar small{display:block;margin-top:3px;opacity:.92}

.dot{
  display:inline-block;
  width:9px;
  height:9px;
  margin-right:5px;
  border-radius:50%;
  background:#35e57e;
}

/* MAIN */
main{padding:14px}

/* START CARD */
.start-card{
  max-width:440px;
  margin:7vh auto 0;
  padding:23px;
  border:1px solid #dce8f7;
  border-radius:20px;
  background:#fff;
  box-shadow:0 12px 35px rgba(30,85,150,.11);
}

.welcome-icon{text-align:center;font-size:2.4rem}
.start-card h1{text-align:center;margin:4px 0 7px}
.start-card p{text-align:center;color:#657890;line-height:1.45}
.start-card label{display:block;margin:18px 0 6px;font-size:.9rem;font-weight:800}

.start-card input{
  width:100%;
  height:52px;
  padding:0 13px;
  border:1px solid #cbdcf1;
  border-radius:12px;
  outline:none;
  font-size:1rem;
}

.start-card input:focus{
  border-color:#1477f8;
  box-shadow:0 0 0 4px rgba(20,119,248,.10);
}

.start-card button{
  width:100%;
  height:52px;
  margin-top:11px;
  border:0;
  border-radius:12px;
  background:linear-gradient(135deg,#1477f8,#084bc3);
  color:#fff;
  font-size:1rem;
  font-weight:900;
  box-shadow:0 8px 18px rgba(11,94,215,.19);
}

.free-badge{
  width:max-content;
  max-width:100%;
  margin:15px auto 0;
  padding:7px 10px;
  border:1px solid #bce8cf;
  border-radius:999px;
  background:#ecfff4;
  color:#08753c;
  font-size:.72rem;
  font-weight:900;
  text-align:center;
}

.privacy-note{margin-bottom:0;font-size:.75rem!important}

/* CHAT */
.chat-card{
  display:flex;
  flex-direction:column;
  min-height:0;
}

.chat-notice{
  flex:0 0 auto;
  padding:8px 10px;
  margin-bottom:6px;
  border:1px solid #f1d682;
  border-radius:10px;
  background:#fff8df;
  color:#795900;
  font-size:.78rem;
  font-weight:700;
  text-align:center;
}

/* MESSAGES */
.messages{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:8px 2px 12px;
  scroll-behavior:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}

.system-message{
  width:max-content;
  max-width:90%;
  margin:5px auto 14px;
  padding:7px 10px;
  border-radius:10px;
  background:#eef3f8;
  color:#718096;
  font-size:.70rem;
  text-align:center;
}

.msg-row{
  display:flex;
  margin:6px 0;
  height:auto;
  min-height:0;
}

.msg-row.mine{justify-content:flex-end}
.msg-row.theirs{justify-content:flex-start}

/* BUBBLES */
.bubble{
  width:auto;
  height:auto;
  min-height:0;
  max-width:82%;
  padding:8px 10px;
  border-radius:13px;
  background:#edf3fb;
  line-height:1.28;
  white-space:normal;
  word-break:break-word;
  box-shadow:0 3px 9px rgba(22,56,100,.05);
}

.bubble>div.message-text{
  white-space:pre-wrap;
  word-break:break-word;
  font-size:.92rem;
}

.mine .bubble{
  background:#dcebff;
  border-bottom-right-radius:5px;
}

.theirs .bubble{
  background:#effbf4;
  border-bottom-left-radius:5px;
}

.sender-label{
  display:block;
  margin:0 0 3px;
  color:#22568f;
  font-size:.68rem;
  line-height:1.15;
}

.theirs .sender-label{color:#147041}

.bubble small{
  display:block;
  margin-top:4px;
  font-size:.60rem;
  line-height:1.15;
  opacity:.62;
  text-align:right;
}

/* REPLY QUOTE */
.reply-quote{
  display:block;
  margin:0 0 6px;
  padding:6px 8px;
  border-left:3px solid #1477f8;
  border-radius:7px;
  background:rgba(255,255,255,.72);
  font-size:.72rem;
  line-height:1.22;
}

.reply-quote strong{
  display:block;
  margin-bottom:2px;
  color:#0b5ed7;
  font-size:.68rem;
}

.reply-quote span{
  display:-webkit-box;
  -webkit-box-orient:vertical;
  -webkit-line-clamp:2;
  overflow:hidden;
  color:#52667f;
  word-break:break-word;
}

.reply-action{
  -webkit-appearance:none;
  appearance:none;
  display:inline-flex;
  align-items:center;
  gap:3px;
  margin-top:5px;
  padding:3px 6px;
  border:0;
  border-radius:7px;
  background:rgba(255,255,255,.70);
  color:#42648c;
  font-size:.64rem;
  line-height:1;
  font-weight:800;
}

.reply-action:active{transform:scale(.98)}

/* COMPOSER */
.composer{
  flex:0 0 auto;
  display:grid;
  grid-template-columns:minmax(0,1fr) 50px;
  gap:7px;
  padding:8px 0 calc(6px + env(safe-area-inset-bottom));
  border-top:1px solid #edf2f8;
  background:#fff;
}

.reply-preview{
  grid-column:1/-1;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:9px;
  padding:6px 8px;
  border-left:3px solid #1477f8;
  border-radius:8px;
  background:#eef5ff;
}

.reply-preview-copy{min-width:0}

.reply-preview-copy strong{
  display:block;
  color:#0b5ed7;
  font-size:.70rem;
}

.reply-preview-copy span{
  display:block;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#52667f;
  font-size:.72rem;
}

.reply-preview button{
  flex:0 0 auto;
  width:26px;
  height:26px;
  padding:0;
  border:0;
  border-radius:50%;
  background:#fff;
  color:#60758f;
  font-weight:900;
}

.composer textarea{
  width:100%;
  min-width:0;
  min-height:44px;
  height:44px;
  max-height:110px;
  padding:10px 11px;
  resize:none;
  border:1px solid #cad9ed;
  border-radius:14px;
  outline:none;
  font-size:.90rem;
}

.composer textarea:focus{
  border-color:#1477f8;
  box-shadow:0 0 0 3px rgba(20,119,248,.08);
}

.composer>button[type="submit"]{
  width:50px;
  height:44px;
  padding:0;
  border:0;
  border-radius:14px;
  background:#0b5ed7;
  color:#fff;
  font-size:1.12rem;
  font-weight:900;
}

/* =========================================================
   ACTIVE CHAT VIEW
========================================================= */

body.chat-page{
  overflow:hidden;
}

body.chat-page .topbar,
body.chat-page .info{
  flex:0 0 auto;
}

body.chat-page main{
  flex:1 1 auto;
  min-height:0;
  overflow:hidden;
}

body.chat-page .chat-card{
  height:100%;
  min-height:0;
  overflow:hidden;
}

/* =========================================================
   MOBILE
   Gunakan fixed viewport supaya composer selalu terlihat.
========================================================= */

@media (max-width:699px){

  html,
  body.chat-page{
    width:100%;
    height:100%;
    overflow:hidden;
  }

  body.chat-page .app-shell{
    position:fixed;
    inset:0;
    width:100%;
    max-width:none;
    height:auto;
    min-height:0;
    margin:0;
    display:flex;
    flex-direction:column;
    overflow:hidden;
    box-shadow:none;
    background:#fff;
  }

  body.chat-page .topbar{
    position:relative;
    z-index:20;
    padding:11px 12px;
  }

  body.chat-page .info{
    max-height:150px;
    overflow:auto;
  }

  body.chat-page main{
    display:flex;
    flex-direction:column;
    padding:8px 10px 0;
  }

  body.chat-page .chat-card{
    flex:1 1 auto;
    display:flex;
    flex-direction:column;
  }

  body.chat-page .messages{
    flex:1 1 0;
    min-height:0;
    padding:6px 2px 8px;
  }

  body.chat-page .composer{
    flex:0 0 auto;
    margin:0 -2px;
    padding:
      7px
      2px
      calc(7px + env(safe-area-inset-bottom));
    background:#fff;
    box-shadow:0 -4px 12px rgba(28,65,115,.08);
  }

  .start-card{
    margin-top:3vh;
    padding:18px;
  }

  .bubble{
    max-width:86%;
    padding:8px 10px;
  }

  .bubble>div.message-text{
    font-size:.90rem;
  }

  .reply-action{
    font-size:.62rem;
  }
}

/* =========================================================
   DESKTOP / LAPTOP
========================================================= */

@media (min-width:700px){

  body.chat-page{
    min-height:100vh;
    padding:20px;
    display:flex;
    align-items:center;
    justify-content:center;
  }

  body.chat-page .app-shell{
    position:static;
    width:100%;
    max-width:420px;
    height:min(620px,calc(100dvh - 40px));
    min-height:0;
    display:flex;
    flex-direction:column;
    overflow:hidden;
    border-radius:18px;
    box-shadow:0 15px 45px rgba(18,62,120,.16);
  }

  body.chat-page .topbar{
    position:relative;
    padding:9px 11px;
  }

  body.chat-page main{
    display:flex;
    flex-direction:column;
    padding:8px 10px;
  }

  body.chat-page .chat-card{
    flex:1 1 auto;
    display:flex;
    flex-direction:column;
  }

  .chat-notice{
    padding:6px 8px;
    margin-bottom:4px;
    font-size:.70rem;
  }

  .messages{
    padding:5px 2px 8px;
  }

  .msg-row{
    margin:5px 0;
  }

  .bubble{
    max-width:74%;
    padding:7px 9px;
    border-radius:11px;
  }

  .bubble>div.message-text{
    font-size:.78rem;
    line-height:1.25;
  }

  .sender-label{
    font-size:.60rem;
  }

  .bubble small{
    font-size:.54rem;
  }

  .reply-quote{
    padding:5px 7px;
    margin-bottom:5px;
    font-size:.64rem;
  }

  .reply-quote strong{
    font-size:.60rem;
  }

  .reply-action{
    margin-top:4px;
    padding:2px 5px;
    font-size:.56rem;
    opacity:.55;
    transition:.15s ease;
  }

  .bubble:hover .reply-action,
  .reply-action:focus{
    opacity:1;
  }

  .composer{
    grid-template-columns:minmax(0,1fr) 46px;
    gap:6px;
    padding:7px 0 3px;
  }

  .composer textarea{
    min-height:40px;
    height:40px;
    padding:9px 10px;
    font-size:.78rem;
  }

  .composer>button[type="submit"]{
    width:46px;
    height:40px;
    border-radius:12px;
    font-size:1rem;
  }

  .reply-preview{
    padding:5px 7px;
  }

  .reply-preview-copy strong{
    font-size:.62rem;
  }

  .reply-preview-copy span{
    font-size:.64rem;
  }
}


/* =========================================================
   FOTO / SELFIE V6
========================================================= */

/* Hanya composer pelanggan yang mendapat kolom tombol kamera.
   Composer admin tetap 2 kolom seperti V5. */
.customer-chat .composer{
  grid-template-columns:44px minmax(0,1fr) 50px;
}

.photo-button{
  width:44px;
  height:44px;
  padding:0;
  border:1px solid #cad9ed;
  border-radius:14px;
  background:#f5f9ff;
  color:#0b5ed7;
  font-size:1.16rem;
  font-weight:900;
}

.photo-button:active{
  transform:scale(.97);
}

.photo-message{
  margin-top:2px;
}

.chat-photo{
  display:block;
  width:auto;
  max-width:100%;
  max-height:340px;
  border-radius:10px;
  background:#e8eef5;
  object-fit:contain;
  cursor:zoom-in;
}

.photo-loading{
  width:180px;
  height:160px;
  opacity:.55;
}

.photo-error{
  width:180px;
  min-height:70px;
}

@media (max-width:699px){
  .customer-chat .composer{
    grid-template-columns:44px minmax(0,1fr) 50px;
  }

  .photo-button{
    width:44px;
    height:44px;
  }

  .chat-photo{
    max-height:360px;
  }
}

@media (min-width:700px){
  .customer-chat .composer{
    grid-template-columns:40px minmax(0,1fr) 46px;
  }

  .photo-button{
    width:40px;
    height:40px;
    border-radius:12px;
    font-size:1rem;
  }

  .chat-photo{
    max-height:260px;
  }
}
