/* ===== Container utama ===== */
#container {
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f0f2f5;
  color: #333;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 0;
  min-height: 100%;   /* ikut isi halaman */
  height: auto;       /* tinggi fleksibel sesuai konten */
  margin: 0;
  box-sizing: border-box;
}

/* Key host & guest */
#hostKey, 
#guestKey {
  padding: 5px 10px;
  background: #858585;
  color: #ffffff;
  font-size: 13px;
}
.autoConnect {
    margin: 10px;
    text-align: left;
    font-size: 12px;
}
/* ===== Kotak utama ===== */
#box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  height: auto;       /* tinggi menyesuaikan konten */
  overflow: hidden;
}

/* ===== Loading spinner umum ===== */
#loadingIndicator {
  display: none;
  justify-content: center;
  align-items: center;
  margin: 15px 0;
}
.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border: 4px solid #ccc;
  border-top: 4px solid #2e7d32;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 2;
  background: transparent;
}

/* ===== Form awal ===== */
#startForm,
#guestForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Grup input + tombol */
.inputGroup {
  display: flex;
  gap: 5px;
  align-items: center;
  animation: slideIn 0.6s ease forwards;
  padding: 10px;
}

/* Input key & pesan */
#key, #keyGuest {
  padding: 10px 14px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 18px;
  width: 100%;
  box-sizing: border-box;
  transition: all 0.3s ease;
}
#key:focus,
#keyGuest:focus {
  border-color: #008069;
  box-shadow: 0 0 6px rgba(0,128,105,0.3);
  transform: scale(1.02);
}

/* Tombol */
#startBtn, #joinBtn, .btn-send, .autoLoadSession {
  background: #16668d;
  color: #fff;
  padding: 4px 6px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}
#startBtn:hover, #joinBtn:hover, .btn-send:hover, .autoLoadSession:hover {
  background: #00816a;
}

#checkboxAutoSellect {
    margin: 10px;
}
#checkboxAutoSellect label {
    vertical-align: text-bottom;
    cursor: pointer;
    margin-left: 5px;
    font-weight: bold;
    color: #c54900;
}

/* Tombol Copy Invite */
#copyInviteBtn {
    background: #00ad41;
    color: #fff;
    padding: 6px 14px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease, transform 0.1s ease;
}
#copyInviteBtn:hover {
    background: #1cd364;
    transform: scale(1.02);
}
#inviteInfo {
    display: none;
    margin: 10px 5px 3px;
    padding: 0 5px 5px;
    background: #ffffff;
    border: solid 1px #aaa;
}
#inviteInfo b {
    color: #1b42ff;
    font-size: 16px;
}

/* ===== Animasi ===== */
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 rgba(0,0,0,0); }
  50%  { box-shadow: 0 0 10px rgba(0, 123, 255, 0.5); }
  100% { box-shadow: 0 0 0 rgba(0,0,0,0); }
}
@keyframes spin {
  0%   { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Invite link wrapper ===== */
#inviteWrap {
  padding: 8px;
  background: #f9f9f9;
  border: 1px dashed #ccc;
  font-size: 14px;
  border-radius: 6px;
  text-align: center;
}

/* ===== Status Host & Guest ===== */
#statusHost,
#statusGuest {
    margin: 0 auto 10px;
    padding: 10px 10px 10px 20px;
    background: #ffffef;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    width: 90%;
    max-width: 400px;
    text-align: left;
    list-style: none;
}
#statusHost li,
#statusGuest li {
  font-size: 14px;
  margin: 6px 0;
  padding-left: 22px;
  position: relative;
  color: #444;
}
#statusHost li::before,
#statusGuest li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #bbb;
}
#statusHost li.done::before,
#statusGuest li.done::before {
    font-size: 12px;
    color: #008069;
    background: none;
    content: "✅";
    margin-left: -3px;
    margin-top: -5px;
}

/* ===== Area chat ===== */
#chatUI {
  display: flex;
  flex-direction: column;
  flex: 1;
}
#banner {
  text-align: center;
  font-size: 13px;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  background: #fff8c4;
  color: #555;
}
#chat {
    flex: 1;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
    background: #242424 url("../background-UI.jpg");
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    border-top: solid 1px #a7a7a7;
}
#message {
    width: 100%;
    height: 50px;
    padding: 6px 10px;
    resize: none;
    border-radius: 10px;
    font-size: 17px;
}
.message {
  max-width: 70%;
  padding: 1px 6px 3px;
  border-radius: 8px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  position: relative;
  font-size: 16px;
  line-height: 1.4;
}
.message.me {
  background: #308d00;
  color: #ffffff;
  align-self: flex-end;
  border-top-right-radius: 0;
}
.message.friend {
  background: #ffffff;
  align-self: flex-start;
  border-top-left-radius: 0;
}
.message.friend.hasImage .imgSpinner {
    top: 25% !important;
}
.message::after {
  content: attr(data-time);
  font-size: 11px;
  color: #888;
  position: absolute;
  bottom: -16px;
  right: 8px;
  white-space: nowrap;
}
.message.hasImage {
    padding: 10px;
    margin-bottom: 10px;
    border: solid 1px #6e6e6e;
    background: #3a3a3a !important;
}
.message.system {
    color: #ff9a9a;
    font-size: 12px;
    width: 100%;
    max-width: none;
    padding: 0;
}
.link_download {
    display: block;
    color: yellow;
}
.link_download:hover {
    text-decoration: underline;
}
/* ===== Status koneksi ===== */
#connStatus {
    font-size: 14px;
    padding: 6px;
    text-align: center;
    background: #242424 url(../background-UI.jpg);
    color: #c5c5c5;
}
#connStatus a {
    color: #fbff0a;
    font-weight: bold;
}
#connStatus a:hover {
    text-decoration: underline;
}
#connStatus.disconnected {
    background: #9d1000;
    color: #ffcccc;
}

/* ===== Input bar ===== */
#inputWrap {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: #fff;
  border-top: 1px solid #ddd;
}
#btn-img {
    width: 50px;
    height: 50px;
    border: unset;
    cursor: pointer;
    background: url('https://p2psecret.com/p2pchat/image-upload-button.png') no-repeat center center;
    background-size: 70%;
    transition: background-color 0.2s;
}
#btn-img:hover {
    border: solid 1px #aaa;
    border-radius: 5px;
}
.message .caption {
    display: block;
    max-width: 250px;
    color: #fff;
    font-size: 13px;
    text-align: center;
    background: #3a3a3a;
}

/* ===== Gambar & spinner ===== */

.message .imgWrap {
  display: inline-block;
  max-width: 250px; /* lebar maksimal gambar */
}

.message .img {
    display: block;
    width: 100%;
    border-radius: 4px;
}

.imgSpinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border: 4px solid rgba(255, 255, 255, 0.6);
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 2;
}

/* ===== Utility ===== */
#container .hidden { display: none; }
.fade-up { animation: fadeUp 0.5s ease; }

@media (max-width: 600px) {
   #container {
    padding: 0;
    border-radius: 15px;
   }
   #message {
    font-size: 13px;
   }
}
