﻿:root {
    /* رنگ‌ها و اندازه‌ها */
    --segment-bg: #ededf3; /* از استایل 1 */
    --segment-active-bg: #fff;
    --segment-active-color: #007aff;
    --segment-inactive-color: #3a3a3c;
    --segment-radius: 8px;
    --segment-padding: 4px;
    --segment-height: 36px;
    --segment-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --segment-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 🧩 کانتینر اصلی */
.segment-container {
    display: flex;
    align-items: center;
    background-color: var(--segment-bg);
    border-radius: var(--segment-radius);
    padding: var(--segment-padding);
    width: 100%;
    height: calc(var(--segment-height) + 2 * var(--segment-padding));
    box-sizing: border-box;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ➕ دکمه افزودن */
.segment-add {
    width: var(--segment-height);
    height: var(--segment-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 500; /* از استایل 1 */
    color: var(--segment-active-color);
    background-color: var(--segment-active-bg);
    border-radius: calc(var(--segment-radius) - 2px);
    margin-right: 8px; /* از استایل 1 */
    box-shadow: var(--segment-shadow);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
    user-select: none;
}

    .segment-add:hover {
        background-color: #e6f0ff;
        transform: scale(1.05);
    }

    .segment-add span {
        position: relative;
        top: -1px; /* از استایل 1 */
        font-size: 24px;
        font-weight: 600; /* از استایل 1 */
        color: #28a745;
    }

/* 🧱 محفظه سگمنت‌ها (اسکرول افقی در موبایل) */
.segment-wrapper {
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    scrollbar-width: none;
}

    .segment-wrapper::-webkit-scrollbar {
        display: none;
    }

/* 🔘 کنترل سگمنت‌ها */
.segmented-control {
    display: flex;
    position: relative;
    flex-wrap: nowrap;
    min-width: max-content;
    height: var(--segment-height);
    flex: 1;
}

/* گزینه‌های سگمنت */
.segment {
    flex: 1 0 auto;
    text-align: center;
    line-height: var(--segment-height);
    font-size: 15px;
    font-weight: 500;
    color: var(--segment-inactive-color);
    cursor: pointer;
    transition: color var(--segment-transition);
    z-index: 1;
    user-select: none;
    padding: 0 12px; /* از استایل 1 */
    min-width: 80px; /* از استایل 1 */
    max-width: 120px; /* از استایل 1 */
    white-space: nowrap;
}

    .segment.active {
        color: var(--segment-active-color);
    }

/* کاشی فعال */
.active-tile {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    background-color: var(--segment-active-bg);
    border-radius: calc(var(--segment-radius) - 2px);
    box-shadow: var(--segment-shadow);
    transition: all var(--segment-transition);
    z-index: 0;
    height: var(--segment-height);
}

/* فوکوس کیبورد */
.segment:focus-visible {
    outline: 2px solid var(--segment-active-color);
    outline-offset: 2px;
}

/* 🌐 واکنش‌گرا */
@media (max-width: 768px) {
    :root {
        --segment-height: 34px;
    }

    .segment-container {
        height: calc(var(--segment-height) + 2 * var(--segment-padding));
    }

    .segment {
        font-size: 14px;
    }

    .segment-add span {
        font-size: 22px;
        top: 0;
    }
}

@media (max-width: 480px) {
    :root {
        --segment-height: 32px;
    }

    .segment {
        font-size: 13px;
    }

    .segment-add span {
        font-size: 20px;
        top: 0;
    }
}

/* کاربران با کاهش حرکت */
@media (prefers-reduced-motion: reduce) {
    :root {
        --segment-transition: none;
    }
}
