/* =========================================================================
   استایل اختصاصی (نسخه جدید) — static/js/custom_style.js
   -------------------------------------------------------------------------
   فقط روی .cs-v2 اثر دارد؛ کلاس‌های قدیمی (custom-style-container و ...)
   برای سازگاری با editor.js و ui.js سر جایشان مانده‌اند.
   ========================================================================= */

.custom-style-container.cs-v2 {
    background: linear-gradient(160deg, #24222d 0%, #1a1920 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    margin-bottom: 18px;
    max-height: 72px;
    box-shadow: 0 12px 26px -16px rgba(0, 0, 0, 0.9);
    transition: max-height 0.42s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s, border-color 0.25s;
}
/* نوار رنگی ظریف بالای کادر */
.custom-style-container.cs-v2::before {
    content: '';
    position: absolute;
    top: 0;
    left: 18px;
    right: 18px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(155, 123, 255, 0.7), rgba(255, 92, 157, 0.55), transparent);
    opacity: 0.8;
    pointer-events: none;
}
.custom-style-container.cs-v2.open {
    max-height: 1000px;
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 36px -18px rgba(0, 0, 0, 0.95);
}
.custom-style-container.cs-v2.cs-active {
    border-color: rgba(124, 77, 255, 0.6);
    box-shadow: 0 0 0 1px rgba(124, 77, 255, 0.25), 0 16px 32px -18px rgba(124, 77, 255, 0.85);
}

/* ---------- سرتیتر ---------- */
.cs-v2 .custom-header {
    height: 72px;
    padding: 0 14px;
    font-family: inherit;
    font-size: inherit;
    gap: 10px;
}
.cs-head-main { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.cs-head-icon {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    background: linear-gradient(135deg, #a58bff 0%, #7C4DFF 48%, #ff5c9d 100%);
    box-shadow: 0 8px 18px -8px rgba(124, 77, 255, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.cs-head-text { min-width: 0; }
.cs-v2 .custom-header-title {
    font-size: 1rem;
    font-weight: 900;
    color: #fff;
    gap: 7px;
    line-height: 1.5;
}
.cs-head-sub {
    font-size: 0.71rem;
    color: #9a9db0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cs-live-badge {
    display: none;
    font-size: 0.58rem;
    font-weight: 800;
    color: #b9f6ca;
    background: rgba(0, 200, 83, 0.14);
    border: 1px solid rgba(0, 200, 83, 0.38);
    border-radius: 999px;
    padding: 0 7px;
    line-height: 1.75;
}
.cs-v2.cs-active .cs-live-badge { display: inline-block; }
.cs-head-side { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.cs-swatch {
    width: 36px;
    height: 26px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 900;
    font-size: 0.92rem;
    line-height: 1;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.cs-swatch b { font-weight: 900; }
.cs-v2 .toggle-icon { color: #8d90a3; }
.cs-v2.open .toggle-icon { color: #fff; }

/* ---------- محتوا ---------- */
.cs-v2 .custom-content {
    padding: 14px 14px 16px;
    background: rgba(0, 0, 0, 0.16);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* پیش‌نمایش زنده: شبیه یک فریم ویدیو */
.cs-preview {
    position: relative;
    height: 88px;
    border-radius: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    isolation: isolate;
    background:
        radial-gradient(60% 90% at 15% 110%, rgba(255, 190, 120, 0.35) 0%, transparent 60%),
        radial-gradient(55% 80% at 90% 0%, rgba(140, 180, 255, 0.35) 0%, transparent 60%),
        linear-gradient(165deg, #56677f 0%, #313b4b 55%, #1c2129 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.cs-preview::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.35), transparent 60%);
    pointer-events: none;
    z-index: 0;
}
.cs-preview-text {
    position: relative;
    z-index: 1;
    display: inline-block;
    max-width: 92%;
    overflow: hidden;
    white-space: nowrap;
    font-size: 1.2rem;
    font-weight: normal;
    line-height: 1.55;
    padding: 2px 4px;
    border-radius: 10px;
    transition: background 0.25s, color 0.25s;
}
.cs-preview-text.cs-boxed { padding: 2px 14px 4px; }
.cs-w { transition: opacity 0.18s ease; }
.cs-w.cs-hide { opacity: 0; }

.cs-label {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 2px 9px;
    font-size: 0.78rem;
    font-weight: 800;
    color: #c9cbd8;
}
.cs-label i { color: #a58bff; font-size: 0.74rem; }

/* نوع نمایش */
.cs-types { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.cs-v2 .cs-type.style-card {
    aspect-ratio: auto;
    min-height: 0;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 11px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
    border: 1.5px solid rgba(255, 255, 255, 0.07);
    box-shadow: none;
}
.cs-v2 .cs-type.style-card.selected {
    background: rgba(124, 77, 255, 0.14);
    border-color: var(--primary);
}
.cs-v2 .cs-type.style-card.selected::after {
    top: 50%;
    left: 9px;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    font-size: 0.58rem;
}
.cs-type-ico {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cfc4ff;
    font-size: 0.88rem;
    background: rgba(255, 255, 255, 0.06);
    transition: background 0.2s, color 0.2s;
}
.cs-type.selected .cs-type-ico {
    color: #fff;
    background: linear-gradient(135deg, #8e6bff, #6a3df0);
    box-shadow: 0 6px 14px -8px rgba(124, 77, 255, 0.95);
}
.cs-type-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.cs-type-title { font-size: 0.84rem; font-weight: 900; color: #fff; white-space: nowrap; }
.cs-type-sub { font-size: 0.66rem; color: #9a9db0; margin-top: 1px; white-space: nowrap; }

/* رنگ‌ها */
.cs-v2 .color-trigger-row { margin: 0 0 10px; gap: 8px; }
.cs-v2 .color-trigger {
    border-radius: 14px;
    padding: 9px 12px 9px 9px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: opacity 0.2s, transform 0.12s ease;
}
.cs-v2 .color-trigger::before { display: none; }
.cs-v2 .color-label { font-size: 0.8rem; padding-left: 0; }
.cs-v2 .color-preview-circle {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}
.cs-v2 .color-trigger.cs-dim { opacity: 0.45; }

.cs-presets {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}
.cs-preset {
    aspect-ratio: 1 / 1;
    width: 100%;
    max-width: 40px;
    justify-self: center;
    padding: 0;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 900;
    font-size: 0.92rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
    transition: transform 0.12s, box-shadow 0.2s;
}
.cs-preset:active { transform: scale(0.88); }
.cs-preset.on { box-shadow: 0 0 0 2px #1d1c24, 0 0 0 4px var(--primary); }

/* حالت کادر: کنترل چهارتکه */
.cs-seg {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.cs-v2 .cs-seg .mode-btn {
    flex: none;
    margin: 0;
    padding: 8px 2px 7px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #a3a6b8;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    font-weight: 800;
    box-shadow: none;
    white-space: nowrap;
}
.cs-v2 .cs-seg .mode-btn.active {
    background: linear-gradient(135deg, #8e6bff, #6a3df0);
    color: #fff;
    box-shadow: 0 6px 14px -8px rgba(124, 77, 255, 0.95);
}
.cs-mode-ico {
    width: 28px;
    height: 20px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 900;
    font-size: 0.82rem;
    line-height: 1;
}
.cs-mode-ico.m-solid { background: currentColor; }
.cs-mode-ico.m-solid b { color: #1d1c24; }
.mode-btn.active .cs-mode-ico.m-solid b { color: #6a3df0; }
.cs-mode-ico.m-glass { background: rgba(255, 255, 255, 0.22); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
/* حرف توخالی: رنگ پر شدن شفاف، ولی currentColor همان رنگ دکمه می‌ماند */
.cs-mode-ico.m-outline b { -webkit-text-fill-color: transparent; -webkit-text-stroke: 1.3px currentColor; }
.cs-mode-ico b { font-weight: 900; }

/* صفحه‌های باریک: کارت نوع نمایش عمودی می‌شود تا متن جا شود */
@media (max-width: 380px) {
    .cs-v2 .cs-type.style-card {
        flex-direction: column;
        align-items: center;
        gap: 6px;
        padding: 10px 6px;
    }
    .cs-type-text { align-items: center; }
    .cs-v2 .cs-type.style-card.selected::after { top: 8px; left: 8px; transform: none; }
}

@media (max-width: 360px) {
    .cs-presets { gap: 4px; }
    .cs-v2 .cs-seg .mode-btn { font-size: 0.62rem; }
    .cs-head-sub { max-width: 150px; }
}
