/* style.css */
:root {
    /* متغیرهای رنگی - تم روشن (پیش‌فرض) */
    --bg-color: #f0f2f5;
    --sidebar-bg: #ffffff;
    --chat-bg: #e5ddd5;
    --chat-bg-pattern: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBvcGFjaXR5PSIwLjA1Ij48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjMDAwIi8+PC9zdmc+');
    --text-color: #333333;
    --text-secondary: #666666;
    --primary-color: #0088cc;
    --primary-hover: #006699;
    --message-out-bg: #dcf8c6;
    --message-in-bg: #ffffff;
    --border-color: #e0e0e0;
    --input-bg: #ffffff;
    --danger-color: #ff4444;
    --success-color: #00C851;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --modal-overlay: rgba(0, 0, 0, 0.5);

    /* فونت */
    --font-family: 'YekanBakh', sans-serif;
}

/* تم تاریک */
[data-theme="dark"] {
    --bg-color: #121212;
    --sidebar-bg: #1e1e1e;
    --chat-bg: #0b141a;
    --chat-bg-pattern: none;
    --text-color: #e0e0e0;
    --text-secondary: #aaaaaa;
    --primary-color: #3390ec;
    --primary-hover: #267fd6;
    --message-out-bg: #255c69;
    --message-in-bg: #182533;
    --border-color: #333333;
    --input-bg: #2c2c2c;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --modal-overlay: rgba(0, 0, 0, 0.8);
}

/* ریست و تنظیمات پایه */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    /* جلوگیری از اسکرول کلی صفحه */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* اسکرول بار سفارشی */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* کلاس‌های کاربردی */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.center {
    align-items: center;
    justify-content: center;
}

.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

/* دکمه‌ها و ورودی‌ها */
button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    color: inherit;
    transition: transform 0.1s;
}

button:active {
    transform: scale(0.95);
}

input,
textarea,
select,
option {
    font-family: inherit;
    border: none;
}

/* =========================================
   صفحه احراز هویت (Login/Register)
   ========================================= */
#auth-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-box {
    background: var(--sidebar-bg);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 400px;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.auth-box h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 1.2rem;
    text-align: right;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-input:focus {
    border-color: var(--primary-color);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1rem;
    margin-top: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.auth-switch {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--primary-color);
    text-decoration: underline;
}

/* =========================================
   رابط کاربری اصلی (App Layout)
   ========================================= */
#app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* --- سایدبار (لیست کاربران) --- */
aside {
    width: 350px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    /* ارتفاع کامل */
    position: relative;
    /* اضافه شد برای محدود کردن فوتر ابسولوت */
    z-index: 10;
    transition: transform 0.3s ease;
}

#user-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    /* مهم برای اسکرول فلکس */
    padding-bottom: 20px;
}

.sidebar-header {
    padding: 15px;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.user-profile-thumb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.search-box {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
}

.user-list {
    flex: 1;
    overflow-y: auto;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.user-item:hover,
.user-item.active {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .user-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-info {
    margin-right: 15px;
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 4px;
}

.last-msg {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    border: 2px solid var(--sidebar-bg);
}

.status-dot.online {
    background: #4caf50;
}

.status-dot.offline {
    background: #9e9e9e;
}

/* --- ناحیه اصلی چت --- */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    background-image: var(--chat-bg-pattern);
    position: relative;
}

.chat-header {
    padding: 10px 15px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    z-index: 5;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* پیام‌ها */
.message {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.2s ease;
}

.message.sent {
    align-self: flex-end;
    background: var(--message-out-bg);
    border-radius: 12px 0 12px 12px;
}

.message.received {
    align-self: flex-start;
    background: var(--message-in-bg);
    border-radius: 0 12px 12px 12px;
}

.message-content img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 5px;
    display: block;
}

.msg-meta {
    font-size: 0.7rem;
    color: rgba(0, 0, 0, 0.5);
    text-align: left;
    margin-top: 4px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
}

[data-theme="dark"] .msg-meta {
    color: rgba(255, 255, 255, 0.5);
}

/* ریپلای و فوروارد */
.reply-preview {
    background: rgba(0, 0, 0, 0.1);
    padding: 5px 8px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.8rem;
    border-right: 3px solid var(--primary-color);
}

.forwarded-badge {
    font-size: 0.7rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

/* --- ورودی پیام --- */
.chat-input-area {
    padding: 10px 15px;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 60px;
}

.chat-input {
    flex: 1;
    padding: 12px 15px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    resize: none;
    height: 45px;
    line-height: 20px;
    font-size: 0.95rem;
    max-height: 120px;
    overflow-y: auto;
}

.chat-input:focus {
    border-color: var(--primary-color);
}

/* =========================================
   المان‌های تعاملی (Modals, Menus)
   ========================================= */

/* منوی راست کلیک */
#context-menu {
    position: absolute;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    width: 180px;
    z-index: 3000;
    display: none;
    overflow: hidden;
    animation: fadeIn 0.1s ease;
}

.context-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-color);
}

.context-item:hover {
    background: var(--primary-color);
    color: white;
}

.context-item svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* مودال (پنجره پاپ‌آپ) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--sidebar-bg);
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.modal-body {
    max-height: 300px;
    overflow-y: auto;
}

/* دکمه بستن مودال */
.close-btn {
    color: #aaa;
    float: left;
    /* تغییر به چپ برای RTL */
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover,
.close-btn:focus {
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
}

.user-list {
    list-style: none;
    padding: 0;
    margin-top: 15px;
    max-height: 75vh;
    overflow-y: auto;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 8px;
    margin-bottom: 5px;
}

.user-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .user-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-profile-thumb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-left: 10px;
}

/* نوتیفیکیشن داخلی (Toast) */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    z-index: 20000;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* =========================================
   انیمیشن‌ها
   ========================================= */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   واکنش‌گرا (Responsive / Mobile)
   ========================================= */
@media (max-width: 768px) {
    aside {
        position: absolute;
        top: 0;
        width: 100%;
        height: 100vh;
        /* Fallback */
        height: 100dvh;
        /* Dynamic positioning */
        z-index: 100;
        transform: translateX(0);
    }

    aside.mobile-hidden {
        display: none !important;
        transform: none;
    }

    main {
        width: 100%;
        height: 100%;
    }

    .back-btn {
        display: block !important;
        margin-left: 10px;
    }

    .message {
        max-width: 85%;
    }
}

@media (min-width: 769px) {
    .back-btn {
        display: none;
    }
}

/* استایل‌های جدید برای بخش‌های تکمیلی */

#chat-search-bar {
    animation: fadeIn 0.3s;
}

/* استایل باکس جستجو در مودال/سایدبار */
.search-box {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 5px 15px;
    margin-bottom: 15px;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    color: var(--text-color);
    font-family: inherit;
    outline: none;
}

.search-box .icon {
    opacity: 0.6;
    transition: opacity 0.2s;
}

.search-box .icon:hover {
    opacity: 1;
}

/* استایل پیام پین شده */
.message.pinned {
    border: 2px solid var(--primary-color);
    background: rgba(0, 136, 204, 0.05);
}

.pinned-badge {
    position: absolute;
    top: -10px;
    right: 10px;
    background: var(--primary-color);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
}

/* بهبود اسکرول بار در مودال‌ها */
.modal-body::-webkit-scrollbar {
    width: 4px;
}

/* =========================================
   استایل‌های مدیا (عکس، ویس، ویدیو)
   ========================================= */

/* عکس داخل پیام */
.msg-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    /* نشانگر دست برای کلیک */
    transition: transform 0.2s;
    display: block;
    margin-top: 5px;
    object-fit: cover;
    /* جلوگیری از کشیده شدن عکس */
}

.msg-image:hover {
    transform: scale(1.02);
}

/* فایل صوتی */
.msg-audio {
    width: 100%;
    max-width: 300px;
    height: 40px;
    margin-top: 5px;
    outline: none;
    /* حذف کادر آبی دور پلیر در برخی مرورگرها */
}

/* ویدیو */
.msg-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    margin-top: 5px;
    background-color: #000;
    outline: none;
}

/* =========================================
   مودال نمایش عکس بزرگ (Lightbox)
   ========================================= */
.image-modal {
    display: none;
    /* پیش‌فرض مخفی */
    position: fixed;
    z-index: 5000;
    /* بالاتر از همه چیز (حتی منوی راست کلیک) */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    /* پس‌زمینه تیره */
    justify-content: center;
    align-items: center;
    flex-direction: column;
    cursor: zoom-out;
    /* نشانگر ذره‌بین کوچک برای بستن */
}

/* عکس داخل مودال */
.image-modal img {
    max-width: 95%;
    max-height: 90%;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
    object-fit: contain;
    cursor: default;
}

/* دکمه بستن (X) */
.close-modal {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #f1f1f1;
    font-size: 50px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    line-height: 1;
    z-index: 5001;
}

.close-modal:hover {
    color: #bbb;
    transform: scale(1.1);
}

/* دکمه منو برای تمام دیوایس‌ها */
.mobile-msg-menu-btn {
    display: flex;
    /* همیشه نمایش داده شود */
    position: absolute;
    top: 5px;
    left: 5px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.05);
    /* کمی شفاف‌تر برای دسکتاپ */
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    font-size: 16px;
    /* کمی بزرگتر برای خوانایی بهتر */
    color: var(--text-color);
    transition: background 0.2s;
    user-select: none;
    /* جلوگیری از انتخاب متن هنگام کلیک */
}

.mobile-msg-menu-btn:hover {
    background: rgba(0, 0, 0, 0.15);
    /* افکت هاور در دسکتاپ */
}

.mobile-msg-menu-btn:active {
    background: rgba(0, 0, 0, 0.3);
}

/* انیمیشن چرخش برای دکمه رفرش */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spinning-icon {
    animation: spin 1s linear infinite;
}

/* =========================================
   استایل‌های جدید برای مودال شروع گفتگوی جدید و ساخت گروه
   ========================================= */

.chat-type-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-option {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-color);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-align: right;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-color);
    transition: background 0.2s, transform 0.1s;
}

.btn-option:hover {
    background: #dde2e7;
    /* کمی تیره‌تر از bg-color */
    transform: translateX(-5px);
}

[data-theme="dark"] .btn-option:hover {
    background: #2a2a2a;
}

.btn-option .icon {
    width: 28px;
    height: 28px;
    opacity: 0.8;
}

.action-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.2s;
}

.action-btn:hover {
    background: var(--primary-hover);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--text-color);
}

#group-desc {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}

#group-title {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
}

/* --- استایل‌های بخش یادداشت --- */
.dropdown-menu {
    transition: opacity 0.2s, transform 0.2s;
    transform-origin: bottom left;
}

.dropdown-menu.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

.menu-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.note-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

/* ریسپانسیو برای بخش یادداشت */
@media (max-width: 768px) {
    #notes-list-sidebar {
        width: 100% !important;
        /* نمایش پیش‌فرض */
    }

    #note-content-area {
        display: none;
        /* در موبایل وقتی لیست هست، ادیتور مخفی */
        width: 100% !important;
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        background: var(--bg-color);
        z-index: 10;
    }

    /* وقتی ادیتور باز میشه، باید کلاس فعال بگیره یا با JS استایل اینلاین بدیم */

}

/* --- اصلاحات نهایی UI (اجرا شده - ویرایش جدید) --- */

/* فوتر سایدبار - راست چین */
.sidebar-footer {
    position: absolute;
    bottom: 0;
    right: 0;
    left: auto;
    width: 100%;
    height: 70px;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* آیکن سمت راست برای RTL */
    padding: 0 15px;
    z-index: 50;
}

#user-list {
    padding-bottom: 80px !important;
}

/* منوی مودال (سمت راست بالا) */
.dropdown-menu {
    position: absolute;
    bottom: 80px;
    right: 15px;
    left: auto;
    width: 240px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 8px;
    opacity: 1;
}

/* برای حالت مخفی */
.dropdown-menu.hidden {
    display: block !important;
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
    visibility: hidden;
}

.menu-item {
    border-radius: 10px;
    margin-bottom: 2px;
}

.menu-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.action-circle-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.action-circle-btn:hover {
    background: var(--bg-color);
    transform: translateY(-2px);
}

.action-circle-btn.danger {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.action-circle-btn.danger:hover {
    background: rgba(255, 68, 68, 0.1);
}

/* دکمه یادداشت جدید - عرض درصدی */
.new-note-btn {
    width: 15% !important;
    min-width: 120px;
    height: 40px;
    margin-left: 0;
    padding: 0 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    margin-top: 0rem;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

/* هدر یادداشت - تراز دقیق */
.notes-header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.notes-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    height: 100%;
}

.notes-header-right h2 {
    margin: 0;
    display: flex;
    align-items: center;
}

/* فوتر ادیتور - تراز دقیق */
.editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 0 !important;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* ریسپانسیو اختصاصی */
@media (max-width: 768px) {
    .new-note-btn {
        width: 45% !important;
    }

    .mobile-back-btn {
        display: flex !important;
    }
}

/* دکمه بازگشت موبایل (پیش‌فرض مخفی) */
.mobile-back-btn {
    display: none;
}

/* اصلاح اختصاصی دکمه ذخیره تغییرات */
#save-note-btn {
    margin-top: 0 !important;
}

/* =========================================
   استایل‌های کارت ویزیت (Business Cards)
   ========================================= */

/* کانتینر کارت */
.biz-card-wrapper {
    width: 380px;
    min-height: 220px;
    border-radius: 15px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    background: #fff;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: default;
    direction: rtl;
    /* پیش‌فرض */
}

.biz-card-wrapper:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.25);
}

/* دکمه‌های عملیات روی کارت (هاور) */
.card-overlay-actions {
    position: absolute;
    top: 10px;
    left: 10px;
    gap: 8px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s;
    display: flex;
}

.biz-card-wrapper:hover .card-overlay-actions {
    opacity: 1;
}

.card-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.card-action-btn:hover {
    background: #fff;
    transform: scale(1.1);
}

/* --- قالب 1: مدرن (Modern) --- */
.card-modern {
    background: linear-gradient(135deg, #ffffff 60%, var(--card-color, #0088cc) 60%);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.card-modern .card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.card-modern .card-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid #fff;
    object-fit: cover;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.card-modern .card-name {
    font-size: 1.4rem;
    font-weight: bold;
    color: #333;
}

.card-modern .card-job {
    font-size: 0.9rem;
    color: #666;
    margin-top: 2px;
}

.card-modern .card-body {
    flex: 1;
}

.card-modern .info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #555;
}

.card-modern .card-footer {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* --- قالب 2: مینیمال (Minimal) --- */
.card-minimal {
    background: #f9f9f9;
    border: 1px solid #ddd;
    text-align: center;
    padding: 25px;
}

.card-minimal .card-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    margin: 0 auto 15px;
    object-fit: cover;
}

.card-minimal .card-name {
    color: var(--card-color, #333);
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

.card-minimal hr {
    border: 0;
    border-top: 2px solid var(--card-color, #333);
    width: 30px;
    margin: 15px auto;
}

/* --- قالب 3: شیشه‌ای (Glass) --- */
.card-glass {
    background: linear-gradient(45deg, var(--card-color, #0088cc), #8e44ad);
    color: #fff;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.card-glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
}

.card-glass>* {
    position: relative;
    z-index: 1;
}

.card-glass .card-name {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* --- قالب 4: خلاقانه (Creative) --- */
.card-creative {
    background: #fff;
    padding: 20px;
    border-left: 10px solid var(--card-color, #ff9f43);
    position: relative;
}

.card-creative::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: var(--card-color, #ff9f43);
    clip-path: polygon(100% 0, 0 0, 100% 100%);
    opacity: 0.2;
}

/* --- قالب 5: لوکس (Luxury) --- */
.card-luxury {
    background: #222;
    color: #d4af37;
    /* Gold */
    padding: 25px;
    border: 1px solid #444;
    text-align: center;
}

.card-luxury .card-name {
    font-family: 'YekanBakh', sans-serif;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-bottom: 1px solid #d4af37;
    display: inline-block;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.card-luxury .card-avatar {
    width: 60px;
    height: 60px;
    border-radius: 5px;
    border: 1px solid #d4af37;
    object-fit: cover;
    margin-bottom: 10px;
}


/* ریسپانسیو اختصاصی کارت */
@media (max-width: 768px) {
    #cards-view {
        z-index: 20000;
    }

    /* بالاتر از همه */
    .biz-card-wrapper {
        width: 100%;
        max-width: 350px;
    }
}

/* استایل گالری کارت */
.card-gallery-wrapper {
    margin: 15px 0;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #f0f0f0;
}

.card-gallery-scroll {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    gap: 5px;
    padding: 5px;
}

.card-gallery-scroll::-webkit-scrollbar {
    height: 4px;
}

.card-gallery-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.gallery-slide {
    width: 100px;
    /* سایز کوچکتر برای حالت کاروسل */
    height: 80px;
    object-fit: cover;
    flex-shrink: 0;
    border-radius: 4px;
    cursor: zoom-in;
    transition: transform 0.2s, filter 0.2s;
    border: 1px solid #ddd;
}

.gallery-slide.active {
    /* عکس اول یا انتخاب شده */
    width: 100%;
    height: 180px;
    margin-bottom: 5px;
    display: block;
    /* برای اینکه در خط جدید بیفتد اگر با فلکس بخواهیم هندل کنیم سخته، پس JS کلاس active رو مدیریت کنه */
}

/* اما چون استراکچر HTML ما برای کاروسل ساده است، همه اسلاید هستند. بیایید استایل ساده اسکرولی بدهیم */
.gallery-slide {
    width: 100%;
    /* حالت تک عکس */
    height: 150px;
}

/* اگر چند عکس باشد، کانتینر اسکرول می‌شود */
.card-gallery-scroll .gallery-slide {
    width: 90%;
    /* کمی کوچکتر از عرض کامل تا بعدی دیده شود */
}

.gallery-slide:hover {
    filter: brightness(0.95);
}

.gallery-hint {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    pointer-events: none;
}

/* مودال لایت باکس */
.image-modal {
    z-index: 10005 !important;
}
/* =========================================
   Modern Form Styles (Business Card)
   ========================================= */

.modern-modal-content {
    background: var(--sidebar-bg);
    border-radius: 24px;
    padding: 0; 
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.modern-modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modern-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    letter-spacing: -0.5px;
}

.modern-form-scroll {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
}

.modern-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

@media (max-width: 900px) {
    .modern-form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

.modern-input-group {
    margin-bottom: 24px;
    position: relative;
}

.modern-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-secondary, #666);
    transition: color 0.2s;
}

.modern-input-group:focus-within .modern-label {
    color: var(--primary-color);
}

.modern-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.modern-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 136, 204, 0.1);
    outline: none;
    background: #fff;
}

.modern-input::placeholder {
    color: #aaa;
}

.modern-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

/* Template Selector Improvements */
.modern-select-wrapper {
    position: relative;
}

.modern-select-wrapper::after {
    content: "?";
    font-size: 0.8rem;
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    pointer-events: none;
}

/* Color Picker Modernization */
.color-picker-container {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--bg-color);
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
}

.color-preview {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

input[type="color"].invisible-picker {
    width: 100%;
    height: 100%;
    opacity: 0;
    position: absolute;
    left: 0;
    top: 0;
    cursor: pointer;
}

/* Social Inputs */
.social-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.social-input-wrapper {
    position: relative;
}

.social-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    opacity: 0.6;
}

.social-input {
    padding-right: 45px !important;
    direction: ltr;
    text-align: left;
}

.modern-footer {
    padding: 20px 32px;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.btn-modern {
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    border: none;
    font-size: 1rem;
}

.btn-modern:active {
    transform: scale(0.98);
}

.btn-primary-modern {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
}

.btn-secondary-modern {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.btn-secondary-modern:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-color);
}


/* Task 8: Specific styling for New Card Button */
#new-card-btn {
    width: 15% !important;
    margin-top: 0 !important;
}

@media (max-width: 768px) {
    #new-card-btn {
        width: 35% !important;
        margin-top: 0 !important;
    }
}

