/**
 * ICSD Theme — Visitor Appearance Widget
 * ---------------------------------------------------------------
 * ویجت شناور شخصی‌سازی ظاهر برای بازدیدکننده.
 * تنظیمات فقط در localStorage مرورگر خودِ بازدیدکننده ذخیره می‌شود.
 *
 * @package ICSD
 * @since   1.5.0
 */

.icsd-appearance {
    position: fixed;
    bottom: 90px;                 /* بالای دکمهٔ «برو بالا» */
    left: 30px;                   /* هم‌راستا با .icsd-scroll-top که فیزیکی چپ است */
    z-index: 1200;
    font-family: 'Vazirmatn', system-ui, sans-serif;
}

/* ===============================================================
   دکمهٔ باز کردن
   =============================================================== */
.icsd-appearance__toggle {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--icsd-border-strong);
    background: var(--icsd-surface);
    color: var(--icsd-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--icsd-shadow);
    transition: transform 0.25s, background 0.25s, color 0.25s, border-color 0.25s;
    padding: 0;
}
.icsd-appearance__toggle:hover {
    background: var(--icsd-primary);
    color: var(--icsd-text-on-primary);
    border-color: var(--icsd-primary);
    transform: translateY(-3px);
}
.icsd-appearance__toggle:focus-visible {
    outline: 2px solid var(--icsd-primary);
    outline-offset: 3px;
}
.icsd-appearance__toggle svg { width: 22px; height: 22px; }
.icsd-appearance.is-open .icsd-appearance__toggle svg { transform: rotate(90deg); transition: transform 0.3s; }

/* ===============================================================
   پنل
   =============================================================== */
.icsd-appearance__panel {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    width: 288px;
    max-width: calc(100vw - 40px);
    padding: 18px;
    background: var(--icsd-bg-elev);
    border: 1px solid var(--icsd-border-strong);
    border-radius: 18px;
    box-shadow: var(--icsd-shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.97);
    transform-origin: bottom left;
    transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.22s;
}
.icsd-appearance.is-open .icsd-appearance__panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.icsd-appearance__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--icsd-border);
}
.icsd-appearance__head h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--icsd-text);
}
.icsd-appearance__close {
    background: transparent;
    border: none;
    color: var(--icsd-text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 0;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
}
.icsd-appearance__close:hover { color: var(--icsd-primary); background: var(--icsd-primary-soft); }

/* ===============================================================
   گروه‌های تنظیمات
   =============================================================== */
.icsd-appearance__group { margin-bottom: 16px; }
.icsd-appearance__group:last-of-type { margin-bottom: 0; }

.icsd-appearance__label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--icsd-text-muted);
    margin-bottom: 8px;
}

/* --- ردیف دکمه‌ها (حالت / اندازه) --- */
.icsd-appearance__row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 6px;
    padding: 4px;
    background: var(--icsd-surface-2);
    border-radius: 12px;
}
.icsd-appearance__opt {
    border: none;
    background: transparent;
    color: var(--icsd-text-2);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 4px;
    border-radius: 9px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.icsd-appearance__opt:hover { color: var(--icsd-primary); }
.icsd-appearance__opt[aria-pressed="true"] {
    background: var(--icsd-bg-elev);
    color: var(--icsd-primary);
    box-shadow: var(--icsd-shadow-sm);
}
.icsd-appearance__opt svg { width: 14px; height: 14px; }
.icsd-appearance__opt--sm  { font-size: 11px; }
.icsd-appearance__opt--md  { font-size: 13px; }
.icsd-appearance__opt--lg  { font-size: 15px; }

/* --- سواچ‌های رنگ --- */
.icsd-appearance__skins {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.icsd-appearance__skin {
    position: relative;
    border: 2px solid transparent;
    background: var(--icsd-surface-2);
    border-radius: 12px;
    padding: 8px 4px 6px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.icsd-appearance__skin:hover { transform: translateY(-2px); }
.icsd-appearance__skin[aria-pressed="true"] { border-color: var(--icsd-primary); background: var(--icsd-bg-elev); }
.icsd-appearance__skin i {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: block;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.icsd-appearance__skin span {
    font-size: 9.5px;
    font-weight: 600;
    color: var(--icsd-text-muted);
    line-height: 1.4;
    text-align: center;
}
.icsd-appearance__skin[aria-pressed="true"] span { color: var(--icsd-primary); }

.icsd-swatch--emerald { background: linear-gradient(135deg, #1E9E7B, #5DDCB4); }
.icsd-swatch--ocean   { background: linear-gradient(135deg, #2563EB, #7DA9FF); }
.icsd-swatch--carpet  { background: linear-gradient(135deg, #C0453A, #C99A3F); }
.icsd-swatch--violet  { background: linear-gradient(135deg, #7C3AED, #B79BFB); }

/* --- سوییچ‌های دوحالته --- */
.icsd-appearance__switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 0;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--icsd-text-2);
    text-align: start;
}
.icsd-appearance__switch:hover { color: var(--icsd-primary); }
.icsd-appearance__switch + .icsd-appearance__switch { border-top: 1px solid var(--icsd-border); }
.icsd-appearance__track {
    flex-shrink: 0;
    width: 38px;
    height: 21px;
    border-radius: 100px;
    background: var(--icsd-surface-2);
    border: 1px solid var(--icsd-border-strong);
    position: relative;
    transition: background 0.25s, border-color 0.25s;
}
.icsd-appearance__track::after {
    content: '';
    position: absolute;
    top: 2px;
    inset-inline-start: 2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--icsd-text-muted);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.25s;
}
.icsd-appearance__switch[aria-pressed="true"] .icsd-appearance__track {
    background: var(--icsd-primary);
    border-color: var(--icsd-primary);
}
.icsd-appearance__switch[aria-pressed="true"] .icsd-appearance__track::after {
    background: var(--icsd-text-on-primary);
    transform: translateX(-17px);          /* RTL: حرکت به چپ */
}

/* --- بازنشانی --- */
.icsd-appearance__reset {
    width: 100%;
    margin-top: 14px;
    padding: 9px;
    background: transparent;
    border: 1px dashed var(--icsd-border-strong);
    border-radius: 10px;
    color: var(--icsd-text-muted);
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.icsd-appearance__reset:hover {
    color: var(--icsd-primary);
    border-color: var(--icsd-primary-border);
    background: var(--icsd-primary-soft);
}

.icsd-appearance__note {
    margin: 10px 0 0;
    font-size: 10px;
    line-height: 1.7;
    color: var(--icsd-text-muted);
    text-align: center;
}

/* ===============================================================
   موبایل
   =============================================================== */
@media (max-width: 575px) {
    .icsd-appearance { bottom: 84px; left: 20px; }
    .icsd-appearance__toggle { width: 44px; height: 44px; }
    .icsd-appearance__panel { width: calc(100vw - 40px); }
    .icsd-appearance__skins { grid-template-columns: repeat(4, 1fr); }
}

/* هنگام چاپ نمایش داده نشود */
@media print {
    .icsd-appearance { display: none !important; }
}
