/*
 * ═══════════════════════════════════════════════
 *  main-modal.css — مدال‌های فهرست و اشتراک‌گذاری
 * ═══════════════════════════════════════════════
 */

/* ══ WRAPPER ══ */
#EMtamplate .EM-modal-main,
#EMtamplate .EM-share-modal {
    position: fixed;
    inset: 0;
    background: rgba(33, 37, 41, .5);
    backdrop-filter: blur(1.5px);
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 1001;
}

#EMtamplate .EM-modal-main.show,
#EMtamplate .EM-share-modal.show {
    display: flex;
}

/* ══ MODAL (اسلاید از چپ — چون dir=rtl در واقع از چپ صفحه میاد) ══ */
#EMtamplate .EM-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 486px;
    max-width: 100%;
    height: 100%;
    background: #fff;
    padding: 55px 30px 30px;
    overflow-y: auto;
    box-shadow: 2px 0 18px rgba(0, 0, 0, .08);
}

#EMtamplate .EM-modal.enter {
    animation: EMmodalEnter .3s forwards;
}

#EMtamplate .EM-modal.exit {
    animation: EMmodalExit .3s forwards;
}

@keyframes EMmodalEnter {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}

@keyframes EMmodalExit {
    from { transform: translateX(0); }
    to   { transform: translateX(-100%); }
}

/* ══ CLOSE BUTTON ══ */
#EMtamplate .EM-close-btn {
    position: absolute;
    top: 18px;
    left: 20px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #F3F4F6;
    cursor: pointer;
    transition: background .2s;
}

#EMtamplate .EM-close-btn::before,
#EMtamplate .EM-close-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 2px;
    background: #343A40;
    border-radius: 2px;
}
#EMtamplate .EM-close-btn::before { transform: translate(-50%, -50%) rotate(45deg); }
#EMtamplate .EM-close-btn::after  { transform: translate(-50%, -50%) rotate(-45deg); }

#EMtamplate .EM-close-btn:hover {
    background: #E5E7EB;
}

/* ══ TOC (لیست فهرست — مینیمال) ══ */
#EMtamplate .EM-list-section h3 {
    color: #343A40;
    font-size: 18px;
    font-weight: 800;
    line-height: 32px;
    margin-bottom: 4px;
}

#EMtamplate .EM-list-section .EM-list-sub {
    color: #9CA3AF;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #F1F3F4;
}

#EMtamplate .EM-list-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#EMtamplate .EM-list-section ul li {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    transition: background .2s ease;
}

#EMtamplate .EM-list-section ul li::after {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 1.8px solid #CBD5E1;
    border-bottom: 1.8px solid #CBD5E1;
    transform: rotate(135deg);
    flex-shrink: 0;
    transition: border-color .2s ease, transform .2s ease;
}

#EMtamplate .EM-list-section ul li a {
    color: #343A40;
    font-size: 14px;
    font-weight: 500;
    line-height: 24px;
    text-decoration: none;
    flex: 1;
    transition: color .2s;
}

#EMtamplate .EM-list-section ul li:hover {
    background: #F8F9FA;
}

#EMtamplate .EM-list-section ul li:hover a {
    color: #12B886;
}

#EMtamplate .EM-list-section ul li:hover::after {
    border-color: #12B886;
    transform: rotate(135deg) translate(-1.5px,-1.5px);
}

#EMtamplate .EM-list-section .EM-bold-link a {
    font-weight: 700;
    color: #1A1A1A;
}

#EMtamplate .EM-list-section .EM-empty {
    color: #9CA3AF;
    font-size: 13px;
    font-style: italic;
    cursor: default;
    justify-content: center;
    padding: 14px 10px;
}

#EMtamplate .EM-list-section .EM-empty::after { display: none }

/* ── آیکون هر بخش (مینیمال — tile رنگی تخت) ── */
#EMtamplate .EM-toc-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--toc-c1, #E6FCF5);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--toc-ink, #12B886);
    transition: background .2s ease;
}

#EMtamplate .EM-toc-icon svg {
    width: 20px;
    height: 20px;
    position: relative;
    z-index: 1;
}

#EMtamplate .EM-list-section ul li:hover .EM-toc-icon {
    background: var(--toc-c2, #C3FAE8);
}

/* ── واریانت‌های رنگی آیکون ── */
#EMtamplate .EM-toc-icon--green  { --toc-c1:#D1FAE5; --toc-c2:#A7F3D0; --toc-ink:#047857 }
#EMtamplate .EM-toc-icon--blue   { --toc-c1:#DBEAFE; --toc-c2:#BFDBFE; --toc-ink:#1D4ED8 }
#EMtamplate .EM-toc-icon--orange { --toc-c1:#FFEDD5; --toc-c2:#FED7AA; --toc-ink:#C2410C }
#EMtamplate .EM-toc-icon--pink   { --toc-c1:#FCE7F3; --toc-c2:#FBCFE8; --toc-ink:#BE185D }
#EMtamplate .EM-toc-icon--purple { --toc-c1:#F3E8FF; --toc-c2:#E9D5FF; --toc-ink:#7C3AED }
#EMtamplate .EM-toc-icon--teal   { --toc-c1:#CFFAFE; --toc-c2:#A5F3FC; --toc-ink:#0E7490 }

/* ── پیشرفته (دسترسی داره) ── */
#EMtamplate .EM-list-section .EM-pro-link { background: transparent; border: none }
#EMtamplate .EM-list-section .EM-pro-link .EM-toc-icon { --toc-c1:#EDE9FE; --toc-c2:#DDD6FE; --toc-ink:#6D28D9 }
#EMtamplate .EM-list-section .EM-pro-link:hover { background: #FAF5FF }
#EMtamplate .EM-list-section .EM-pro-link:hover a { color: #6D28D9 }
#EMtamplate .EM-list-section .EM-pro-link:hover::after { border-color: #845EF7 }

#EMtamplate .EM-list-section .EM-pro-link .EM-toc-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 700;
    color: #6D28D9;
    background: #F3E8FF;
    border-radius: 999px;
    white-space: nowrap;
}

#EMtamplate .EM-list-section .EM-pro-link .EM-toc-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='20' viewBox='0 0 22 20' fill='none'%3E%3Cpath d='M11 18.5L20.5 7.65L17.3 1.5M11 18.5L1.5 7.65L4.5 1.5M11 18.5L14.2 7.08M11 18.5L7.8 7.08M17.3 1.5H11M17.3 1.5L14.2 7.08M4.5 1.5L7.8 7.08M4.5 1.5H11M7.8 7.08L11 1.5M11 1.5L14.2 7.08' stroke='%236D28D9' stroke-width='1.8'/%3E%3C/svg%3E") no-repeat center/contain;
}

/* ── قفل (پیشرفته ولی دسترسی نداره) ── */
#EMtamplate .EM-list-section .EM-lock { cursor: pointer }
#EMtamplate .EM-list-section .EM-lock a { color: #9CA3AF }
#EMtamplate .EM-list-section .EM-lock .EM-toc-icon { opacity: .5 }
#EMtamplate .EM-list-section .EM-lock::after {
    content: '';
    width: 13px;
    height: 13px;
    border: none;
    transform: none;
    flex-shrink: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 10V8a6 6 0 0112 0v2' stroke='%23845EF7' stroke-width='1.8' stroke-linecap='round'/%3E%3Crect x='4' y='10' width='16' height='12' rx='2.5' stroke='%23845EF7' stroke-width='1.8'/%3E%3Ccircle cx='12' cy='16' r='1.5' fill='%23845EF7'/%3E%3C/svg%3E") no-repeat center/contain;
}

#EMtamplate .EM-list-section .EM-lock:hover a { color: #7048E8 }
#EMtamplate .EM-list-section .EM-lock:hover .EM-toc-icon { opacity: 1 }
#EMtamplate .EM-list-section .EM-lock:hover::after { transform: none }

/* ── نوار پیشرفته ── */
#EMtamplate .EM-list-pro-notice {
    margin-top: 16px;
    padding: 11px 14px;
    border-radius: 10px;
    background: #FAF5FF;
    border: 1px solid #EDE9FE;
    color: #6D28D9;
    font-size: 12px;
    font-weight: 500;
    line-height: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#EMtamplate .EM-pulse { animation: EMpulseHighlight 1.8s ease-out }

@keyframes EMpulseHighlight {
    0%   { box-shadow: 0 0 0 0 rgba(132,94,247,.6) }
    70%  { box-shadow: 0 0 0 16px rgba(132,94,247,0) }
    100% { box-shadow: 0 0 0 0 rgba(132,94,247,0) }
}

#EMtamplate .EM-list-pro-notice::before {
    content: '';
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='20' viewBox='0 0 22 20' fill='none'%3E%3Cpath d='M11 18.5L20.5 7.65L17.3 1.5M11 18.5L1.5 7.65L4.5 1.5M11 18.5L14.2 7.08M11 18.5L7.8 7.08M17.3 1.5H11M17.3 1.5L14.2 7.08M4.5 1.5L7.8 7.08M4.5 1.5H11M7.8 7.08L11 1.5M11 1.5L14.2 7.08' stroke='%236D28D9' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat center/contain;
}

/* ══ SHARE MODAL ══ */
#EMtamplate .EM-share-box h3 {
    color: #343A40;
    font-size: 18px;
    font-weight: 800;
    line-height: 32px;
    margin-bottom: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid #E5E7EB;
}

#EMtamplate .EM-share-box p {
    color: #6B7280;
    font-size: 14px;
    font-weight: 400;
    line-height: 26px;
    margin-bottom: 18px;
}

#EMtamplate .EM-share-link {
    display: flex;
    align-items: stretch;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 22px;
    background: #F9FAFB;
}

#EMtamplate .EM-share-link input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 14px;
    font-size: 13px;
    color: #343A40;
    outline: none;
    direction: ltr;
    text-align: left;
    font-family: inherit;
}

#EMtamplate .EM-copy-btn {
    border: none;
    background: #339AF0;
    color: #fff;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background .2s;
}

#EMtamplate .EM-copy-btn:hover {
    background: #228BE6;
}

#EMtamplate .EM-copy-btn.copied {
    background: #12B886;
}

#EMtamplate .EM-share-social {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

#EMtamplate .EM-social {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    text-decoration: none;
    color: #343A40;
    font-size: 13px;
    font-weight: 600;
    transition: all .2s;
    background: #fff;
}

#EMtamplate .EM-social svg {
    width: 26px;
    height: 26px;
}

#EMtamplate .EM-social--telegram { color: #0088CC; }
#EMtamplate .EM-social--whatsapp { color: #25D366; }
#EMtamplate .EM-social--twitter  { color: #111827; }

#EMtamplate .EM-social:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .06);
}

/* ══ RESPONSIVE ══ */
@media screen and (max-width: 576px) {
    #EMtamplate .EM-modal {
        width: 100%;
        padding: 55px 20px 20px;
    }

    #EMtamplate .EM-list-section h3,
    #EMtamplate .EM-share-box h3 {
        font-size: 16px;
    }

    #EMtamplate .EM-list-section ul li {
        padding: 8px 8px;
        gap: 10px;
    }

    #EMtamplate .EM-list-section ul li a {
        font-size: 13px;
        line-height: 22px;
    }

    #EMtamplate .EM-toc-icon {
        width: 32px;
        height: 32px;
        border-radius: 9px;
    }

    #EMtamplate .EM-toc-icon svg {
        width: 18px;
        height: 18px;
    }

    #EMtamplate .EM-list-section .EM-pro-link .EM-toc-badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    #EMtamplate .EM-share-social {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    #EMtamplate .EM-social {
        padding: 10px 6px;
        font-size: 12px;
    }

    #EMtamplate .EM-social svg {
        width: 22px;
        height: 22px;
    }
}
