* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #0d1117;
    color: #f1f5f9;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 19px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
}

.logo:hover {
    opacity: 0.8;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

.hidden {
    display: none !important;
}

/* ==================================================
   TOPBAR
================================================== */

.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid #222b36;
    background: #111821;
}

.logo-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    object-fit: cover;
    display: block;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==================================================
   MY NAME & ID
================================================== */

.my-name {
    min-width: 145px;
    padding: 5px 10px;
    border: 1px solid #303a46;
    border-radius: 9px;
    background: linear-gradient(135deg, #151e29, #111821);
}

.my-name-label {
    color: #64748b;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.8px;
}

.my-name-value {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 700;
}

#myNameDisplay {
    max-width: 85px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.my-online-status {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #4ade80;
    font-size: 9px;
    font-weight: 600;
    white-space: nowrap;
}

.my-online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.65);
}

.my-id {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    border: 1px solid #303a46;
    border-radius: 8px;
    background: #0d1117;
}

.my-id span {
    color: #64748b;
    font-size: 9px;
    font-weight: 700;
}

.my-id strong {
    color: #cbd5e1;
    font-family: monospace;
    font-size: 12px;
    letter-spacing: 1px;
}

#copyIdButton {
    border: 0;
    border-radius: 5px;
    padding: 4px 7px;
    background: #26303c;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 10px;
}

#copyIdButton:hover {
    background: #354252;
}

.name-change-button {
    padding: 8px 11px;
    border: 1px solid #303a46;
    border-radius: 8px;
    background: #171f29;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: 0.15s;
}

.name-change-button:hover {
    background: #242e3a;
    border-color: #6366f1;
    color: white;
}

.connection-status {
    color: #fbbf24;
    font-size: 12px;
    white-space: nowrap;
}

.notification-button {
    position: relative;
    width: 40px;
    height: 40px;
    border: 1px solid #303a46;
    border-radius: 9px;
    background: #171f29;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 16px;
}

.notification-button:hover {
    background: #222d3a;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
}

/* ==================================================
   MAIN & SIDEBAR
================================================== */

.app {
    height: calc(100vh - 64px);
    display: flex;
}

.sidebar {
    width: 270px;
    flex-shrink: 0;
    padding: 16px 12px;
    border-right: 1px solid #222b36;
    background: #111821;
    display: flex;
    flex-direction: column;
}

.sidebar-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    background: #0d1117;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid #222b36;
}

.sidebar-tab {
    flex: 1;
    padding: 6px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.15s;
    text-align: center;
}

.sidebar-tab.active {
    background: #1e293b;
    color: #ffffff;
}

.add-friend-button {
    width: 100%;
    margin-bottom: 8px;
    padding: 9px;
    border: 1px solid #303a46;
    border-radius: 8px;
    background: #171f29;
    color: #cbd5e1;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: 0.15s;
    text-align: center;
}

.add-friend-button:hover {
    background: #202b38;
    border-color: #6366f1;
    color: white;
}

.sidebar-sub-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.search-box-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-search-input {
    width: 100%;
    padding: 6px 9px;
    border: 1px solid #283340;
    border-radius: 6px;
    background: #0d1117;
    color: #f1f5f9;
    font-size: 11px;
    outline: none;
    transition: border-color 0.15s;
}

.sidebar-search-input:focus {
    border-color: #6366f1;
}

.global-mute-icon-btn {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
}

.global-mute-icon-btn:hover {
    color: #ffffff;
    transform: scale(1.08);
}

.global-mute-icon-btn.muted {
    color: #ef4444;
}

/* ==================================================
   FRIEND LIST & GROUP LIST
================================================== */

.friend-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.friend {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.12s;
    position: relative;
}

.friend:hover {
    background: #1b2530;
}

.friend.active {
    background: #242c49;
}

.friend-avatar-wrapper {
    position: relative;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.friend-avatar {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #273444;
    font-size: 16px;
}

.online-dot {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 9px;
    height: 9px;
    border: 2px solid #111821;
    border-radius: 50%;
    background: #64748b;
}

.online-dot.online {
    background: #22c55e;
    box-shadow: 0 0 7px rgba(34, 197, 94, 0.55);
}

.avatar-unread-badge {
    position: absolute;
    top: -3px;
    left: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5);
    z-index: 2;
}

.friend-info {
    flex: 1;
    min-width: 0;
}

.friend-name {
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-last-msg {
    margin-top: 2px;
    color: #64748b;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-mute-btn {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
    padding: 0;
}

.friend-mute-btn:hover {
    color: #94a3b8;
    transform: scale(1.1);
}

.friend-mute-btn.muted {
    color: #ef4444;
}

.empty-friends {
    padding: 30px 10px;
    color: #64748b;
    text-align: center;
    font-size: 12px;
    line-height: 1.8;
}

/* ==================================================
   CHAT
================================================== */

.chat {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0d1117;
}

.chat-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid #222b36;
}

.chat-user {
    display: flex;
    align-items: center;
    gap: 11px;
}

.chat-avatar {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #273444;
}

.chat-name {
    font-size: 16px;
    font-weight: 700;
}

.chat-status {
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
}

.call-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.call-button,
.hangup-button {
    padding: 9px 13px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: 0.15s;
}

.call-button {
    background: #1d9b61;
    color: white;
}

.call-button:hover {
    background: #24ad6e;
}

.call-button.add-member-btn {
    background: #4f46e5;
}

.call-button.add-member-btn:hover {
    background: #6366f1;
}

.call-button.join-call-btn {
    background: #ffffff;
    color: #0f172a;
    font-weight: 700;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
    animation: pulseJoinBtn 1.8s infinite;
}

@keyframes pulseJoinBtn {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.04);
    }
}

.hangup-button {
    background: #292f38;
    color: #cbd5e1;
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ==================================================
   MESSAGES
================================================== */

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.welcome-message {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #64748b;
    text-align: center;
}

.welcome-icon {
    width: 72px;
    height: 72px;
    margin-bottom: 18px;
    border-radius: 18px;
    object-fit: cover;
    display: block;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.welcome-message h2 {
    margin: 0 0 8px;
    color: #dbe4ef;
    font-size: 20px;
}

.welcome-message p {
    margin: 0;
    font-size: 13px;
}

.message {
    display: flex;
    margin-bottom: 16px;
}

.message.mine {
    justify-content: flex-end;
}

.message-content {
    max-width: min(600px, 70%);
    padding: 10px 13px;
    border-radius: 13px;
    background: #1a2430;
}

.message.mine .message-content {
    background: #4f51d8;
}

.message-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.message-author {
    margin-bottom: 0;
    color: #94a3b8;
    font-size: 11px;
}

.message-time {
    color: #64748b;
    font-size: 10px;
    font-family: monospace;
    white-space: nowrap;
}

.message.mine .message-time {
    color: rgba(255, 255, 255, 0.65);
}

.message-text {
    line-height: 1.5;
    font-size: 14px;
    word-break: break-word;
}

.system-message {
    margin: 15px 0;
    color: #64748b;
    text-align: center;
    font-size: 12px;
}

/* ==================================================
   MESSAGE INPUT
================================================== */

.message-input-area {
    display: flex;
    gap: 8px;
    padding: 15px 18px;
    border-top: 1px solid #222b36;
}

#messageInput {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid #303a46;
    border-radius: 9px;
    outline: none;
    background: #111821;
    color: white;
}

#sendButton {
    padding: 0 18px;
    border: 0;
    border-radius: 9px;
    background: #5b5cf0;
    color: white;
    font-weight: 600;
    cursor: pointer;
}

/* ==================================================
   MODAL
================================================== */

.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(3, 7, 12, 0.75);
    backdrop-filter: blur(7px);
}

.modal-card {
    position: relative;
    width: 390px;
    max-width: calc(100vw - 30px);
    padding: 28px;
    border: 1px solid #303b49;
    border-radius: 18px;
    background: #151e28;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.modal-card h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.modal-card p {
    margin: 0 0 20px;
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.6;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    font-size: 22px;
    cursor: pointer;
}

.modal-close:hover {
    background: #26303c;
    color: white;
}

.name-modal-card {
    width: 410px;
    text-align: left;
}

.name-modal-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.25);
    font-size: 21px;
}

.current-name-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 11px 13px;
    border: 1px solid #303a46;
    border-radius: 9px;
    background: #111821;
}

.current-name-box span {
    color: #64748b;
    font-size: 11px;
}

.current-name-box strong {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #e2e8f0;
    font-size: 13px;
}

.name-input,
.friend-id-input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #303a46;
    border-radius: 9px;
    outline: none;
    background: #0d1117;
    color: white;
    font-size: 14px;
}

.confirm-name-button,
.confirm-friend-button {
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    border: 0;
    border-radius: 9px;
    background: linear-gradient(135deg, #5b5cf0, #764df0);
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: 0.15s;
}

.name-change-message,
.friend-add-message {
    min-height: 20px;
    margin-top: 9px;
    color: #ef6b6b;
    font-size: 12px;
    text-align: center;
}

.member-select-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #111821;
    border: 1px solid #222b36;
    cursor: pointer;
    transition: 0.15s;
}

.member-select-item:hover {
    background: #1a2332;
}

/* ==================================================
   REQUEST
================================================== */

.request-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.request-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid #303a46;
    border-radius: 10px;
    background: #111821;
}

.request-avatar {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    background: #273444;
}

.request-info {
    flex: 1;
    min-width: 0;
}

.request-name {
    font-size: 13px;
    font-weight: 700;
}

.request-id {
    margin-top: 3px;
    color: #64748b;
    font-family: monospace;
    font-size: 10px;
}

.request-actions {
    display: flex;
    gap: 5px;
}

.request-actions button {
    padding: 7px 9px;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.accept-button {
    background: #22c55e;
    color: white;
}

.reject-button {
    background: #303946;
    color: #cbd5e1;
}

/* ==================================================
   CONTEXT MENU
================================================== */

.friend-menu {
    position: fixed;
    z-index: 500;
    width: 190px;
    padding: 5px;
    border: 1px solid #303b49;
    border-radius: 10px;
    background: #151e28;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.45);
}

.friend-menu button {
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #cbd5e1;
    text-align: left;
    cursor: pointer;
    font-size: 12px;
}

.friend-menu button:hover {
    background: #242e3a;
}

.friend-menu .danger {
    color: #f87171;
}

.menu-divider {
    height: 1px;
    margin: 4px 0;
    background: #303a46;
}

/* ==================================================
   CALL
================================================== */

.call-panel {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(3, 7, 12, 0.85);
    backdrop-filter: blur(10px);
}

.call-card {
    width: 320px;
    padding: 32px 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    background: #0f172a;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
    color: #ffffff;
}

.call-avatar {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 36px;
    color: #ffffff;
}

.call-name {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
}

.call-timer {
    margin-top: 8px;
    color: #94a3b8;
    font-family: monospace;
}

.call-status {
    margin-top: 7px;
    color: #94a3b8;
    font-size: 13px;
}

.panel-hangup {
    width: 100%;
    margin-top: 24px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
    transition: 0.15s;
}

.panel-hangup:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* ==================================================
   INCOMING CALL
================================================== */

.incoming-call-card {
    width: 360px;
    padding: 34px 28px 28px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: #0f172a;
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.8);
    animation: incomingCallAppear 0.25s ease-out;
}

@keyframes incomingCallAppear {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.incoming-call-glow {
    width: 84px;
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.35);
    font-size: 34px;
    animation: incomingCallPulse 1.5s ease-in-out infinite;
}

@keyframes incomingCallPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.call-small-title {
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.incoming-call-card .call-name {
    margin-top: 8px;
    font-size: 21px;
    color: #ffffff;
}

.incoming-call-card .call-status {
    margin-top: 8px;
    color: #94a3b8;
    line-height: 1.5;
}

.incoming-call-actions {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 26px;
}

.accept-call-button,
.reject-call-button {
    width: 74px;
    height: 74px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: transform 0.15s, filter 0.15s, background 0.15s;
}

.accept-call-button {
    background: #ffffff;
    color: #0f172a;
    border: none;
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.3);
}

.accept-call-button:hover {
    transform: scale(1.06);
    filter: brightness(0.95);
}

.reject-call-button {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.reject-call-button:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: scale(1.06);
}

.accept-call-button span,
.reject-call-button span {
    font-size: 10px;
    font-weight: 700;
}

/* ==================================================
   FACE MESH
================================================== */

.friend-face-mesh-container {
    position: relative;
    width: 180px;
    height: 120px;
    margin-top: 8px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 12px;
    background: #0f172a;
    border: 1px solid rgba(96, 165, 250, 0.4);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.friend-face-mesh-container canvas {
    display: block;
    width: 180px;
    height: 120px;
}

.friend-face-mesh-label {
    position: absolute;
    top: 6px;
    left: 7px;
    padding: 3px 6px;
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.78);
    color: #93c5fd;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    pointer-events: none;
}