/* ============================================================
   جاوجُم | یابنده خوابگاه — استایل ویجت
   همه‌چیز زیر .jaojom-widget اسکوپ شده تا با قالب سایت تداخل نکنه
   ============================================================ */

@font-face {
    font-family: 'JDFVazirmatn';
    src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400; font-display: swap;
}
@font-face {
    font-family: 'JDFVazirmatn';
    src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700; font-display: swap;
}
@font-face {
    font-family: 'JDFVazirmatn';
    src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-ExtraBold.woff2') format('woff2');
    font-weight: 800; font-display: swap;
}

.jaojom-widget, .jaojom-widget *, .jaojom-widget *::before, .jaojom-widget *::after { box-sizing: border-box; }
.jaojom-widget button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
.jaojom-widget a { text-decoration: none; color: inherit; }
.jaojom-widget input { font: inherit; color: inherit; }
.jaojom-widget h1, .jaojom-widget h2, .jaojom-widget h3, .jaojom-widget p { margin: 0; }
.jaojom-widget ul, .jaojom-widget li { list-style: none; margin: 0; padding: 0; }
.jaojom-widget svg { display: block; }

.jaojom-widget {
    /* ── توکن‌های رنگ ── */
    --jw-ink: #23201B;
    --jw-paper: #FBF8F3;
    --jw-panel: #FFFFFF;
    --jw-clay: #B4652F;
    --jw-clay-deep: #8C4A20;
    --jw-amber: #E08A3E;
    --jw-amber-deep: #C06B22;
    --jw-sage: #56705A;
    --jw-line: #E7DFD2;
    --jw-muted: #8A8177;
    --jw-pink: #C6577A;
    --jw-blue: #3E6FA0;
    --jw-shadow: 0 16px 40px -14px rgba(35, 32, 27, 0.28);
    --jw-shadow-sm: 0 4px 14px -4px rgba(35, 32, 27, 0.18);
    --jw-r-sm: 10px;
    --jw-r-md: 16px;
    --jw-r-lg: 26px;

    direction: rtl;
    position: relative;
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    height: min(720px, 86vh);
    min-height: 460px;
    background: var(--jw-paper);
    border-radius: var(--jw-r-lg);
    overflow: hidden;
    box-shadow: var(--jw-shadow);
    font-family: 'JDFVazirmatn', Tahoma, Arial, sans-serif;
    color: var(--jw-ink);
    isolation: isolate;
    line-height: 1.6;
}

.jaojom-widget:focus-visible,
.jaojom-widget *:focus-visible {
    outline: 2px solid var(--jw-amber-deep);
    outline-offset: 2px;
}

/* ── لودر اولیه ── */
.jw-loader {
    position: absolute; inset: 0; z-index: 500;
    display: flex; align-items: center; justify-content: center;
    background: var(--jw-paper);
    transition: opacity .4s ease;
}
.jw-loader.jw-hide { opacity: 0; pointer-events: none; }
.jw-spinner {
    width: 44px; height: 44px;
    border: 4px solid var(--jw-line);
    border-top-color: var(--jw-amber);
    border-radius: 50%;
    animation: jw-spin 0.9s linear infinite;
}
.jw-mini-spinner {
    width: 14px; height: 14px; flex-shrink: 0;
    border: 2px solid var(--jw-line);
    border-top-color: var(--jw-clay);
    border-radius: 50%;
    animation: jw-spin 0.7s linear infinite;
}
@keyframes jw-spin { to { transform: rotate(360deg); } }

/* ── مدیریت صفحه‌ها ── */
.jw-view {
    position: absolute; inset: 0;
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .3s ease;
    overflow-y: auto;
}
.jw-view.is-active { opacity: 1; visibility: visible; pointer-events: auto; }

/* ══════════════════════════════
   صفحه ۱: انتخاب جنسیت
   ══════════════════════════════ */
.jw-hero {
    height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2rem 1.5rem;
    text-align: center;
    background:
        radial-gradient(circle at 15% 15%, rgba(224,138,62,0.10), transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(86,112,90,0.08), transparent 45%);
}
.jw-eyebrow {
    display: inline-block;
    font-weight: 700; font-size: 0.78rem;
    letter-spacing: 0.06em;
    color: var(--jw-clay-deep);
    background: rgba(180, 101, 47, 0.1);
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    margin-bottom: 1.1rem;
}
.jw-title {
    font-weight: 800; font-size: clamp(1.5rem, 4vw, 2.15rem);
    line-height: 1.35;
    max-width: 32rem;
    color: var(--jw-ink);
}
.jw-sub {
    margin-top: 0.85rem;
    color: var(--jw-muted);
    font-size: 1rem;
    max-width: 30rem;
}
.jw-gender-grid {
    margin-top: 2.2rem;
    display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
    width: 100%; max-width: 28rem;
}
.jw-gender-card {
    --accent: var(--jw-clay);
    background: var(--jw-panel);
    border: 1.5px solid var(--jw-line);
    border-radius: var(--jw-r-md);
    padding: 1.6rem 1rem;
    display: flex; flex-direction: column; align-items: center; gap: 0.7rem;
    box-shadow: var(--jw-shadow-sm);
    transition: transform .25s cubic-bezier(.2,.8,.2,1), border-color .25s ease, box-shadow .25s ease;
    opacity: 0; transform: translateY(14px);
    animation: jw-rise .5s ease forwards;
    animation-delay: .1s;
}
.jw-gender-card:nth-child(2) { animation-delay: .2s; }
.jw-view.is-active .jw-gender-card { animation-play-state: running; }
@keyframes jw-rise { to { opacity: 1; transform: translateY(0); } }

.jw-gender-card:hover, .jw-gender-card:focus-visible {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 14px 30px -10px color-mix(in srgb, var(--accent) 45%, transparent);
}
.jw-gender-icon {
    width: 52px; height: 52px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--accent) 14%, white);
    color: var(--accent);
}
.jw-gender-icon svg { width: 26px; height: 26px; }
.jw-gender-label { font-weight: 700; font-size: 1.05rem; }

/* ══════════════════════════════
   صفحه ۲: انتخاب موقعیت
   ══════════════════════════════ */
.jw-map-picker { position: relative; height: 100%; }
.jw-picker-map { position: absolute; inset: 0; background: #EDEAE2; }

.jw-center-pin {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -100%);
    z-index: 10; pointer-events: none;
    color: var(--jw-clay-deep);
    filter: drop-shadow(0 6px 8px rgba(35,32,27,0.28));
}
.jw-center-pin svg { width: 34px; height: 34px; }

.jw-picker-top {
    position: absolute; top: 1rem; left: 50%; transform: translateX(-50%);
    width: calc(100% - 2rem); max-width: 30rem; z-index: 20;
}
.jw-searchbar {
    display: flex; align-items: center; gap: 0.4rem;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    border: 1px solid var(--jw-line);
    border-radius: 999px;
    padding: 0.4rem;
    box-shadow: var(--jw-shadow-sm);
}
.jw-input {
    flex: 1; height: 2.4rem; padding: 0 0.6rem;
    background: transparent; border: none; outline: none;
    font-size: 0.95rem;
}
.jw-input::placeholder { color: var(--jw-muted); }
.jw-icon-btn {
    flex-shrink: 0; width: 2.4rem; height: 2.4rem;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--jw-paper);
    color: var(--jw-ink);
    transition: background .2s ease, transform .2s ease;
}
.jw-icon-btn:hover { transform: scale(1.06); }
.jw-icon-btn svg { width: 18px; height: 18px; }
.jw-icon-btn--accent { background: var(--jw-amber); color: #fff; }
.jw-icon-btn--accent:hover { background: var(--jw-amber-deep); }
.jw-icon-btn--ghost {
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--jw-line);
    box-shadow: var(--jw-shadow-sm);
}

.jw-address-status {
    display: none; align-items: center; gap: 0.5rem;
    margin-top: 0.6rem; padding: 0.45rem 0.9rem;
    background: rgba(255,255,255,0.92);
    border-radius: 999px; font-size: 0.82rem; color: var(--jw-muted);
    box-shadow: var(--jw-shadow-sm); width: fit-content;
}
.jw-address-status.is-visible { display: flex; }

.jw-picker-bottom {
    position: absolute; bottom: 1rem; left: 50%; transform: translateX(-50%);
    width: calc(100% - 2rem); max-width: 30rem; z-index: 20;
}
.jw-cta {
    width: 100%; min-height: 3.1rem;
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    background: linear-gradient(135deg, var(--jw-amber), var(--jw-amber-deep));
    color: #fff; font-weight: 700; font-size: 1.02rem;
    border-radius: var(--jw-r-md);
    box-shadow: 0 10px 24px -8px rgba(192,107,34,0.55);
    transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.jw-cta:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 28px -8px rgba(192,107,34,0.6); }
.jw-cta:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.jw-cta .jw-mini-spinner { border-color: rgba(255,255,255,0.4); border-top-color: #fff; }

/* ══════════════════════════════
   صفحه ۳: داشبورد
   ══════════════════════════════ */
.jw-dashboard { height: 100%; display: flex; flex-direction: column; }
@media (min-width: 860px) {
    .jw-dashboard { flex-direction: row-reverse; }
}

.jw-map-pane { position: relative; flex: 1; min-height: 42%; }
.jw-dash-map { position: absolute; inset: 0; background: #EDEAE2; }
.jw-map-controls {
    position: absolute; top: 1rem; left: 1rem; z-index: 30;
    display: flex; flex-direction: column; gap: 0.5rem;
}

.jw-panel {
    position: relative;
    background: var(--jw-panel);
    border-top: 1px solid var(--jw-line);
    display: flex; flex-direction: column;
    flex: 1; min-height: 0;
}
@media (min-width: 860px) {
    .jw-panel { width: 360px; flex: none; border-top: none; border-inline-start: 1px solid var(--jw-line); }
}

.jw-panel-handle {
    display: flex; justify-content: center; padding: 0.6rem;
    flex-shrink: 0; cursor: grab;
}
@media (min-width: 860px) { .jw-panel-handle { display: none; } }
.jw-handle-bar { width: 40px; height: 4px; border-radius: 999px; background: var(--jw-line); }

.jw-panel-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0.25rem 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.85rem; }

.jw-card {
    background: var(--jw-paper);
    border: 1.5px solid var(--jw-line);
    border-radius: var(--jw-r-md);
    padding: 1rem;
    transition: border-color .25s ease, box-shadow .25s ease, background .25s ease;
}
.jw-card.is-active { background: var(--jw-panel); border-color: var(--jw-amber); box-shadow: 0 0 0 4px rgba(224,138,62,0.14); }

.jw-card-top { display: flex; align-items: flex-start; gap: 0.7rem; }
.jw-rank {
    flex-shrink: 0; width: 1.9rem; height: 1.9rem;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.85rem;
    background: var(--jw-clay); color: #fff;
}
.jw-card.is-active .jw-rank { background: var(--jw-amber-deep); }
.jw-card-head { flex: 1; min-width: 0; }
.jw-card-head h3 { font-weight: 700; font-size: 1.02rem; }
.jw-access { margin-top: 0.35rem; display: flex; flex-wrap: wrap; gap: 0.7rem; }
.jw-access span { display: flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; color: var(--jw-muted); }
.jw-access svg { width: 14px; height: 14px; flex-shrink: 0; }
.jw-distance { flex-shrink: 0; text-align: center; }
.jw-distance b { font-size: 1.15rem; font-weight: 800; color: var(--jw-clay-deep); font-variant-numeric: tabular-nums; }
.jw-distance span { display: block; font-size: 0.68rem; color: var(--jw-muted); }

.jw-card-actions { margin-top: 0.9rem; display: flex; flex-direction: column; gap: 0.5rem; }
.jw-btn {
    display: flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.6rem; border-radius: var(--jw-r-sm);
    font-size: 0.85rem; font-weight: 700;
    transition: transform .2s ease, background .2s ease;
}
.jw-btn--primary { background: linear-gradient(135deg, var(--jw-amber), var(--jw-amber-deep)); color: #fff; }
.jw-btn--primary:hover { transform: translateY(-1px); }
.jw-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.jw-btn--ghost { background: var(--jw-panel); border: 1px solid var(--jw-line); color: var(--jw-ink); }
.jw-btn--ghost:hover { border-color: var(--jw-clay); }
.jw-btn svg { width: 15px; height: 15px; }

/* ── مارکرهای نقشه ── */
.jw-pin-dorm {
    width: 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--jw-clay); color: #fff;
    font-weight: 800; font-size: 12px;
    border: 2px solid #fff;
    box-shadow: 0 3px 8px rgba(35,32,27,0.35);
    transition: transform .25s ease, background .25s ease;
}
.jw-pin-dorm.is-active { background: var(--jw-amber-deep); transform: scale(1.25); z-index: 1000 !important; }

.jw-pin-user {
    width: 22px; height: 22px; position: relative;
    display: flex; align-items: center; justify-content: center;
}
.jw-pin-user .jw-pin-user-dot {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--jw-sage); border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(35,32,27,0.35);
    position: relative; z-index: 2;
}
.jw-pin-user .jw-pin-ring {
    position: absolute; inset: 0; border-radius: 50%;
    border: 2px solid var(--jw-sage);
    animation: jw-ring 2.2s ease-out infinite;
}
.jw-pin-user .jw-pin-ring.jw-ring-2 { animation-delay: 1.1s; }
@keyframes jw-ring {
    0% { transform: scale(0.6); opacity: 0.7; }
    100% { transform: scale(2.6); opacity: 0; }
}

.jw-tooltip {
    background: var(--jw-ink); color: #fff; border: none;
    font-family: 'JDFVazirmatn', Tahoma, sans-serif;
    font-weight: 700; font-size: 12px;
    border-radius: 8px; padding: 5px 10px;
    box-shadow: var(--jw-shadow-sm);
}

.jaojom-widget .leaflet-container { font-family: 'JDFVazirmatn', Tahoma, sans-serif; background: #EDEAE2; }
.jaojom-widget .leaflet-bar { box-shadow: none !important; border-radius: var(--jw-r-sm) !important; overflow: hidden; }
.jaojom-widget .leaflet-bar a {
    background: rgba(255,255,255,0.92) !important; color: var(--jw-ink) !important;
    width: 34px !important; height: 34px !important; line-height: 34px !important;
    border-bottom: 1px solid var(--jw-line) !important;
}
.jaojom-widget .leaflet-bar a:hover { background: #fff !important; }

.jw-map-error {
    position: absolute; inset: 0; z-index: 15;
    display: flex; align-items: center; justify-content: center; text-align: center;
    padding: 2rem; background: var(--jw-paper); color: var(--jw-clay-deep); font-weight: 700;
}
