@font-face {
    font-family: "IRANSansXFaNum";
    src: url("../../fonts/IRANSansXFaNum-regular.woff") format("woff");
    font-weight: 400;
}

@font-face {
    font-family: "IRANSansXFaNum";
    src: url("../../fonts/IRANSansXFaNum-bold.woff") format("woff");
    font-weight: 700;
}

:root {
    --radius-lg: 22px;
    --radius-md: 16px;
    --safe-bottom: env(safe-area-inset-bottom);
}

.theme-light {
    --app-bg: #f3f4f6;
    --panel-bg: #ffffff;
    --panel-soft: #f9fafb;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --primary: #2563eb;
    --primary-soft: #dbeafe;
    --danger: #dc2626;
    --chat-me-bg: #dcf8c6;
    --chat-other-bg: #ffffff;
    --input-bg: #ffffff;
}

.theme-dark {
    --app-bg: #0f172a;
    --panel-bg: #111827;
    --panel-soft: #1f2937;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --primary: #60a5fa;
    --primary-soft: #1e3a8a;
    --danger: #f87171;
    --chat-me-bg: #14532d;
    --chat-other-bg: #1f2937;
    --input-bg: #111827;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--app-bg);
    color: var(--text-main);
    font-family: "IRANSansXFaNum", Tahoma, sans-serif;
}

a {
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
}

.app-messages {
    position: fixed;
    top: 12px;
    right: 12px;
    left: 12px;
    z-index: 9999;
    max-width: 520px;
    margin: 0 auto;
}

.mobile-page,
.chat-room-page {
    width: 100%;
    max-width: 560px;
    min-height: 100vh;
    margin: 0 auto;
    background: var(--app-bg);
}

.app-header,
.room-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
}

.app-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.app-header span,
.room-title span {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-soft);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    font-size: 20px;
}

.chat-search-box,
.room-search {
    padding: 12px 16px;
    background: var(--panel-bg);
}

.chat-search-box input,
.room-search input {
    width: 100%;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-main);
    padding: 11px 16px;
    outline: none;
}

.chat-list {
    padding: 8px;
}

.chat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 18px;
    color: var(--text-main);
    background: transparent;
}

.chat-row:hover {
    background: var(--panel-soft);
    color: var(--text-main);
}

.saved-row {
    margin: 8px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
}

.chat-avatar,
.room-avatar,
.profile-avatar {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
}

.saved-avatar {
    background: var(--primary);
    color: #fff;
}

.chat-avatar img,
.room-avatar img,
.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-main {
    min-width: 0;
    flex: 1;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.chat-top,
.chat-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-top strong {
    font-size: 15px;
}

.chat-top small {
    color: var(--text-muted);
    font-size: 11px;
}

.chat-preview {
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 330px;
}

.unread-badge {
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    padding: 0 7px;
}

.empty-state,
.empty-chat {
    min-height: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    gap: 10px;
}

.empty-state i,
.empty-chat i {
    font-size: 42px;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card,
.settings-card {
    width: 100%;
    max-width: 440px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px;
    margin: 16px auto;
}

.auth-logo {
    width: 64px;
    height: 64px;
    border-radius: 22px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin-bottom: 16px;
}

.auth-card h1,
.settings-card h2 {
    font-size: 22px;
    margin: 0 0 8px;
}

.auth-card p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.auth-footer {
    margin-top: 18px;
    text-align: center;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    font-weight: 700;
}

.form-control,
.form-select {
    background-color: var(--input-bg);
    color: var(--text-main);
    border-color: var(--border-color);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--input-bg);
    color: var(--text-main);
}

.form-label {
    font-size: 13px;
    color: var(--text-muted);
}

.field-error,
.form-error {
    margin-top: 6px;
    color: var(--danger);
    font-size: 12px;
}

.form-hint {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

.app-btn {
    border-radius: 14px;
    padding: 11px 16px;
}

.room-header {
    justify-content: flex-start;
}

.room-title {
    min-width: 0;
    flex: 1;
}

.room-title strong {
    display: block;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messages-area {
    padding: 14px 12px 92px;
    min-height: calc(100vh - 170px);
}

.message-row {
    display: flex;
    margin-bottom: 10px;
}

.message-row.mine {
    justify-content: flex-start;
}

.message-row.other {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 82%;
    padding: 10px 12px;
    border-radius: 18px;
    background: var(--chat-other-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    position: relative;
}

.message-row.mine .message-bubble {
    background: var(--chat-me-bg);
}

.sender-name {
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}

.message-text {
    font-size: 14px;
    line-height: 1.8;
    word-break: break-word;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 5px;
    font-size: 10px;
    color: var(--text-muted);
}

.reply-preview,
.forward-label {
    display: block;
    border-right: 3px solid var(--primary);
    padding: 6px 8px;
    margin-bottom: 7px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.attachment-box {
    margin-top: 8px;
}

.chat-image {
    max-width: 100%;
    border-radius: 14px;
    display: block;
}

.chat-video {
    width: 100%;
    max-height: 260px;
    border-radius: 14px;
}

.chat-audio {
    width: 240px;
    max-width: 100%;
}

.file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    background: var(--panel-soft);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 12px;
}





.action-btn.danger {
    color: var(--danger);
}

.composer-wrapper {
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    max-width: 560px;
    margin: 0 auto;
    background: var(--panel-bg);
    border-top: 1px solid var(--border-color);
    padding-bottom: var(--safe-bottom);
}

.reply-compose-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: var(--panel-soft);
    border-bottom: 1px solid var(--border-color);
}

.reply-compose-preview div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.reply-compose-preview strong {
    font-size: 12px;
    color: var(--primary);
}

.reply-compose-preview span {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 420px;
}

.reply-compose-preview button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
}

.send-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-bg);
    padding: 10px 12px;
}

.send-box textarea {
    flex: 1;
    resize: none;
    max-height: 120px;
    border-radius: 18px;
}

.file-picker {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--panel-soft);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.file-picker input {
    display: none;
}

.send-btn {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-results-box {
    margin: 8px 12px;
    padding: 12px;
    border-radius: 14px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
}

.search-result-item {
    display: block;
    color: var(--text-main);
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.search-result-empty {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 8px;
}

.profile-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 22px;
}

.profile-avatar {
    width: 82px;
    height: 82px;
    font-size: 28px;
}

.profile-preview small {
    color: var(--text-muted);
}

.limit-box {
    display: grid;
    gap: 8px;
    padding: 12px;
    background: var(--panel-soft);
    border-radius: 14px;
    margin-bottom: 16px;
}

.limit-box div {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.limit-box span {
    color: var(--text-muted);
    font-size: 13px;
}

.limit-box strong {
    font-size: 13px;
}

.auth-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

@media (min-width: 700px) {
    .mobile-page,
    .chat-room-page {
        border-right: 1px solid var(--border-color);
        border-left: 1px solid var(--border-color);
    }
}


a.action-btn {
    text-decoration: none;
}

.forward-source-preview {
    background: var(--panel-soft);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px;
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.8;
}

.forward-target-form {
    margin: 0;
}

.forward-target-btn {
    width: 100%;
    border: 0;
    text-align: right;
    background: transparent;
    font-family: inherit;
}


.voice-btn {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: var(--panel-soft);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.voice-btn.recording {
    background: var(--danger);
    color: #fff;
    animation: voicePulse 1s infinite;
}

.voice-record-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: var(--panel-soft);
    border-bottom: 1px solid var(--border-color);
}

.voice-record-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.voice-record-info strong {
    font-size: 13px;
    color: var(--text-main);
}

.voice-record-info small {
    font-size: 12px;
    color: var(--text-muted);
    direction: ltr;
}

.voice-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    display: inline-block;
    animation: voiceBlink 1s infinite;
}

.voice-cancel-btn {
    border: 0;
    background: transparent;
    color: var(--danger);
    font-size: 13px;
    font-family: inherit;
}

@keyframes voicePulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes voiceBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.25;
    }
}



.older-loader-wrap {
    display: flex;
    justify-content: center;
    padding: 10px 0 16px;
}

.older-loader-btn {
    border: 1px solid var(--border-color);
    background: var(--panel-bg);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 12px;
    font-family: inherit;
}

.older-loader-btn:disabled {
    opacity: 0.7;
}



.message-context-menu {
    position: fixed;
    z-index: 99999;
    width: 180px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
    padding: 6px;
}

.message-context-menu button {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 11px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 13px;
    text-align: right;
}

.message-context-menu button:hover {
    background: var(--panel-soft);
}

.message-context-menu button.danger {
    color: var(--danger);
}

.message-context-menu button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.message-bubble {
    cursor: pointer;
    user-select: text;
}

.message-bubble a,
.message-bubble audio,
.message-bubble video {
    cursor: auto;
}


.message-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1;
}

.message-status.is-read {
    color: var(--primary);
}

.message-status i {
    line-height: 1;
}



.attachment-compose-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--panel-soft);
    border-bottom: 1px solid var(--border-color);
}

.attachment-compose-thumb {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex: 0 0 auto;
}

.attachment-compose-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-compose-info {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.attachment-compose-info strong {
    font-size: 13px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-compose-info span {
    font-size: 11px;
    color: var(--text-muted);
    direction: ltr;
    text-align: right;
}

.attachment-compose-preview button {
    border: 0;
    background: transparent;
    color: var(--danger);
    font-size: 16px;
}