@font-face {
    font-family: iranSans;
    src: url(/static/IRANSansXV.woff2) format("woff2");
    font-display: swap;
    font-weight: 100 900;
    font-style: normal;
}

:root {
    --bg-color: #17212b;
    --sidebar-bg: #0e1621;
    --chat-bg: #0e1621;
    --msg-in: #182533;
    --msg-out: #2b5278;
    --text-primary: #f5f5f5;
    --text-secondary: #7f91a4;
    --accent: #5288c1;
    --border: #101921;
    --height: 100svh;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "iranSans";
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    scroll-behavior: smooth;
}

body {
    background: var(--bg-color);
    color: var(--text-primary);
    height: var(--height);
    overflow: hidden;
}

@media (min-width: 768px) {
    .app-container {
        display: flex;
        height: 100vh;
    }
}

/* Login Modal */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--height);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(1rem);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-box {
    background: var(--sidebar-bg);
    padding: 30px;
    border-radius: 10px;
    width: 300px;
    text-align: center;
}

.login-box button {
    width: 100%;
}

.login-box.loading {
    opacity: 0.5;
    pointer-events: none;
}

input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    background: var(--bg-color);
    border: 1px solid var(--border);
    color: white;
    border-radius: 15px;
    outline: none;
}

:is(button, .btn) {
    appearance: none;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    transition: transform 250ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none;
}

:is(button, .btn).ghost {
    background: transparent;
}

:is(button, .btn):hover {
    transform: scale(1.05);
}

:is(button, .btn):active {
    transform: scale(0.95);
}

#emoji-box {
    display: none;
    z-index: 5;
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background: var(--sidebar-bg);
    flex-wrap: wrap;
    align-items: center;
    padding: 1rem;
    gap: 0.1rem;
    max-width: 300px;
    /* فاصله بین نوار ایموجی و input-area */
}

#emoji-box.active {
    display: flex;
}

#emoji-box span {
    font-family: "icons";
    /* فاصله بین ایموجی‌ها */
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 5px;
}

#emoji-box span:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.send-button i {
    transform: rotate(0);
    transition: transform 250ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

:is(.send-button:hover, .send-button:active) i {
    transform: rotate(-90deg);
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    flex-direction: column;
    padding: 15px;
    padding-bottom: 0;
    border-bottom: 1px solid var(--border);
    font-weight: bold;
}

.user-list {
    flex: 1;
    overflow-y: auto;
}

.user-item {
    padding: 15px;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    overflow: hidden;
}

.user-item:hover {
    background: #202b36;
}

.user-item.active {
    background: #213d59;
}

.user-item.active {
    pointer-events: none;
}

.user-item.private .user-avatar {
    border-radius: 99999px;
}

.user-item .user-data {
    display: flex;
    align-items: center;
    flex: 1;
}

.user-item .user-details {
    flex: 1;
    display: grid;
}

.user-item .user-name {
    text-transform: capitalize;
}

.user-item .user-last-message {
    color: var(--text-secondary);
    size: 0.25rem;
    height: 1.3rem;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.user-avatar {
    color: var(--text-primary);
    width: 3rem;
    height: 3rem;
    background: var(--accent);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-left: 10px;
    position: relative;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 1rem;
}

.user-item.private .avatar-img {
    border-radius: 99999px;
}

.user-avatar::after {
    content: " ";
    opacity: var(--online);
    width: 0.75em;
    height: 0.75rem;
    background-color: rgb(15, 190, 60);
    position: absolute;
    bottom: -0.1rem;
    left: -0.1rem;
    border-radius: 9999px;
    outline: 2px var(--sidebar-bg) solid;
    transition: opacity 350ms ease-in-out;
}

.unread-badge {
    background: #ff5252;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 12px;
    display: inline-block;
}

.online-badge {
    background: #0ddd6400;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 12px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    max-height: 100svh;
    flex-direction: column;
    background: var(--bg-color);
}

.chat-header {
    padding: 15px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid black;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 2;
}

#pin-header {
    z-index: 1;
    position: absolute;
    width: 100%;
    padding: 15px;
    background: rgba(100, 100, 100, 0.5);
    backdrop-filter: blur(1rem);
    border-bottom: 1px solid black;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transform: translateY(var(--translateY));
    transition: transform 500ms ease-in-out;
    gap: 0.5rem;
}

.pin-message {
    display: -webkit-box;
    line-clamp: 1;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
    flex: 1;
}

#pin-header.expanded .pin-message {
    line-clamp: none;
    -webkit-line-clamp: none;
}

#messages-container {
    overflow-x: hidden;
    overflow-y: scroll;
    flex: 1;
}

#messages {
    display: flex;
    min-height: 80svh;
    flex-direction: column;
    justify-content: end;
}

.message-row {
    width: 100%;
    display: flex;
    padding: 0.5rem 0.75rem;
}

.message-row.incoming {
    justify-content: flex-start;
}

.message-row.incoming + .message-row.incoming {
    padding-top: 0;
}

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

.message-row.outgoing + .message-row.outgoing {
    padding-top: 0;
}

.message {
    display: inline-block;
    max-width: 50vw;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    position: relative;
    line-height: 1.4;
    word-break: break-word;
    animation: slide-up 250ms ease-in-out;
    overflow: hidden;
}

.message.uploading {
    display: flex;
    padding: 1rem;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.message.uploading button {
    width: 100%;
}

.message-row:has(.message:target) {
    animation: bg-glow 2s ease-in;
}

.message.incoming {
    background: var(--msg-in);
    border-bottom-right-radius: 0;
}

.message.outgoing {
    background: var(--msg-out);
    border-bottom-left-radius: 0;
}

.message a:is(:not(.reply-msg, .btn)) {
    color: var(--accent);
}

.message blockquote {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    white-space: normal;
}

.message pre::before {
    content: "Code";
    position: absolute;
    top: -1rem;
}

.message pre {
    position: relative;
    border-top: rgba(100, 100, 100, 1) 1rem solid;
    padding: 0.5rem;
    overflow: auto;
}

.message code {
    padding: 0.1rem 0.25rem;
}

.message :is(code, pre) {
    background-color: rgba(50, 50, 50, 1);
    font-family: monospace;
}

.message table {
    border: 2px solid var(--text-secondary);

    border-collapse: collapse;
}

.message table :is(td, tr, th) {
    border: 1px solid var(--text-secondary);
    padding: 0.5rem 1rem;
    border-collapse: collapse;
}

.message :is(ul, ol) {
    margin-inline-start: 1rem;
}

/* استایل نام فرستنده با قابلیت کلیک */
.msg-sender {
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 4px;
    display: block;
    cursor: pointer;
    font-weight: bold;
}

.msg-sender:hover {
    text-decoration: underline;
}

.msg-footer {
    font-size: 10px;
    color: var(--text-secondary);
    float: left;
    margin-top: 5px;
    margin-right: 5px;
}

.msg {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.msg-image {
    width: calc(100% + 1.5rem);
    margin: -0.75rem;
    margin-bottom: 0;
    min-height: 2rem;
}

.msg-image img {
    aspect-ratio: var(--aspect-ratio);
    width: var(--width);
}

.message.incoming .msg-image {
    margin-top: 0;
}

.message img {
    max-width: 100%;
    max-height: 30rem;
    object-fit: contain;
}

@media (min-width: 769px) {
    .back-btn {
        display: none;
    }
}

#replit-bar {
    position: relative;
    width: 100%;
    bottom: -1rem;
    background: rgba(100, 100, 100, 0.65);
    border-radius: 1rem 1rem 0 0;
    backdrop-filter: blur(1rem);
    display: flex;
    padding: 1rem;
    padding-bottom: 2rem;
    flex-direction: row-reverse;
    justify-content: space-between;
    transform: translateY(0);
    filter: blur(0);
    opacity: 1;
    transition: all 500ms ease-in-out;
}

#replit-bar.closed {
    transform: translateY(50%);
    filter: blur(0.5rem);
    opacity: 0.2;
}

#replit-bar a {
    color: var(--accent);
}

.hide {
    display: none !important;
}

.pointer {
    cursor: pointer;
}

.reply-msg {
    border-right: 3px solid gray;
    display: flex;
    gap: 2;
    font-size: small;
    margin-bottom: 3px;
    flex-direction: column;
    background: #151c247a;
    color: var(--text-secondary);
    border-radius: 5px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 8px;
    margin-right: -7px;
    margin-bottom: 6px;
    text-decoration: none;
}

.reply-msg span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    width: 95%;
}

.toggle-mute {
    width: auto;
    margin-right: 15px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
}

:has(.toggle-mute.active) .user-item.group .unread-badge {
    background-color: rgba(100, 100, 100, 1);
}

.input-box-holder {
    position: sticky;
    bottom: 0;
    padding: 0.5rem;
    width: 100%;
}

#input-box {
    width: calc(100%);
    z-index: 2;
    bottom: 0;
    padding: 1rem;
    display: flex;
    backdrop-filter: blur(1rem);
    gap: 0.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(100, 100, 100, 0.2);
    position: relative;
    overflow: hidden;
    resize: none;
}

#input-box button {
    padding: 0.7rem;
    height: fit-content;
}

#input-box::after {
    content: "بنداز توش :D";
    text-align: center;
    align-content: center;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    position: absolute;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    filter: blur(1rem);
    pointer-events: none;
    transition: all 450ms ease-in-out;
}

#input-box.dragover::after {
    opacity: 1;
    filter: blur(0);
    pointer-events: auto;
}

.input-text {
    background: transparent;
    flex: 1;
    padding: 0.5rem 0.5rem;
    border: none;
    color: white;
    border-radius: 15px;
    outline: none;
    min-width: none;
}

@media (max-width: 480px) {
    button {
        width: 46px;
        padding: 12px;
        color: white;
        border: none;
        border-radius: 15px;
        cursor: pointer;
        height: 43px;
    }

    #input-box {
        gap: 0.1rem;
    }

    .emoji-bar {
        display: flex;
        align-items: center;
        margin: 5px 5px 0px 5px;
        padding: 9px;
        border-radius: 9px;
        width: auto;
        justify-content: space-around;
    }

    input {
        border-radius: 15px;
    }
}

#pin-chat.active {
    background-color: rgb(200, 50, 50);
}

.actions-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.relative {
    position: relative;
}

#scroll-to-bottom {
    background-color: rgba(255, 255, 255, 0.1);
    border: rgba(255, 255, 255, 0.2) 1px solid;
    backdrop-filter: blur(2rem);
    width: 3rem;
    height: 3rem;
    border-radius: 99999px;
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    transition: all 500ms ease-in-out;
    opacity: 1;
    filter: blur(0);
}

#scroll-to-bottom.hidden {
    opacity: 0;
    filter: blur(1rem);
    pointer-events: none;
}

.noselect {
    user-select: none;
}
.pinMessage {
    display: flex;
    align-items: center;
}
.closeBtn {
    background: transparent;
}

#search-form {
    display: flex;
    background-color: rgba(100, 100, 100, 0.2);
    border: rgba(100, 100, 100, 0.5) 1px solid;
    margin: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
}

#search-form button {
    background: transparent;
    padding: 0.25rem;
}

#search-form input {
    background: transparent;
    margin: 0;
    border: none;
}

#context-menu {
    position: fixed;
    width: 80vw;
    max-width: 250px;
    top: 0;
    left: 0;
    min-height: 1rem;
    background-color: red;
    opacity: 0;
}

#modal {
    position: fixed;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100svh;
    width: 100vw;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: all 600ms ease-in-out;
}

#modal.open {
    opacity: 1;
    pointer-events: auto;
}

#modal .modal-window {
    transform: translateY(100%);
    width: 95vw;
    min-height: 50vh;
    max-width: 500px;
    background-color: rgba(100, 100, 100, 0.75);
    backdrop-filter: blur(1rem);
    border-radius: 1rem;
    padding: 1rem;
    transition: transform 300ms ease-out;
}

#modal.open .modal-window {
    transform: translateY(0);
}

#modal .modal-window .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#modal .modal-window .modal-header .modal-title {
    font-size: 1.5rem;
    font-weight: bold;
}

#modal .modal-window .modal-header #modal-close {
    background-color: rgb(200, 50, 50);
    width: 1rem;
    height: 2rem;
}

#modal .modal-window #modal-content-container {
    max-height: 80svh;
    overflow: auto;
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        width: 100%;
        height: 100%;
        z-index: 10;
        transform: translateX(100%);
        transition: 0.3s;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .back-btn {
        display: flex;
        margin-left: 10px;
        cursor: pointer;
    }

    .message {
        max-width: 90vw;
    }

    .toggle-mute span {
        display: none;
    }
}

@keyframes slide-up {
    from {
        filter: blur(0.5rem);
        opacity: 0.5;
        transform: translateY(1rem);
    }
    to {
        filter: blur(0);
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    animation: fade-in 150ms ease-out;
}

.header-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 99999px;
}

.chat-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.chat-title {
    font-weight: bold;
}

.chat-status {
    font-size: 11px;
    color: var(--text-secondary);
    padding-top: 0.2rem;
}

.member-list-item {
    padding: 0.25rem 1rem;
    border-bottom: 1px rgba(255, 255, 255, 0.1) solid;
}

.member-list-item:last-child {
    border-bottom: none;
}

@keyframes fade-in {
    from {
        filter: blur(0.5rem);
        opacity: 0.5;
    }
    to {
        filter: blur(0);
        opacity: 1;
    }
}

@keyframes bg-glow {
    0% {
        background-color: rgba(100, 100, 100, 0);
    }
    30% {
        background-color: rgba(100, 100, 100, 0.2);
    }
    100% {
        background-color: rgba(100, 100, 100, 0);
    }
}

@media (prefers-reduced-motion) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
