/* ==========================================================================
   لینک‌ساز خدمات شهری - استایل فرانت‌اند
   پالت رنگ: رز و گلدی (#d6336c + اکسنت طلایی #c9a227)
   فونت: Vazirmatn (در صورتی که پوسته بارگذاری کرده باشد)
   ========================================================================== */


:root {
    --cbl-rose: #d6336c;
    --cbl-rose-dark: #b02a5a;
    --cbl-rose-light: #fff0f5;
    --cbl-rose-soft: #ffe4ed;
    --cbl-gold: #c9a227;
    --cbl-gold-light: #f5e6b8;
    --cbl-text: #2d1b2e;
    --cbl-text-muted: #6c5b6e;
    --cbl-white: #ffffff;
    --cbl-shadow: 0 10px 30px -10px rgba(214, 51, 108, 0.35);
    --cbl-shadow-strong: 0 20px 50px -10px rgba(214, 51, 108, 0.45);
    --cbl-radius: 14px;
    --cbl-radius-sm: 8px;
    --cbl-font: 'Vazirmatn', 'Tahoma', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

/* ریست محلی */
.cbl-sticky-sidebar *,
.cbl-inline-block * {
    box-sizing: border-box;
}

.cbl-sticky-sidebar,
.cbl-inline-block {
    font-family: var(--cbl-font);
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.cbl-sticky-sidebar svg,
.cbl-inline-block svg {
    display: inline-block;
    vertical-align: middle;
}

/* ==========================================================================
   جعبه چسبان سمت چپ (دسکتاپ فقط)
   ========================================================================== */

.cbl-sticky-sidebar {
    position: fixed;
    top: 50%;
    left: 20px;
    right: auto;
    transform: translateY(-50%);
    width: 280px;
    z-index: 9990;
    font-size: 14px;
    transition: opacity 0.3s ease, transform 0.3s ease, top 0.3s ease;
}

/* موقعیت افقی */
.cbl-sticky-sidebar.cbl-pos-left {
    left: 20px;
    right: auto;
}
.cbl-sticky-sidebar.cbl-pos-right {
    left: auto;
    right: 20px;
}

/* موقعیت عمودی - این کلاس‌ها فقط fallback هستند.
   JS با inline style این مقادیر را override می‌کند. */
.cbl-sticky-sidebar.cbl-vert-center {
    top: 50%;
    transform: translateY(-50%);
}
.cbl-sticky-sidebar.cbl-vert-top {
    top: 80px;
    transform: none;
}
.cbl-sticky-sidebar.cbl-vert-bottom {
    bottom: 80px;
    top: auto;
    transform: none;
}

/* وقتی JS موقعیت جدیدی اعمال می‌کند، transition داشته باشد */
.cbl-sticky-sidebar {
    transition: top 0.4s ease, transform 0.3s ease, opacity 0.3s ease, left 0.3s ease, right 0.3s ease;
}

.cbl-sticky-sidebar.cbl-collapsed {
    opacity: 0.5;
}

.cbl-sticky-sidebar.cbl-collapsed:hover {
    opacity: 1;
}

.cbl-sticky-inner {
    background: linear-gradient(160deg, #ffffff 0%, #fff8fb 100%);
    border-radius: var(--cbl-radius);
    box-shadow: var(--cbl-shadow-strong);
    overflow: hidden;
    border: 1px solid rgba(214, 51, 108, 0.12);
}

.cbl-sticky-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--cbl-rose) 0%, var(--cbl-rose-dark) 100%);
    color: var(--cbl-white);
    position: relative;
}

.cbl-pin-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    color: var(--cbl-gold-light);
    flex-shrink: 0;
}

.cbl-sticky-title {
    flex: 1;
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--cbl-white);
    letter-spacing: -0.2px;
}

.cbl-sticky-toggle {
    background: transparent;
    border: none;
    color: var(--cbl-white);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
}

.cbl-sticky-toggle:hover {
    background: rgba(255, 255, 255, 0.18);
}

.cbl-sticky-toggle svg {
    transition: transform 0.3s ease;
}

.cbl-sticky-sidebar.collapsed-body .cbl-sticky-toggle svg {
    transform: rotate(-90deg);
}

.cbl-sticky-body {
    max-height: 70vh;
    overflow-y: auto;
    padding: 8px;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

/* جعبه جستجو */
.cbl-search-box {
    padding: 10px 8px 10px;
    background: linear-gradient(180deg, rgba(214, 51, 108, 0.04) 0%, transparent 100%);
    border-bottom: 1px dashed rgba(214, 51, 108, 0.25);
    margin: 0 0 8px;
    /* مهم: background سفید برای اطمینان از نمایش در همه قالب‌ها */
    position: relative;
    z-index: 2;
}

.cbl-search-form {
    display: flex;
    align-items: center;
    background: #ffffff !important;
    border: 1.5px solid rgba(214, 51, 108, 0.3);
    border-radius: 22px;
    overflow: hidden;
    padding: 3px 4px 3px 3px;
    transition: all 0.2s ease;
    direction: rtl;
    box-shadow: 0 2px 8px rgba(214, 51, 108, 0.1);
    height: 38px;
}

.cbl-search-form:focus-within {
    border-color: var(--cbl-rose);
    box-shadow: 0 0 0 3px rgba(214, 51, 108, 0.15), 0 2px 8px rgba(214, 51, 108, 0.15);
}

.cbl-search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--cbl-rose) !important;
    background: transparent;
    flex-shrink: 0;
    margin-right: 4px;
}

.cbl-search-icon svg {
    width: 16px;
    height: 16px;
    color: var(--cbl-rose) !important;
    stroke: var(--cbl-rose) !important;
}

.cbl-search-input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    outline: none !important;
    padding: 6px 4px !important;
    font-size: 13px !important;
    font-family: var(--cbl-font) !important;
    color: var(--cbl-text) !important;
    min-width: 0;
    box-shadow: none !important;
    line-height: 1.4;
    height: 100%;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    background-image: none !important;
}

.cbl-search-input::placeholder {
    color: var(--cbl-text-muted);
    font-size: 12px;
    opacity: 0.8;
}

.cbl-search-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none !important;
    background: linear-gradient(135deg, var(--cbl-rose) 0%, var(--cbl-rose-dark) 100%) !important;
    color: var(--cbl-white) !important;
    border-radius: 50% !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: 0 2px 6px rgba(214, 51, 108, 0.3) !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    outline: none !important;
    text-indent: 0 !important;
    text-shadow: none !important;
    line-height: 1 !important;
    font-size: 0 !important;
    letter-spacing: 0 !important;
}

.cbl-search-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(214, 51, 108, 0.5) !important;
}

.cbl-search-btn::-moz-focus-inner {
    border: 0 !important;
    padding: 0 !important;
}

.cbl-search-btn svg {
    transform: scaleX(-1); /* فلش چپ در RTL */
    width: 14px;
    height: 14px;
    stroke: var(--cbl-white) !important;
    color: var(--cbl-white) !important;
}

.cbl-sticky-sidebar.collapsed-body .cbl-sticky-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
}

/* اسکرول‌بار سفارشی */
.cbl-sticky-body::-webkit-scrollbar {
    width: 6px;
}
.cbl-sticky-body::-webkit-scrollbar-track {
    background: var(--cbl-rose-light);
    border-radius: 3px;
}
.cbl-sticky-body::-webkit-scrollbar-thumb {
    background: var(--cbl-rose);
    border-radius: 3px;
}
.cbl-sticky-body::-webkit-scrollbar-thumb:hover {
    background: var(--cbl-rose-dark);
}

.cbl-services-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cbl-service-item {
    margin-bottom: 6px;
}

.cbl-service-item:last-child {
    margin-bottom: 0;
}

.cbl-service-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--cbl-white);
    border: 1px solid rgba(214, 51, 108, 0.1);
    border-radius: var(--cbl-radius-sm);
    color: var(--cbl-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.cbl-service-link::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--cbl-rose);
    transform: scaleY(0);
    transform-origin: center;
    transition: transform 0.25s ease;
}

.cbl-service-link:hover {
    background: var(--cbl-rose-light);
    border-color: var(--cbl-rose);
    color: var(--cbl-rose-dark);
    transform: translateX(-4px);
    box-shadow: 0 4px 12px -2px rgba(214, 51, 108, 0.25);
}

.cbl-service-link:hover::before {
    transform: scaleY(1);
}

.cbl-icon-wrap {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--cbl-rose-light) 0%, var(--cbl-rose-soft) 100%);
    color: var(--cbl-rose);
    border-radius: 8px;
    transition: all 0.25s ease;
}

.cbl-icon-wrap svg {
    width: 18px;
    height: 18px;
}

.cbl-service-link:hover .cbl-icon-wrap {
    background: linear-gradient(135deg, var(--cbl-rose) 0%, var(--cbl-rose-dark) 100%);
    color: var(--cbl-white);
    transform: scale(1.08);
}

.cbl-service-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    line-height: 1.4;
}

.cbl-city-tag {
    font-size: 11px;
    color: var(--cbl-gold);
    font-weight: 600;
    margin-top: 2px;
    letter-spacing: -0.2px;
}

.cbl-service-link:hover .cbl-city-tag {
    color: var(--cbl-rose-dark);
}

.cbl-arrow {
    flex-shrink: 0;
    color: var(--cbl-rose);
    opacity: 0;
    transform: translateX(6px);
    transition: all 0.25s ease;
}

.cbl-service-link:hover .cbl-arrow {
    opacity: 1;
    transform: translateX(0);
}

.cbl-sticky-footer {
    padding: 8px 12px;
    background: linear-gradient(180deg, transparent, rgba(214, 51, 108, 0.04));
    border-top: 1px dashed rgba(214, 51, 108, 0.2);
    text-align: center;
}

.cbl-close-sticky {
    display: inline-block;
    font-size: 12px;
    color: var(--cbl-rose-dark);
    text-decoration: none;
    padding: 4px 12px;
    border-radius: 12px;
    background: var(--cbl-rose-light);
    transition: all 0.2s ease;
    font-family: var(--cbl-font);
}

.cbl-close-sticky:hover {
    background: var(--cbl-rose);
    color: var(--cbl-white);
}

/* وقتی کاربر روی «بستن» کلیک کرد */
.cbl-sticky-sidebar.cbl-hidden {
    display: none !important;
}

/* دکمه شناور برای بازگرداندن پنل بعد از بستن */
.cbl-float-toggle {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cbl-rose) 0%, var(--cbl-rose-dark) 100%);
    color: var(--cbl-white);
    border: none;
    box-shadow: var(--cbl-shadow-strong);
    cursor: pointer;
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.cbl-float-toggle.cbl-pos-left {
    left: 20px;
    right: auto;
}
.cbl-float-toggle.cbl-pos-right {
    left: auto;
    right: 20px;
}

.cbl-float-toggle:hover {
    transform: translateY(-50%) scale(1.1);
}

.cbl-float-toggle.cbl-visible {
    display: flex;
}

.cbl-float-toggle svg {
    width: 22px;
    height: 22px;
}

/* ==========================================================================
   بلوک پایین محتوا (موبایل + دسکتاپ)
   ========================================================================== */

.cbl-inline-block {
    margin: 40px 0 30px;
    padding: 0;
    clear: both;
}

.cbl-inline-block .cbl-services-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: contents;
}

.cbl-block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--cbl-rose) 0%, var(--cbl-rose-dark) 100%);
    border-radius: var(--cbl-radius) var(--cbl-radius) 0 0;
    color: var(--cbl-white);
}

.cbl-block-header .cbl-block-icon {
    color: var(--cbl-gold-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    flex-shrink: 0;
}

.cbl-block-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--cbl-white);
}

.cbl-items-grid {
    background: linear-gradient(160deg, #ffffff 0%, #fff8fb 100%);
    border: 1px solid rgba(214, 51, 108, 0.15);
    border-top: none;
    border-radius: 0 0 var(--cbl-radius) var(--cbl-radius);
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}

.cbl-items-grid .cbl-service-item {
    margin-bottom: 0;
    list-style: none;
}

.cbl-items-grid .cbl-service-link {
    padding: 12px 14px;
    height: 100%;
}

/* ==========================================================================
   ریسپانسیو - موبایل
   ========================================================================== */

@media screen and (max-width: 1023px) {
    .cbl-sticky-sidebar {
        display: none !important;
    }

    .cbl-float-toggle {
        display: none !important;
    }

    .cbl-items-grid {
        grid-template-columns: 1fr;
    }
}

@media screen and (min-width: 1024px) and (max-width: 1280px) {
    .cbl-sticky-sidebar {
        width: 250px;
        left: 12px;
    }

    .cbl-service-link {
        padding: 9px 10px;
        font-size: 12px;
    }

    .cbl-icon-wrap {
        width: 28px;
        height: 28px;
    }
}

@media screen and (max-width: 768px) {
    .cbl-inline-block {
        margin: 30px 0 20px;
    }

    .cbl-block-header {
        padding: 14px 16px;
    }

    .cbl-block-title {
        font-size: 16px;
    }

    .cbl-items-grid {
        padding: 12px;
        gap: 8px;
    }
}

/* در صفحه چاپ، مخفی */
@media print {
    .cbl-sticky-sidebar,
    .cbl-inline-block,
    .cbl-float-toggle {
        display: none !important;
    }
}

/* موقعیت چپ/راست توسط JS کنترل می‌شود.
   این قانون فقط به‌عنوان fallback در صورتی که JS اجرا نشود، عمل می‌کند. */
html[dir="rtl"] .cbl-sticky-sidebar:not(.cbl-pos-right),
html[dir="ltr"] .cbl-sticky-sidebar:not(.cbl-pos-right) {
    left: 20px;
    right: auto;
}
