@font-face {
    font-family: "Vazirmatn";
    src: url("/assets/Vazirmatn-Regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Vazirmatn";
    src: url("/assets/Vazirmatn-Bold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: "Font Awesome 6 Free Solid";
    src: url("/assets/fontawesome.woff2") format("woff2");
    font-style: normal;
    font-weight: normal;
    font-display: block;
}

.fa-icon {
    font-family: "Font Awesome 6 Free Solid", sans-serif;
    font-style: normal;
    font-weight: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    font-family: "Vazirmatn", Tahoma, sans-serif;
    direction: rtl;
    background: #f1ede7;
    color: #1c1c21;
}

#root,
.app-root {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.messenger {
    display: flex;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.nav-rail {
    width: 76px;
    background: #f6f7f8;
    border-left: 1px solid #e0e2e8;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 8px;
    flex-shrink: 0;
    min-height: 0;
}

.nav-rail-top {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.nav-rail-items {
    display: flex;
    flex-direction: column;
    gap: 17px;
    align-items: stretch;
}

.nav-rail-spacer {
    flex: 1;
    min-height: 12px;
}

.nav-rail-item {
    width: 100%;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #8c8c94;
    cursor: pointer;
    padding: 6px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-family: inherit;
}

.nav-rail-item:hover {
    background: rgba(99, 102, 241, 0.08);
}

.nav-rail-item.active {
    background: rgba(99, 102, 241, 0.14);
    color: #6366f1;
}

.nav-rail-icon {
    font-size: 17px;
    line-height: 1;
}

.nav-rail-label {
    font-size: 9px;
    line-height: 1.2;
    text-align: center;
}

.list-placeholder {
    padding: 40px 20px;
    text-align: center;
    color: #8c8c94;
}

.list-placeholder-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    color: #c4c4cc;
}

.list-placeholder p {
    margin: 0;
    font-size: 14px;
}

.list-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.list-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e2e8;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: list-spinner-spin 0.75s linear infinite;
}

@keyframes list-spinner-spin {
    to {
        transform: rotate(360deg);
    }
}

.settings-panel .settings-body {
    flex: 1;
    padding: 20px 16px;
    overflow-y: auto;
}

.settings-hint {
    color: #8c8c94;
    font-size: 14px;
    margin: 0 0 20px;
    line-height: 1.6;
}

.settings-logout-btn {
    width: 100%;
    border: none;
    border-radius: 12px;
    background: #6366f1;
    color: #fff;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.settings-logout-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.logout-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: #f1ede7;
}

.header-icon-btn {
    border: none;
    background: #f6f7f8;
    color: #8c8c94;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    flex-shrink: 0;
}

.header-fa-icon {
    font-size: 16px;
    color: #8c8c94;
}

.chat-list-panel {
    width: 320px;
    background: #fff;
    border-left: 1px solid #e0e2e8;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.list-header {
    padding: 14px 16px;
    border-bottom: 1px solid #e0e2e8;
    background: #fff;
}
.list-header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}
.search {
    margin-top: 10px;
    width: 100%;
    border: none;
    background: #f6f7f8;
    border-radius: 10px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
}

.room-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.room-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    min-height: 56px;
    cursor: pointer;
    border: none;
    width: 100%;
    background: transparent;
    text-align: right;
    font-family: inherit;
}
.room-row:hover {
    background: #f8f8fa;
}
.room-row.active {
    background: #f0f0fc;
    position: relative;
}
.room-row.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #6366f1;
}
.avatar,
.nav-user-avatar,
.chat-header-avatar {
    border-radius: 50%;
    background: #6366f1;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}
.room-row .avatar {
    width: 44px;
    height: 44px;
}
.nav-user-avatar {
    width: 48px;
    height: 48px;
    margin-bottom: 4px;
    font-size: 18px;
}
.chat-header-avatar {
    width: 44px;
    height: 44px;
}
.avatar img,
.nav-user-avatar img,
.chat-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.avatar .initial,
.nav-user-avatar .initial,
.chat-header-avatar .initial {
    line-height: 1;
}
.room-meta {
    flex: 1;
    min-width: 0;
}
.room-meta .top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.room-meta .name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.room-meta .time {
    font-size: 12px;
    color: #8c8c94;
    flex-shrink: 0;
}
.room-meta .preview {
    font-size: 13px;
    color: #8c8c94;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: transparent;
}

.chat-body {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #f1ede7;
}

.chat-header {
    height: 66px;
    background: #fff;
    color: #1c1c21;
    border-bottom: 1px solid #e0e2e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.chat-header-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.chat-header-icon {
    border: none;
    background: transparent;
    color: #8c8c94;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.chat-header-icon:hover {
    background: rgba(99, 102, 241, 0.08);
}

.chat-header-icon .fa-icon {
    font-size: 16px;
    line-height: 1;
}

.chat-header .title {
    flex: 1;
    min-width: 0;
}
.chat-header .title h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #1c1c21;
}
.chat-header .title p {
    margin: 2px 0 0;
    font-size: 12px;
    color: #8c8c94;
}

.timeline {
    flex: 1;
    overflow-y: auto;
    padding: 12px 27px;
    padding-bottom: 95px;
    display: flex;
    flex-direction: column;
    background: transparent;
    gap: 8px;
    min-height: 0;
}

.timeline-hint {
    text-align: center;
    font-size: 12px;
    color: #8c8c94;
    padding: 8px 0;
    flex-shrink: 0;
}

.bubble-row {
    display: flex;
    width: 100%;
}
.bubble-row.mine {
    justify-content: flex-start;
}
.bubble-row.theirs {
    justify-content: flex-end;
}

.bubble {
    max-width: min(72%, 520px);
    padding: 10px 14px;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    position: relative;
}
.bubble.mine {
    background: #d0f1d5;
}
.bubble.theirs {
    background: #fff;
}
.bubble .text {
    font-size: 15px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}
.bubble .meta {
    display: flex;
    flex-direction: row;
    direction: ltr;
    justify-content: flex-start;
    align-items: center;
    gap: 4px;
    margin-top: 9px;
    font-size: 11px;
    color: #8c8c94;
}

.bubble .meta .time {
    line-height: 1;
}

.bubble .meta .tick {
    font-size: 11px;
    line-height: 1;
    flex-shrink: 0;
}

.bubble .meta .tick.sent {
    color: #8c8c94;
}

.bubble .meta .tick.read {
    color: #6366f1;
}
.bubble img {
    max-width: 280px;
    border-radius: 10px;
    display: block;
}

.composer-float {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    pointer-events: none;
    z-index: 2;
}

.composer-area {
    position: relative;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #e0e2e8;
    border-radius: 28px;
    margin: 0 20px 20px;
    min-height: 51px;
    pointer-events: auto;
}

.composer {
    min-height: 51px;
    padding: 4px 12px;
    display: flex;
    flex-direction: row;
    direction: ltr;
    gap: 6px;
    align-items: center;
    box-sizing: border-box;
}

.composer-icon {
    border: none;
    background: transparent;
    color: #8c8c94;
    cursor: pointer;
    padding: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-family: inherit;
}

.composer-icon:hover {
    background: rgba(99, 102, 241, 0.08);
}

.composer-icon .fa-icon {
    font-size: 18px;
    line-height: 1;
}

.composer-plus.active {
    color: #6366f1;
}

.composer-send {
    color: #6366f1;
}

.composer-send .fa-icon {
    font-size: 16px;
}

.composer-input {
    flex: 1;
    height: 38px;
    min-height: 38px;
    max-height: 192px;
    resize: none;
    overflow-y: hidden;
    border: none;
    background: transparent;
    border-radius: 0;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.45;
    direction: rtl;
    text-align: right;
    color: #1c1c21;
    box-sizing: border-box;
}

.composer-input:focus {
    outline: none;
}

.attach-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.attach-menu-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 14px;
    z-index: 10000;
    width: 220px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e0e2e8;
    border-radius: 14px;
    box-shadow: 0 -3px 14px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.login-screen {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1ede7;
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}
.login-card h1 {
    margin: 0 0 8px;
    font-size: 22px;
    text-align: center;
}
.login-card p {
    margin: 0 0 20px;
    text-align: center;
    color: #8c8c94;
    font-size: 14px;
}
.field {
    margin-bottom: 12px;
}
.field label {
    display: block;
    font-size: 13px;
    color: #8c8c94;
    margin-bottom: 6px;
}
.field input {
    width: 100%;
    border: 1px solid #e0e2e8;
    border-radius: 10px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 15px;
}
.login-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.auth-loading-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: #f1ede7;
    padding: 20px;
}

.auth-loading-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #1c1c21;
}

.auth-loading-text {
    margin: 0;
    font-size: 15px;
    color: #8c8c94;
}

.auth-progress {
    width: min(280px, 72vw);
    height: 7px;
    background: #e0e2e8;
    border-radius: 999px;
    overflow: hidden;
    direction: ltr;
}

.auth-progress-bar {
    width: 100%;
    height: 100%;
    background: #6366f1;
    border-radius: 999px;
    transform: scaleX(0);
    transform-origin: left center;
    animation: auth-progress-fill 2.8s ease-out forwards;
}

.logout-overlay .auth-progress-bar {
    animation-duration: 4s;
}

@keyframes auth-progress-fill {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

.btn {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary {
    background: #6366f1;
    color: #fff;
}
.btn-secondary {
    background: #f0f0fc;
    color: #6366f1;
}
.btn:disabled {
    opacity: 0.6;
    cursor: wait;
}
.error {
    color: #c0392b;
    font-size: 13px;
    margin-top: 10px;
    text-align: center;
}

.empty-chat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8c8c94;
    font-size: 15px;
}

.bubble-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.bubble-menu-panel {
    position: fixed;
    z-index: 10000;
    width: 175px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e0e2e8;
    border-radius: 14px;
    box-shadow: 0 -3px 14px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bubble-menu-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    min-height: 36px;
    padding: 6px 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    color: #1c1c21;
    cursor: pointer;
}

.bubble-menu-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.bubble-menu-item.destructive {
    color: #d94040;
}

.bubble-menu-item.destructive:hover {
    background: rgba(217, 64, 64, 0.1);
}

.bubble-menu-item.destructive .bubble-menu-icon {
    color: #d94040;
}

.bubble-menu-label {
    flex: 1;
    text-align: start;
}

.bubble-menu-icon {
    font-size: 16px;
    color: #6366f1;
    line-height: 1;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.bubble-menu-sep {
    height: 1px;
    margin: 6px 10px;
    background: #e8ebf0;
}

.hidden-input {
    display: none;
}
