/* Styling targets the BlackBerry 10 browser (WebKit 537, ~2014).
   No CSS variables, no flexbox, no rem — absolute positioning and floats only. */

* { -webkit-box-sizing: border-box; box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #ece5dd;
  font-family: "Slate Pro", "Slate", Arial, Helvetica, sans-serif;
  font-size: 16px;
  color: #111;
  -webkit-text-size-adjust: none;
}

/* --- header --------------------------------------------------------------- */

#header {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: #075e54;
  color: #fff;
  z-index: 10;
}

#header h1 {
  margin: 0;
  padding: 14px 12px;
  font-size: 19px;
  font-weight: normal;
  line-height: 24px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#header h1.with-back { padding-left: 60px; }

#back {
  position: absolute;
  top: 0; left: 0;
  width: 56px;
  height: 52px;
  line-height: 52px;
  text-align: center;
  font-size: 26px;
  color: #fff;
  cursor: pointer;
  display: none;
}

#newchat {
  position: absolute;
  top: 0; right: 36px;
  width: 44px; height: 52px;
  line-height: 52px;
  text-align: center;
  font-size: 22px;
  color: #fff;
  cursor: pointer;
  display: none;
}

#dot {
  position: absolute;
  top: 20px; right: 14px;
  width: 12px; height: 12px;
  border-radius: 6px;
  background: #f0ad4e;
}
#dot.online { background: #25d366; }
#dot.offline { background: #d9534f; }

/* --- scrolling body ------------------------------------------------------- */

#main {
  position: absolute;
  top: 52px; bottom: 0; left: 0; right: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
#main.has-composer { bottom: 56px; }

/* --- chat list ------------------------------------------------------------ */

#list { background: #fff; }

.row {
  position: relative;
  min-height: 68px;
  padding: 11px 76px 11px 14px;
  border-bottom: 1px solid #e4e4e4;
  cursor: pointer;
}
.row:active { background: #f0f0f0; }

.row .name {
  font-size: 17px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.row .preview {
  font-size: 14px;
  color: #667;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row .time {
  position: absolute;
  top: 12px; right: 12px;
  font-size: 12px;
  color: #8a8a8a;
}
.row .badge {
  position: absolute;
  top: 36px; right: 12px;
  min-width: 22px;
  height: 22px;
  line-height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #25d366;
  color: #fff;
  font-size: 12px;
  text-align: center;
}

/* --- contacts ------------------------------------------------------------- */

#contacts { background: #fff; display: none; }

#csearchwrap {
  padding: 8px;
  background: #f4f4f4;
  border-bottom: 1px solid #ddd;
}

#csearch {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid #ccc;
  border-radius: 20px;
  outline: none;
}

.row .number {
  font-size: 13px;
  color: #8a8a8a;
  margin-top: 2px;
}

.row.lookup .name { color: #075e54; }

/* --- conversation --------------------------------------------------------- */

#thread { padding: 8px 8px 12px 8px; }

.msg {
  max-width: 84%;
  /* Wide enough that the timestamp and ticks can never sit on top of very
     short messages like "hm". */
  min-width: 96px;
  margin: 0 0 8px 0;
  padding: 7px 10px 18px 10px;
  border-radius: 8px;
  background: #fff;
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,0.15);
  clear: both;
  float: left;
}
.msg.me {
  background: #dcf8c6;
  float: right;
}
.msg .who {
  font-size: 13px;
  font-weight: bold;
  color: #075e54;
  margin-bottom: 2px;
}
.msg .body { font-size: 16px; line-height: 21px; white-space: pre-wrap; }
.msg .meta {
  position: absolute;
  right: 8px; bottom: 3px;
  font-size: 11px;
  color: #8a8a8a;
}

/* Delivery ticks, drawn from borders so no font glyph is involved:
   one tick = sent, two = delivered, two blue = read, circle = pending. */
.tk {
  display: inline-block;
  position: relative;
  width: 11px;
  height: 9px;
  margin-left: 3px;
  vertical-align: middle;
}
.tk.dbl { width: 16px; }

.tk i {
  position: absolute;
  top: 1px;
  left: 0;
  display: block;
  width: 7px;
  height: 3px;
  border-left: 2px solid #7d8a8a;
  border-bottom: 2px solid #7d8a8a;
  -webkit-transform: rotate(-45deg);
  transform: rotate(-45deg);
}
.tk i.b { left: 5px; }
.tk.read i { border-color: #34b7f1; }

.tk.pend {
  width: 8px;
  height: 8px;
  border: 2px solid #9aa5a5;
  border-radius: 50%;
}
.msg .quote {
  border-left: 3px solid #25d366;
  padding: 2px 0 2px 6px;
  margin-bottom: 4px;
  font-size: 13px;
  color: #555;
  background: rgba(0,0,0,0.04);
}
.msg img.media {
  max-width: 100%;
  display: block;
  margin-bottom: 4px;
  border-radius: 4px;
}
.msg a.file {
  display: block;
  color: #075e54;
  text-decoration: none;
  padding: 6px 0;
  font-size: 15px;
}
.msg audio { width: 100%; margin-bottom: 4px; }

.earlier {
  clear: both;
  text-align: center;
  margin: 4px 0 12px 0;
  padding: 10px;
  background: rgba(255,255,255,0.9);
  border: 1px solid #d6d0c8;
  border-radius: 16px;
  font-size: 14px;
  color: #075e54;
  cursor: pointer;
}
.earlier:active { background: #e8e2da; }

.daysep {
  clear: both;
  text-align: center;
  margin: 10px 0;
}
.daysep span {
  background: rgba(255,255,255,0.85);
  border-radius: 10px;
  padding: 3px 10px;
  font-size: 12px;
  color: #555;
}

/* --- composer ------------------------------------------------------------- */

#composer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 56px;
  background: #f4f4f4;
  border-top: 1px solid #d8d8d8;
  display: none;
  z-index: 10;
}
#composer.on { display: block; }

#attach {
  position: absolute;
  left: 6px; top: 8px;
  width: 40px; height: 40px;
  line-height: 38px;
  text-align: center;
  font-size: 28px;
  color: #075e54;
  cursor: pointer;
}

#text {
  position: absolute;
  left: 50px; right: 84px; top: 8px;
  height: 40px;
  padding: 0 10px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid #ccc;
  border-radius: 20px;
  background: #fff;
  outline: none;
}

#send {
  position: absolute;
  right: 8px; top: 8px;
  width: 68px; height: 40px;
  border: 0;
  border-radius: 20px;
  background: #25d366;
  color: #fff;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
}
#send:disabled { background: #a5d6b7; }

/* --- attach sheet --------------------------------------------------------- */

#sheet {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 20;
  display: none;
}
#sheet.on { display: block; }

#sheet-inner {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid #ccc;
}

.sheet-title {
  padding: 12px 16px;
  font-size: 14px;
  color: #888;
  border-bottom: 1px solid #eee;
}

.sheet-opt {
  display: block;
  padding: 16px;
  font-size: 17px;
  color: #111;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
.sheet-opt:active { background: #f0f0f0; }
.sheet-opt.cancel { color: #b33; }

.sheet-note {
  padding: 12px 16px 16px 16px;
  font-size: 13px;
  color: #888;
  line-height: 18px;
}

/* The upload form is driven by the sheet's labels; never shown directly. */
#upform, #upframe { position: absolute; width: 1px; height: 1px; left: -9999px; top: 0; border: 0; }

#uploading {
  position: absolute;
  left: 0; right: 0; bottom: 56px;
  padding: 10px;
  background: #075e54;
  color: #fff;
  font-size: 14px;
  text-align: center;
  z-index: 15;
  display: none;
}
#uploading.on { display: block; }

/* --- notices / QR --------------------------------------------------------- */

#notice {
  padding: 20px 16px;
  text-align: center;
  color: #444;
  font-size: 15px;
  line-height: 22px;
}
#notice img { max-width: 280px; width: 90%; margin: 12px auto; display: block; background: #fff; padding: 8px; }
#notice b { color: #075e54; }

/* --- login ---------------------------------------------------------------- */

#login-wrap {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #075e54;
  color: #fff;
  text-align: center;
  padding: 60px 24px 0 24px;
}
#login-wrap h1 { font-size: 26px; font-weight: normal; margin: 0 0 6px 0; }
#login-wrap p { font-size: 14px; color: #b7d8d3; margin: 0 0 30px 0; }
#login-wrap input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  font-size: 17px;
  font-family: inherit;
  border: 0;
  border-radius: 4px;
  margin-bottom: 14px;
  outline: none;
}
#login-wrap button {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 4px;
  background: #25d366;
  color: #fff;
  font-size: 17px;
  font-family: inherit;
  cursor: pointer;
}
#login-error { color: #ffd2d2; font-size: 14px; height: 20px; margin-top: 12px; }
