:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --record-active-color: #ef4444;

    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --text-color: #e0e0e0;
    --border-color: #333;
    --message-sent-bg: var(--primary-color);
    --message-received-bg: #374151;
    --seen-color: #4ade80;

    --vh: 1vh;
    --kb: 0px;


    --glass-blur: 0px;
    --surface-color: rgba(255,255,255,0.1);
    --panel-color: rgba(255,255,255,0.12);
    --border-color: rgba(255,255,255,0.15);
    --shadow-color: rgba(0,0,0,0.25);
    --mica-tint: rgba(255,255,255,0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100 * var(--vh));
    padding: 10px;
    -webkit-tap-highlight-color: transparent;
}


/* پس‌زمینه مایکا/شیشه‌ای */
.glass-theme {
    background:
            radial-gradient(1200px 600px at 80% -10%, var(--mica-tint), transparent 60%),
            radial-gradient(1000px 500px at -10% 120%, var(--mica-tint), transparent 60%),
            var(--surface-color);
    backdrop-filter: blur(var(--glass-blur)) saturate(160%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
}

/* حالت تیره: رنگ‌های متن و لینک‌ها */
.dark-theme, .dark-theme body {
    color: var(--text-color);
}
.dark-theme a { color: var(--primary-color); }

/* کارت‌ها/پنل‌ها/باکس‌های گفتگو با افکت شیشه‌ای */
.dark-theme .card,
.dark-theme .chat-container,
.dark-theme .sidebar,
.dark-theme .toolbar,
.dark-theme .message-bubble,
.dark-theme .modal,
.dark-theme .panel {
    background: var(--panel-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px var(--shadow-color);
}

/* حباب پیام دریافتی (contrast نرم) */
.dark-theme .message-bubble.received {
    background: var(--message-received-bg);
}

/* دکمه‌ی اکسنت */
.dark-theme .btn-primary {
    background: var(--primary-color);
    border-color: transparent;
    color: #fff;
}
.dark-theme .btn-primary:hover { filter: brightness(1.06); }

/* فالبک برای مرورگرهای بدون backdrop-filter */
@supports not ((backdrop-filter: blur(10px))) {
    .glass-theme { background: #12161c; }
}

.app-container {
    width: 100%;
    max-width: 450px;
    height: 100%;
    max-height: 850px;
    display: flex;
    flex-direction: column;
    background: var(--surface-color);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

#login-view {
    padding: 40px;
    text-align: center;
}

#chat-view {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

h2 {
    margin-bottom: 25px;
    font-weight: 600;
    color: var(--primary-color);
}

input[type="password"], input[type="text"] {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-color);
    font-family: inherit;
    text-align: center;
    font-size: 1rem;
}

button {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: background-color .2s;
    font-family: inherit;
}

button:hover {
    background: var(--primary-hover);
}

#login-view button {
    margin-top: 20px;
}

#status-message {
    margin-top: 15px;
    height: 20px;
    color: #ef4444;
}

.chat-header {
    padding: 10px 20px;
    background-color: rgba(0, 0, 0, .2);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-info {
    text-align: right;
}

.chat-header h3 {
    margin: 0 0 5px 0;
    font-size: 1rem;
}

.chat-header #user-status-text {
    font-size: .8rem;
    color: #a0a0a0;
    font-weight: 300;
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

.message {
    position: relative;
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 80%;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    margin-top: 10px;
}

.message.sent {
    background: var(--message-sent-bg);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.received {
    background: var(--message-received-bg);
    color: var(--text-color);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-content {
    word-wrap: break-word;
}

.message-meta {
    font-size: .75rem;
    color: #a0a0a0;
    margin-top: 5px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 5px;
    user-select: none;
}

.message-status {
    font-weight: bold;
}

.message-status.seen, .seen {
    color: var(--seen-color);
}

.chat-media {
    border-radius: 10px;
    max-width: 100%;
    margin-top: 8px;
}

audio.chat-media {
    width: 100%;
    max-width: 250px;
}

.progress-container {
    margin-top: 8px;
    background: #555;
    border-radius: 5px;
    height: 8px;
    overflow: hidden;
}

.progress-bar {
    background: var(--seen-color);
    width: 0%;
    height: 100%;
    transition: width .2s;
}

#typing-indicator {
    color: #a0a0a0;
    font-style: italic;
    font-size: .9rem;
    padding: 0 20px 5px;
    height: 20px;
    opacity: 0;
    transition: opacity .3s;
}

#typing-indicator.active {
    opacity: 1;
}

#chat-input-area {
    display: flex;
    gap: 10px;
    padding: 10px 15px;
    align-items: center;
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
    flex-shrink: 0;
}

#message-input {
    flex-grow: 1;
    text-align: right;
    margin-bottom: 0;
}

.icon-btn {
    flex-shrink: 0;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    padding: 0;
    cursor: pointer;
    background: var(--primary-color);
    color: #fff;
    border: none;
    font-size: 1.2rem;
}

#record-btn.recording {
    background: var(--record-active-color);
}

#file-input {
    display: none;
}

.header-menu {
    position: relative;
    display: inline-block;
}

.menu-icon-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
}

.dropdown-content {
    display: none;
    position: absolute;
    background: var(--surface-color);
    min-width: 220px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, .2);
    z-index: 100;
    left: 0;
    border-radius: 8px;
    overflow: hidden;
}

.dropdown-content a {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    font-size: .9rem;
}

.dropdown-content a i {
    margin-left: 10px;
}

.dropdown-content a:hover {
    background: #374151;
}

.show {
    display: block;
}

.reply-preview-container {
    display: none;
    padding: 8px 15px;
    background: rgba(0, 0, 0, .2);
    border-top: 1px solid var(--border-color);
    align-items: center;
}

.reply-content {
    flex-grow: 1;
    border-right: 3px solid var(--primary-color);
    padding-right: 10px;
    overflow: hidden;
}

.reply-content strong {
    color: var(--primary-color);
    font-size: .9rem;
}

.reply-content p {
    font-size: .8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    color: #a0a0a0;
}

.cancel-reply-icon {
    background: none;
    border: none;
    color: #a0a0a0;
    cursor: pointer;
    width: auto;
    font-size: 1.2rem;
}

.quoted-reply {
    background: rgba(0, 0, 0, .2);
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 5px;
    border-right: 3px solid var(--seen-color);
    cursor: pointer;
}

.quoted-reply p {
    font-size: .8rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes highlight {
    from {
        background-color: rgba(74, 222, 128, .3);
    }
    to {
        background-color: transparent;
    }
}

.edit-textarea {
    width: 100%;
    background: #4b5563;
    color: var(--text-color);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    padding: 8px;
    font-family: inherit;
    resize: vertical;
    min-height: 50px;
}

.edit-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

.edit-buttons button {
    padding: 4px 12px;
    font-size: .8rem;
    width: auto;
}

.edit-save {
    background: #16a34a;
}

.edit-cancel {
    background: #6b7280;
}

.edited-label {
    font-style: italic;
    font-size: .7rem;
    opacity: .8;
}

body.swal2-shown > [aria-hidden="true"] {
    filter: blur(5px);
}

.swal2-popup {
    background: #1e1e1e !important;
    color: #e0e0e0 !important;
}

.swal2-title {
    color: #fff !important;
}

.swal2-html-container {
    color: #e0e0e0 !important;
}

#load-more-container {
    text-align: center;
    padding: 10px 0;
}

#load-more-btn {
    background: #374151;
    color: var(--text-color);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    width: auto;
}

#load-more-btn:hover {
    background: #4b5563;
}

#load-more-btn:disabled {
    background: #2b333e;
    cursor: not-allowed;
}

.message-media-container {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    margin-top: 10px;
    position: relative;
    padding-bottom: 20px;
}

.message-media-container.sent {
    align-self: flex-end;
}

.message-media-container.received {
    align-self: flex-start;
}

.chat-media {
    border-radius: 12px;
    max-width: 100%;
    display: block;
}

.chat-media.image {
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.chat-media.audio {
    width: 260px;
    height: 45px;
}

.video-thumb {
    width: 250px;
    height: 150px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.video-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, .5), transparent);
}

.video-thumb .fa-play {
    color: #fff;
    font-size: 2.5rem;
    z-index: 2;
    opacity: .8;
    transition: transform .2s;
}

.video-thumb:hover .fa-play {
    transform: scale(1.1);
    opacity: 1;
}

.file-link {
    background: var(--message-received-bg);
    padding: 10px 15px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-color);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.file-link i {
    font-size: 1.5rem;
}

.message-media-container .message-meta {
    position: absolute;
    bottom: 2px;
    right: 8px;
    background: rgba(0, 0, 0, .4);
    padding: 1px 6px;
    border-radius: 8px;
}

.message-media-container.received .message-meta {
    right: auto;
    left: 8px;
}

.form-input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
}

.message .chat-media.image,
.message-media-container .chat-media.image,
.message .chat-media.video,
.message-media-container video.chat-media {
    width: auto;
    /*max-width: min(75vw, 480px);*/
    max-width: 100%;
    height: auto;
    max-height: 60vh;
    object-fit: contain;
    display: block;
}

.message-container {
    touch-action: manipulation;
}


body {
    backdrop-filter: var(--blur, none);
    -webkit-backdrop-filter: var(--blur, none);
}

