
:root{
  --bg:#090d14;
  --panel:#111722;
  --panel2:#171e2a;
  --line:#252e3b;
  --text:#f4f7fb;
  --muted:#8994a5;
  --primary:#6d72ff;
  --primary2:#555bea;
  --danger:#ef5360;
  --green:#36d58a;
  --radius:18px;
}

*{
  box-sizing:border-box;
}

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

body{
  background:var(--bg);
  color:var(--text);
  font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  overflow:hidden;
}

button,
input,
textarea{
  font:inherit;
}

button{
  border:0;
  cursor:pointer;
}

input,
textarea{
  outline:none;
}

.hidden{
  display:none!important;
}


/* AUTH */

.auth-page{
  width:100%;
  height:100%;
  display:grid;
  place-items:center;
  padding:20px;
}

.auth-card{
  width:min(410px,100%);
  background:rgba(17,23,34,.96);
  border:1px solid var(--line);
  border-radius:26px;
  padding:34px;
  box-shadow:0 25px 80px #0008;
}

.logo{
  width:58px;
  height:58px;
  border-radius:18px;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,#7d82ff,#555bea);
  font-size:25px;
  font-weight:800;
  margin-bottom:25px;
}

.logo span{
  color:white;
}

.auth-card h1{
  margin:0;
  font-size:27px;
}

.auth-card p{
  color:var(--muted);
  line-height:1.6;
}

.error-message{
  color:#ff7b84;
  min-height:20px;
  margin:12px 0;
}

#authForm{
  display:grid;
  gap:9px;
}

#authForm label{
  color:#b7c0ce;
  font-size:13px;
}

#authForm input,
.settings-section input,
#createGroupForm input,
#createGroupForm textarea{
  width:100%;
  border:1px solid var(--line);
  background:#0d131c;
  color:var(--text);
  padding:13px 14px;
  border-radius:13px;
}

#authForm input:focus,
#createGroupForm input:focus,
#createGroupForm textarea:focus{
  border-color:var(--primary);
}

.primary-button{
  background:linear-gradient(135deg,var(--primary),var(--primary2));
  color:white;
  padding:13px 17px;
  border-radius:13px;
  font-weight:700;
}

.primary-button:hover{
  filter:brightness(1.08);
}

.auth-switch{
  text-align:center;
  color:var(--muted);
  margin-top:20px;
}

.auth-switch button{
  background:none;
  color:#8d92ff;
  margin-left:5px;
}


/* APP */

.app-page{
  width:100%;
  height:100%;
  display:flex;
}

.sidebar{
  width:340px;
  height:100%;
  background:var(--panel);
  border-right:1px solid var(--line);
  display:flex;
  flex-direction:column;
}

.sidebar-header{
  padding:17px;
  display:flex;
  align-items:center;
  justify-content:space-between;
}

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

.brand-logo{
  width:42px;
  height:42px;
  border-radius:14px;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,#767bff,#555bea);
  font-weight:800;
}

.brand strong{
  display:block;
  font-size:17px;
}

.brand small{
  color:var(--muted);
  font-size:12px;
}

.header-buttons{
  display:flex;
  gap:7px;
}

.icon-button{
  width:40px;
  height:40px;
  border-radius:12px;
  background:var(--panel2);
  border:1px solid var(--line);
  color:#dce2ec;
  display:grid;
  place-items:center;
  font-size:17px;
}

.icon-button:hover{
  background:#222b39;
}

.danger-icon:hover{
  color:#ff727c;
}


/* SEARCH */

.search-container{
  padding:0 14px;
  position:relative;
}

.search-box{
  height:46px;
  display:flex;
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  background:#0d131c;
}

.search-box input{
  min-width:0;
  flex:1;
  border:0;
  background:transparent;
  color:white;
  padding:0 13px;
}

.search-box button{
  width:48px;
  background:transparent;
  color:#8f95ff;
  font-size:20px;
}

.search-results{
  position:absolute;
  left:14px;
  right:14px;
  top:52px;
  background:#151c27;
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  z-index:5;
  box-shadow:0 15px 35px #0008;
}


/* LIST */

.list-title{
  padding:20px 17px 8px;
  color:var(--muted);
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
  display:flex;
  justify-content:space-between;
}

.contact-list{
  flex:1;
  overflow-y:auto;
  padding:5px 10px 20px;
}

.contact-item{
  display:flex;
  align-items:center;
  gap:11px;
  padding:11px;
  border-radius:14px;
  cursor:pointer;
  margin-bottom:3px;
}

.contact-item:hover{
  background:#1a222e;
}

.contact-item.active{
  background:#20283a;
}

.contact-item-info{
  min-width:0;
  flex:1;
}

.contact-item-name{
  display:block;
  font-weight:650;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.contact-item-status{
  display:block;
  color:var(--muted);
  font-size:12px;
  margin-top:3px;
}

.online{
  color:var(--green)!important;
}


/* AVATAR */

.avatar{
  width:44px;
  height:44px;
  flex:none;
  border-radius:50%;
  background:linear-gradient(135deg,#666cff,#454bd4);
  display:grid;
  place-items:center;
  font-weight:750;
  overflow:hidden;
}

.avatar img,
.profile-large img{
  width:100%;
  height:100%;
  object-fit:cover;
}


/* CHAT */

.chat-page{
  min-width:0;
  flex:1;
  display:flex;
  flex-direction:column;
  background:#0d131c;
}

.chat-header,
.group-header{
  min-height:72px;
  padding:12px 18px;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  background:rgba(13,19,28,.94);
}

.chat-user,
.group-title{
  min-width:0;
  display:flex;
  align-items:center;
  gap:11px;
}

.chat-user-info strong,
.group-title strong{
  display:block;
}

.chat-user-info span,
.group-title span{
  display:block;
  color:var(--muted);
  font-size:12px;
  margin-top:3px;
}

.chat-actions{
  display:flex;
  gap:7px;
}

.mobile-back-button{
  display:none;
  width:38px;
  height:38px;
  border-radius:11px;
  background:var(--panel2);
  color:white;
  font-size:25px;
}

.messages{
  flex:1;
  overflow-y:auto;
  padding:22px;
}

.empty-chat{
  height:100%;
  display:grid;
  place-items:center;
  align-content:center;
  text-align:center;
  color:var(--muted);
}

.empty-icon{
  width:65px;
  height:65px;
  border-radius:20px;
  background:linear-gradient(135deg,#686dff,#4e54d7);
  color:white;
  display:grid;
  place-items:center;
  font-size:25px;
  font-weight:800;
  margin-bottom:12px;
}

.empty-chat h2{
  color:#e8edf5;
  margin:5px 0;
}

.message-row{
  display:flex;
  margin:5px 0;
}

.message-row.mine{
  justify-content:flex-end;
}

.message-bubble{
  max-width:min(72%,650px);
  padding:9px 12px;
  border-radius:15px;
  background:#1b2430;
  overflow-wrap:anywhere;
  white-space:pre-wrap;
  line-height:1.45;
}

.message-row.mine .message-bubble{
  background:linear-gradient(135deg,#6268f5,#555bea);
  border-bottom-right-radius:5px;
}

.message-row:not(.mine) .message-bubble{
  border-bottom-left-radius:5px;
}

.message-meta{
  color:#aab3c1;
  font-size:10px;
  margin-top:4px;
  text-align:right;
}

.message-row.mine .message-meta{
  color:#dce0ff;
}


/* COMPOSER */

.message-composer{
  padding:12px 16px 16px;
  display:flex;
  align-items:flex-end;
  gap:9px;
  border-top:1px solid var(--line);
  background:#0d131c;
}

#messageInput{
  min-height:45px;
  max-height:140px;
  resize:none;
  flex:1;
  border:1px solid var(--line);
  background:#151d28;
  color:white;
  border-radius:15px;
  padding:12px 14px;
  line-height:20px;
}

.send-button{
  width:45px;
  height:45px;
  border-radius:14px;
  background:var(--primary);
  color:white;
  font-size:20px;
}


/* MODALS */

.modal{
  position:fixed;
  inset:0;
  background:#0009;
  backdrop-filter:blur(8px);
  display:grid;
  place-items:center;
  padding:18px;
  z-index:50;
}

.modal-card{
  width:min(470px,100%);
  max-height:90vh;
  overflow:auto;
  background:#121924;
  border:1px solid var(--line);
  border-radius:22px;
  padding:22px;
  box-shadow:0 25px 80px #000b;
}

.modal-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  margin-bottom:20px;
}

.modal-header h2{
  margin:0;
}

.modal-header p{
  color:var(--muted);
  margin:5px 0;
}

.close-button{
  width:36px;
  height:36px;
  border-radius:10px;
  background:#1d2633;
  color:white;
  font-size:22px;
}


/* SETTINGS */

.profile-editor{
  display:flex;
  align-items:center;
  gap:18px;
  padding:5px 0 22px;
}

.profile-large{
  width:76px;
  height:76px;
  flex:none;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,#6b70ff,#4c52d8);
  font-size:25px;
  font-weight:800;
  overflow:hidden;
}

.profile-buttons{
  display:flex;
  flex-wrap:wrap;
  gap:7px;
}

.secondary-button{
  display:inline-flex;
  justify-content:center;
  align-items:center;
  border:1px solid var(--line);
  background:#1b2430;
  color:#dfe5ee;
  padding:10px 13px;
  border-radius:11px;
}

.settings-section{
  padding:15px 0;
  border-top:1px solid var(--line);
}

.settings-section label,
.settings-section h3{
  font-size:13px;
  color:var(--muted);
  margin:0 0 8px;
}

.setting-value{
  padding:11px;
  border-radius:11px;
  background:#0d131c;
}

.blocked-list{
  display:grid;
  gap:6px;
}

.blocked-user{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:10px;
  background:#0d131c;
  border-radius:11px;
}

.logout-button{
  width:100%;
  padding:12px;
  margin-top:18px;
  border-radius:12px;
  background:#35171b;
  color:#ff8189;
}


/* GROUP */

#createGroupForm{
  display:grid;
  gap:9px;
}

#createGroupForm label{
  color:#b7c0ce;
  font-size:13px;
}

#createGroupForm textarea{
  min-height:90px;
  resize:vertical;
}

.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:20px;
}

.menu-actions{
  display:grid;
  gap:8px;
}

.menu-button{
  width:100%;
  padding:14px;
  border-radius:13px;
  background:#1a222e;
  color:#e9edf4;
  text-align:left;
  display:flex;
  gap:10px;
  align-items:center;
}

.menu-button:hover{
  background:#222c39;
}

.menu-button.danger{
  color:#ff7b84;
}

.member-list{
  display:grid;
  gap:6px;
}

.member-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px;
  background:#0d131c;
  border-radius:12px;
}

.join-card{
  text-align:center;
}

.group-invite-icon{
  width:70px;
  height:70px;
  margin:0 auto 14px;
  border-radius:22px;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,#6d72ff,#5056dc);
  font-size:27px;
  font-weight:800;
}


/* CALL */

.call-screen{
  position:fixed;
  inset:0;
  z-index:100;
  background:#05070b;
}

.remote-video{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  background:#090d14;
}

.local-video{
  position:absolute;
  top:18px;
  right:18px;
  width:150px;
  height:210px;
  object-fit:cover;
  border-radius:17px;
  border:2px solid #fff3;
  background:#101722;
}

.call-top{
  position:absolute;
  top:0;
  left:0;
  right:0;
  z-index:2;
  padding:22px;
  background:linear-gradient(#0009,transparent);
}

.call-top strong,
.call-top span{
  display:block;
}

.call-top span{
  color:#c0c8d5;
  margin-top:4px;
}

.call-controls{
  position:absolute;
  bottom:30px;
  left:0;
  right:0;
  display:flex;
  justify-content:center;
  gap:12px;
  z-index:3;
}

.call-control{
  width:54px;
  height:54px;
  border-radius:50%;
  background:#242c38;
  color:white;
}

.call-control.hangup{
  background:#e34d59;
}

.incoming-call{
  text-align:center;
}

.incoming-call .profile-large{
  margin:0 auto 15px;
}

.incoming-actions{
  display:flex;
  justify-content:center;
  gap:12px;
  margin-top:20px;
}

.reject-button,
.accept-button{
  padding:12px 22px;
  border-radius:12px;
  color:white;
}

.reject-button{
  background:#3a1b20;
  color:#ff7d86;
}

.accept-button{
  background:#28b978;
}


/* TOAST */

.toast{
  position:fixed;
  left:50%;
  bottom:25px;
  transform:translate(-50%,20px);
  opacity:0;
  pointer-events:none;
  z-index:200;
  padding:11px 16px;
  border-radius:12px;
  background:#202a37;
  color:white;
  border:1px solid var(--line);
  transition:.2s;
}

.toast.show{
  opacity:1;
  transform:translate(-50%,0);
}


/* MOBILE */

@media(max-width:760px){

  .sidebar{
    width:100%;
  }

  .chat-page{
    position:fixed;
    inset:0;
    display:none;
  }

  .app-page.chat-open .sidebar{
    display:none;
  }

  .app-page.chat-open .chat-page{
    display:flex;
  }

  .mobile-back-button{
    display:grid;
    place-items:center;
  }

  .message-bubble{
    max-width:86%;
  }

  .chat-actions .icon-button{
    width:36px;
    height:36px;
  }

  .local-video{
    width:105px;
    height:155px;
  }

  .auth-card{
    padding:25px;
  }
}
