/* assets/style.css */

/* ریست ساده */
* {
box-sizing: border-box;
}

html, body {
margin: 0;
padding: 0;
}

body {
font-family: -apple-system, BlinkMacSystemFont, "IRANSans", "Segoe UI", sans-serif;
background: linear-gradient(135deg, #f0f4ff, #e6f7ff);
color: #222;
}

/* دکمه‌ها و المان‌های عمومی */

a {
text-decoration: none;
color: inherit;
}

.btn-primary {
background: #4c6fff;
color: #fff;
border: none;
border-radius: 8px;
padding: 8px 16px;
cursor: pointer;
font-size: 14px;
transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s ease;
}

.btn-primary:hover {
background: #3954d7;
box-shadow: 0 4px 10px rgba(76, 111, 255, 0.3);
transform: translateY(-1px);
}

.btn-primary:disabled {
opacity: 0.5;
cursor: default;
box-shadow: none;
transform: none;
}

.btn-small {
font-size: 13px;
padding: 6px 10px;
margin-top: 6px;
}

.btn-link {
display: inline-block;
margin-top: 10px;
font-size: 13px;
color: #4c6fff;
}

.icon-button {
border: none;
background: transparent;
font-size: 20px;
cursor: pointer;
padding: 4px 8px;
}

.icon-button.small {
font-size: 14px;
}

.icon-button:disabled {
opacity: 0.4;
cursor: default;
}

/* پیام‌های خطا/موفقیت */

.alert {
padding: 8px 10px;
border-radius: 6px;
font-size: 13px;
margin-bottom: 10px;
}

.alert-error {
background: #ffe5e5;
color: #c62828;
}

.alert-success {
background: #e5ffe9;
color: #2e7d32;
}

/* صفحه لاگین/ثبت نام */

.auth-body {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}

.auth-container {
width: 100%;
max-width: 420px;
padding: 16px;
}

.auth-card {
background: #ffffff;
border-radius: 16px;
box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
padding: 24px 24px 28px;
}

.app-logo {
text-align: center;
margin: 0 0 8px;
font-size: 24px;
font-weight: 700;
color: #1d3cff;
}

.auth-subtitle {
text-align: center;
margin: 0 0 18px;
font-size: 13px;
color: #555;
}

.auth-tabs {
display: flex;
gap: 8px;
margin-bottom: 16px;
background: #f3f4ff;
padding: 4px;
border-radius: 999px;
}

.auth-tab-button {
flex: 1;
border-radius: 999px;
border: none;
padding: 8px 0;
font-size: 14px;
cursor: pointer;
background: transparent;
transition: background 0.2s, color 0.2s;
}

.auth-tab-button.active {
background: #ffffff;
color: #1d3cff;
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.auth-form {
display: flex;
flex-direction: column;
gap: 10px;
}

.auth-form label {
font-size: 13px;
color: #444;
display: flex;
flex-direction: column;
gap: 4px;
}

.auth-form input[type="text"],
.auth-form input[type="password"],
.auth-form input[type="file"] {
padding: 8px 10px;
border-radius: 8px;
border: 1px solid #d0d7ff;
outline: none;
font-size: 14px;
}

.auth-form input:focus {
border-color: #4c6fff;
box-shadow: 0 0 0 2px rgba(76, 111, 255, 0.2);
}

.hidden {
display: none !important;
}

/* صفحه پروفایل */

.profile-avatar-preview img {
width: 72px;
height: 72px;
object-fit: cover;
border-radius: 50%;
margin-top: 8px;
}

/* اپلیکیشن اصلی */

.app-body {
min-height: 100vh;
}

.app-container {
display: flex;
flex-direction: column;
height: 100vh;
max-height: 100vh;
}

.app-header {
height: 56px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 12px;
background: linear-gradient(135deg, #1d3cff, #4c6fff);
color: #fff;
}

.app-title {
font-weight: 600;
font-size: 18px;
}

.header-right {
display: flex;
align-items: center;
gap: 4px;
}

.logout-link {
font-size: 18px;
}

/* محیط اصلی */

.app-main {
flex: 1;
display: flex;
min-height: 0;
}

/* سایدبار */

.sidebar {
width: 260px;
background: #ffffff;
border-left: 1px solid #e2e8ff;
padding: 12px;
display: flex;
flex-direction: column;
gap: 10px;
}

.profile-summary {
display: flex;
gap: 10px;
align-items: center;
margin-bottom: 6px;
}

.avatar-wrapper img {
width: 44px;
height: 44px;
border-radius: 50%;
object-fit: cover;
}

.avatar-placeholder {
width: 44px;
height: 44px;
border-radius: 50%;
background: #4c6fff;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-weight: 600;
}

.profile-text {
display: flex;
flex-direction: column;
gap: 2px;
}

.profile-name {
font-size: 14px;
font-weight: 600;
}

.profile-handle {
font-size: 12px;
color: #555;
}

.badge-admin {
display: inline-block;
padding: 2px 6px;
border-radius: 999px;
font-size: 11px;
background: #ffebee;
color: #c62828;
margin-top: 2px;
}

/* لیست چت */

.chat-list {
flex: 1;
display: flex;
flex-direction: column;
gap: 6px;
margin-top: 6px;
}

.chat-list-title {
font-size: 13px;
color: #777;
margin-bottom: 4px;
}

#chat-list-ul {
list-style: none;
padding: 0;
margin: 0;
overflow-y: auto;
}

.chat-item {
padding: 8px 10px;
border-radius: 10px;
cursor: pointer;
margin-bottom: 4px;
background: #f5f6ff;
display: flex;
flex-direction: column;
gap: 2px;
transition: background 0.15s, transform 0.05s;
}

.chat-item:hover {
background: #e7e9ff;
transform: translateY(-1px);
}

.chat-item.active {
background: #4c6fff;
color: #fff;
}

.chat-item-name {
font-size: 14px;
font-weight: 500;
}

.chat-item-type {
font-size: 11px;
opacity: 0.8;
}

/* پنل چت */

.chat-pane {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
background: linear-gradient(135deg, #f4f7ff, #f9fbff);
}

.chat-header {
height: 56px;
border-bottom: 1px solid #e2e8ff;
padding: 8px 12px;
display: flex;
align-items: center;
}

.chat-header-main {
display: flex;
flex-direction: column;
}

.chat-title {
font-size: 15px;
font-weight: 600;
}

.chat-subtitle {
font-size: 12px;
color: #666;
}

/* پیام‌ها */

.messages-container {
flex: 1;
overflow-y: auto;
padding: 10px 12px;
display: flex;
flex-direction: column;
gap: 6px;
}

.message {
max-width: 80%;
padding: 6px 8px;
border-radius: 10px;
font-size: 13px;
box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
background: #ffffff;
display: flex;
flex-direction: column;
gap: 2px;
}

.message.mine {
margin-left: auto;
background: #d7f8d0;
}

.message.other {
margin-right: auto;
background: #ffffff;
}

.message.admin {
border-right: 4px solid #ff5252;
background: #ffecec;
}

.message.deleted {
opacity: 0.7;
font-style: italic;
}

.message-header {
display: flex;
justify-content: space-between;
font-size: 11px;
color: #555;
}

.message-sender {
font-weight: 500;
}

.message-time {
font-size: 10px;
}

.message-body {
font-size: 13px;
color: #222;
}

.message-reply-preview {
font-size: 11px;
color: #555;
border-right: 2px solid #4c6fff;
padding-right: 6px;
margin-bottom: 2px;
}

.message-text {
word-wrap: break-word;
}

.message-footer {
display: flex;
justify-content: flex-end;
font-size: 10px;
color: #555;
}

.message-status {
margin-right: 4px;
}

/* پیام mention در سیو مسیج */

.mention-message {
border: 1px dashed #4c6fff;
background: #ecf3ff;
cursor: pointer;
}

/* مدیا داخل پیام */

.message-media {
display: block;
margin-top: 4px;
border-radius: 8px;
}

.message-media.image {
max-width: 100%;
height: auto;
}

.message-media.video {
width: 100%;
max-height: 260px;
}

.message-media.audio {
width: 100%;
margin-top: 6px;
}

.message-media.file {
font-size: 13px;
color: #1d3cff;
text-decoration: underline;
}

/* وویس با UI شبیه تلگرام */

.voice-wrapper {
display: flex;
align-items: center;
gap: 8px;
background: rgba(255, 255, 255, 0.9);
border-radius: 999px;
padding: 4px 10px;
margin-top: 2px;
}

.message.mine .voice-wrapper {
background: rgba(255, 255, 255, 0.8);
}

.voice-play {
border: none;
background: #4c6fff;
color: #fff;
width: 28px;
height: 28px;
border-radius: 999px;
font-size: 14px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}

.voice-play.playing {
background: #c62828;
}

.voice-progress {
flex: 1;
height: 4px;
background: rgba(0, 0, 0, 0.12);
border-radius: 999px;
overflow: hidden;
}

.voice-progress-fill {
height: 100%;
width: 0;
background: #4c6fff;
}

.voice-duration {
font-size: 11px;
color: #444;
min-width: 40px;
text-align: left;
}

/* کامپوزر */

.composer {
border-top: 1px solid #e2e8ff;
padding: 8px;
display: flex;
flex-direction: column;
gap: 6px;
}

.composer-toolbar {
display: flex;
align-items: center;
gap: 4px;
margin-bottom: 2px;
}

.composer-toolbar .icon-button {
font-size: 20px;
}

/* اندیکاتور ضبط وویس */

.recording-indicator {
display: flex;
align-items: center;
gap: 6px;
font-size: 12px;
color: #c62828;
margin-bottom: 2px;
padding: 2px 6px;
border-radius: 8px;
background: rgba(254, 226, 226, 0.8);
}

.recording-indicator .dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #c62828;
animation: pulse-dot 1s infinite;
}

.recording-indicator.cancel {
background: rgba(254, 202, 202, 0.95);
color: #b71c1c;
}

.icon-button.recording {
color: #c62828;
}

@keyframes pulse-dot {
0% { opacity: 1; transform: scale(1); }
50% { opacity: 0.3; transform: scale(1.3); }
100% { opacity: 1; transform: scale(1); }
}

#message-input {
resize: none;
min-height: 52px;
max-height: 120px;
border-radius: 10px;
border: 1px solid #d0d7ff;
padding: 8px 10px;
font-size: 14px;
outline: none;
}

#message-input:focus {
border-color: #4c6fff;
box-shadow: 0 0 0 2px rgba(76, 111, 255, 0.15);
}

.reply-preview {
display: flex;
align-items: center;
justify-content: space-between;
background: #eef2ff;
border-radius: 8px;
padding: 4px 8px;
font-size: 12px;
}

/* منوی پیام (کانتکست) */

.context-menu {
position: absolute;
background: #ffffff;
border-radius: 8px;
box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
padding: 4px;
display: flex;
flex-direction: column;
z-index: 1000;
}

.context-menu button {
border: none;
background: transparent;
text-align: right;
padding: 6px 10px;
font-size: 13px;
cursor: pointer;
}

.context-menu button:hover {
background: #f1f3ff;
}

/* مودال پروفایل */

.modal {
position: fixed;
inset: 0;
background: rgba(15, 23, 42, 0.4);
display: flex;
align-items: center;
justify-content: center;
z-index: 1500;
}

.modal.hidden {
display: none !important;
}

.modal-content {
background: #ffffff;
border-radius: 16px;
padding: 16px;
width: 90%;
max-width: 360px;
position: relative;
box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
}

.modal-close {
position: absolute;
left: 8px;
top: 8px;
border: none;
background: transparent;
font-size: 20px;
cursor: pointer;
}

.profile-modal-header {
display: flex;
gap: 10px;
align-items: center;
margin-bottom: 12px;
}

.profile-modal-avatar {
width: 64px;
height: 64px;
border-radius: 50%;
object-fit: cover;
}

.profile-modal-avatar.placeholder {
background: #4c6fff;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-weight: 600;
}

.profile-modal-text {
display: flex;
flex-direction: column;
gap: 2px;
}

.profile-modal-name {
font-size: 15px;
font-weight: 600;
}

.profile-modal-handle {
font-size: 13px;
color: #555;
}

.profile-modal-lastseen {
font-size: 12px;
color: #777;
}

.profile-modal-actions {
display: flex;
justify-content: flex-start;
}

/* ریسپانسیو */

@media (max-width: 768px) {
.sidebar {
position: fixed;
top: 56px;
bottom: 0;
right: 0;
z-index: 1200;
transform: translateX(100%);
transition: transform 0.25s ease;
box-shadow: -4px 0 16px rgba(15, 23, 42, 0.25);
}

.sidebar.open {
transform: translateX(0);
}

.app-main {
flex-direction: column;
}

.chat-pane {
flex: 1;
}

.message {
max-width: 86%;
}
}