/* ============ RESET & BASE ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  overflow: hidden;
}
body {
  font-family:
    "Inter",
    -apple-system,
    sans-serif;
  background: #0b141a;
  color: #e9edef;
}
.hidden {
  display: none !important;
}

/* ============ LOGIN ============ */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #00a884 0%, #075e54 50%, #0b141a 100%);
}
.login-card {
  background: #1f2c34;
  border-radius: 20px;
  padding: 48px 40px;
  text-align: center;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.login-logo {
  font-size: 64px;
  margin-bottom: 12px;
}
.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  color: #00a884;
  margin-bottom: 8px;
}
.login-card p {
  color: #8696a0;
  font-size: 14px;
  margin-bottom: 24px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.phone-input-group {
  display: flex;
  align-items: center;
  background: #2a3942;
  border-radius: 12px;
  overflow: hidden;
}
.country-select {
  padding: 10px 8px;
  background: #1a252c;
  border: none;
  color: #e9edef;
  font-size: 15px;
  cursor: pointer;
  outline: none;
  border-right: 1px solid #3b4a54;
  min-width: 100px;
}
.country-select option {
  background: #1a252c;
  color: #e9edef;
}
.phone-number-input {
  flex: 1;
}
.login-input {
  width: 100%;
  padding: 14px 16px;
  background: #2a3942;
  border: none;
  border-radius: 12px;
  color: #e9edef;
  font-size: 16px;
  outline: none;
  transition: box-shadow 0.2s;
}
.phone-input-group .login-input {
  border-radius: 0;
}
.login-input:focus {
  box-shadow: inset 0 0 0 2px #00a884;
}
.login-input::placeholder {
  color: #8696a0;
}
.btn-login {
  padding: 14px;
  background: #00a884;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.1s;
}
.btn-login:hover {
  background: #00c49a;
}
.btn-login:active {
  transform: scale(0.97);
}
.code-display {
  background: #1a252c;
  border: 2px dashed #00a884;
  border-radius: 12px;
  padding: 14px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 10px;
  text-align: center;
  color: #00a884;
  font-family: "Courier New", monospace;
}
.code-input {
  text-align: center;
  font-size: 24px;
  letter-spacing: 8px;
  font-weight: 700;
}
.btn-back {
  padding: 10px;
  background: none;
  border: none;
  color: #8696a0;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s;
}
.btn-back:hover {
  color: #e9edef;
}

/* ============ APP LAYOUT ============ */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ============ HEADER ============ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #1f2c34;
  border-bottom: 1px solid #2a3942;
  min-height: 56px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo {
  font-size: 28px;
}
.header-title {
  font-size: 20px;
  font-weight: 700;
  color: #00a884;
}
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}
.header-name {
  font-size: 14px;
  font-weight: 500;
}
.btn-icon {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ============ CONTACTS BAR (HORIZONTAL) ============ */
.contacts-bar {
  background: #111b21;
  border-bottom: 1px solid #2a3942;
  padding: 12px 0 12px 12px;
}
.contacts-scroll-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  overflow-x: auto;
  padding-right: 12px;
  scrollbar-width: thin;
  scrollbar-color: #2a3942 transparent;
}
.contacts-scroll-wrapper::-webkit-scrollbar {
  height: 4px;
}
.contacts-scroll-wrapper::-webkit-scrollbar-thumb {
  background: #2a3942;
  border-radius: 4px;
}
.contacts-scroll {
  display: flex;
  gap: 4px;
}

/* Contact card */
.contact-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s;
  min-width: 76px;
  max-width: 76px;
  position: relative;
}
.contact-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.contact-item.active {
  background: #00a884;
}
.contact-item.active .contact-name {
  color: #fff;
}

.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  position: relative;
  flex-shrink: 0;
}
.contact-online-dot {
  width: 12px;
  height: 12px;
  background: #00a884;
  border: 2px solid #111b21;
  border-radius: 50%;
  position: absolute;
  bottom: 0;
  right: 0;
  display: none;
}
.contact-item.online .contact-online-dot {
  display: block;
}
.contact-name {
  font-size: 11px;
  font-weight: 500;
  color: #8696a0;
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-unread {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #00a884;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}
.contact-item.has-unread .contact-unread {
  display: flex;
}

/* Add contact button */
.contact-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s;
  min-width: 76px;
  max-width: 76px;
  background: none;
  border: none;
  color: #8696a0;
}
.contact-add:hover {
  background: rgba(255, 255, 255, 0.06);
}
.contact-add-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px dashed #00a884;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #00a884;
  transition: background 0.2s;
}
.contact-add:hover .contact-add-icon {
  background: rgba(0, 168, 132, 0.1);
}
.contact-add span {
  font-size: 11px;
  font-weight: 500;
}

/* ============ MODAL ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: #1f2c34;
  border-radius: 16px;
  padding: 28px;
  width: 340px;
  text-align: center;
}
.modal-content h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: #e9edef;
}
.modal-content p {
  font-size: 13px;
  color: #8696a0;
  margin-bottom: 16px;
}
.modal-content .phone-input-group {
  margin-bottom: 16px;
}
.modal-buttons {
  display: flex;
  gap: 10px;
}
.btn-modal {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-cancel {
  background: #2a3942;
  color: #8696a0;
}
.btn-confirm {
  background: #00a884;
  color: #fff;
}
.btn-modal:hover {
  opacity: 0.85;
}

/* ============ CHAT AREA ============ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0b141a;
  position: relative;
}

/* Placeholder */
.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #8696a0;
}
.placeholder-icon {
  font-size: 80px;
  margin-bottom: 16px;
  opacity: 0.3;
}
.chat-placeholder h2 {
  font-size: 22px;
  font-weight: 300;
  color: #e9edef;
  margin-bottom: 8px;
}
.chat-placeholder p {
  font-size: 14px;
}

/* Chat active */
.chat-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #1f2c34;
  border-bottom: 1px solid #2a3942;
}
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.chat-contact-name {
  font-size: 16px;
  font-weight: 600;
  display: block;
}
.chat-contact-status {
  font-size: 12px;
  color: #8696a0;
}

/* Messages container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #0b141a;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.015'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.messages-container::-webkit-scrollbar {
  width: 6px;
}
.messages-container::-webkit-scrollbar-thumb {
  background: #2a3942;
  border-radius: 6px;
}

/* Message bubble */
.msg {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
  animation: msgIn 0.2s ease-out;
}
@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.msg-sent {
  align-self: flex-end;
  background: #005c4b;
  border-bottom-right-radius: 4px;
}
.msg-received {
  align-self: flex-start;
  background: #1f2c34;
  border-bottom-left-radius: 4px;
}
.msg-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  text-align: right;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.msg-check {
  font-size: 14px;
}
.msg-check.seen {
  color: #53bdeb;
}

/* Image message */
.msg-image {
  max-width: 280px;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.msg-image:hover {
  opacity: 0.85;
}
.msg img {
  width: 100%;
  border-radius: 8px;
}

/* Custom audio player */
.custom-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  padding: 4px 0;
}
.audio-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.audio-play-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}
.audio-play-btn:active {
  transform: scale(0.9);
}
.audio-progress-wrap {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  cursor: pointer;
  min-width: 80px;
  position: relative;
}
.audio-progress-bar {
  height: 100%;
  background: #00a884;
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}
.audio-time {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

/* Date separator */
.date-separator {
  align-self: center;
  background: #1f2c34;
  padding: 4px 14px;
  border-radius: 8px;
  font-size: 12px;
  color: #8696a0;
  margin: 8px 0;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 76px;
  color: #00a884;
  font-size: 13px;
}
.typing-dots {
  display: flex;
  gap: 3px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  background: #00a884;
  border-radius: 50%;
  animation: typingBounce 0.6s infinite alternate;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes typingBounce {
  from {
    opacity: 0.3;
    transform: translateY(0);
  }
  to {
    opacity: 1;
    transform: translateY(-4px);
  }
}

/* ============ INPUT AREA ============ */
.input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #1f2c34;
  border-top: 1px solid #2a3942;
}
.input-wrapper {
  flex: 1;
}
.msg-input {
  width: 100%;
  padding: 10px 16px;
  background: #2a3942;
  border: none;
  border-radius: 24px;
  color: #e9edef;
  font-size: 14px;
  outline: none;
}
.msg-input::placeholder {
  color: #8696a0;
}
.btn-attach,
.btn-voice {
  color: #8696a0;
  font-size: 22px;
}
.btn-send {
  width: 42px;
  height: 42px;
  background: #00a884;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.1s;
  flex-shrink: 0;
}
.btn-send:hover {
  background: #00c49a;
}
.btn-send:active {
  transform: scale(0.9);
}

/* Recording bar */
.recording-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #1f2c34;
  border-top: 1px solid #2a3942;
  width: 100%;
}
.recording-pulse {
  width: 12px;
  height: 12px;
  background: #ff4444;
  border-radius: 50%;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.3);
  }
}
#recording-time {
  flex: 1;
  font-size: 16px;
  color: #ff4444;
  font-weight: 600;
}
.btn-stop {
  background: #ff4444;
}
.btn-stop:hover {
  background: #ff6666;
}

/* ============ IMAGE MODAL ============ */
.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: pointer;
}
.image-modal img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
}

/* ============ CALL BUTTON ============ */
.btn-call {
  font-size: 22px;
  margin-left: auto;
}

/* ============ CALL MODAL ============ */
.call-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.call-modal-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px;
}
.call-modal .call-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 700;
  color: #fff;
}
.call-modal h3 {
  font-size: 24px;
  color: #e9edef;
}
.call-modal p {
  font-size: 14px;
  color: #8696a0;
}
.call-modal #call-timer {
  font-size: 32px;
  color: #00a884;
  font-weight: 300;
}
.call-actions {
  display: flex;
  gap: 24px;
  margin-top: 20px;
}
.call-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  font-size: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.15s,
    opacity 0.2s;
}
.call-btn:active {
  transform: scale(0.9);
}
.call-accept {
  background: #00a884;
}
.call-reject {
  background: #ff4444;
}
.call-mute {
  background: rgba(255, 255, 255, 0.15);
}
.call-mute.active {
  background: #00a884;
}
@keyframes callPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(0, 168, 132, 0.4);
  }
  50% {
    box-shadow: 0 0 0 20px rgba(0, 168, 132, 0);
  }
}
.call-modal .call-avatar {
  animation: callPulse 2s infinite;
}

/* ============ CALL PARTICIPANTS ============ */
.call-participants {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
}
.call-participant {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.call-participant .cp-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}
.call-participant .cp-name {
  font-size: 12px;
  color: #8696a0;
}
.call-participant.cp-connected .cp-avatar {
  box-shadow: 0 0 0 3px #00a884;
}
.call-contact-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.call-contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.2s;
}
.call-contact-item:hover {
  background: rgba(255, 255, 255, 0.1);
}
.call-contact-item .cci-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.call-contact-item .cci-name {
  flex: 1;
  color: #e9edef;
}
.call-contact-item .cci-status {
  font-size: 12px;
  color: #00a884;
}
#add-to-call-modal {
  z-index: 400;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .messages-container {
    padding: 12px 12px;
  }
  .msg {
    max-width: 85%;
  }
  .msg-audio {
    max-width: 200px;
  }
  .login-card {
    width: 92%;
    padding: 32px 20px;
  }
  .input-area {
    gap: 4px;
    padding: 8px 8px;
  }
  .msg-input {
    padding: 10px 12px;
    font-size: 16px;
  }
  .btn-send {
    width: 38px;
    height: 38px;
  }
  .btn-attach,
  .btn-voice {
    font-size: 20px;
    padding: 4px;
  }
  .contact-item {
    min-width: 64px;
    max-width: 64px;
    padding: 6px 6px;
  }
  .contact-avatar {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }
  .contact-add {
    min-width: 64px;
    max-width: 64px;
  }
  .contact-add-icon {
    width: 42px;
    height: 42px;
    font-size: 20px;
  }
  .header {
    padding: 8px 12px;
  }
  .header-title {
    font-size: 16px;
  }
  .typing-indicator {
    padding: 6px 12px;
  }
  .chat-header {
    padding: 8px 12px;
  }
  .recording-bar {
    gap: 8px;
    padding: 8px 12px;
  }
  .modal-content {
    width: 90%;
    padding: 20px;
  }
}

@media (max-width: 400px) {
  .msg {
    max-width: 90%;
  }
  .msg-audio {
    max-width: 160px;
  }
  .contact-item {
    min-width: 56px;
    max-width: 56px;
  }
  .contact-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  .contact-name {
    font-size: 10px;
  }
}
