:root {
    --black: #0d0d0d;
    --white: #faf8f4;
    --cream: #f2ede5;
    --gold: #ba9765;
    --gold-bg: #fdf7e8;
    --gray: #6b6560;
    --gray-light: #c8c3bc;
    --border: #e4dfd7;
    --overlay: rgba(8,8,8,0.65);
}
#country-selector-root[dir="rtl"] {
    direction: rtl;
}

#country-selector-root[dir="ltr"] {
    direction: ltr;
}
/* Demo */
.demo { text-align: center; padding: 48px 24px; }
.demo h1 {
    font-size: clamp(1.6rem, 3.5vw, 2.6rem);
    font-weight: 700; letter-spacing: -0.03em; margin-bottom: 6px;
}
.demo p { color: var(--gray); font-size: 0.9rem; margin-bottom: 36px; }

/* Overlay */
.overlay {
    position: fixed; inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(6px);
    z-index: 99999999;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.overlay.open { opacity: 1; pointer-events: all; }

/* Popup */
.popup {
    background: var(--white);
    width: 100%; max-width: 480px;
    border-radius: 8px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.08);
    transform: translateY(20px) scale(0.97);
    opacity: 0;
    transition: transform 0.38s cubic-bezier(.34,1.3,.64,1), opacity 0.28s ease;
    overflow: hidden;
}
.overlay.open .popup { transform: translateY(0) scale(1); opacity: 1; }

/* Header */
.popup-head {
    padding: 26px 26px 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.head-left { display: flex; flex-direction: column; gap: 3px; }
.head-title { font-weight: 700; letter-spacing: -0.02em; }
.head-sub { color: var(--gray); }

/* Lang toggle */
.head-right { display: flex; align-items: center; gap: 10px; }
.lang-pill {
    display: flex; align-items: center;
    background: var(--cream); border: 1px solid var(--border);
    border-radius: 20px; padding: 3px; gap: 1px;
}
.lang-btn {
    background: none; border: none; cursor: pointer;
    font-size: 1.3rem; font-weight: 600;
    color: var(--gray); padding: 5px 14px; border-radius: 16px;
    transition: background 0.18s, color 0.18s; letter-spacing: 0.01em;
}
.lang-btn.on {
    background: #ba9765;
    color: #fff;
}
.lang-btn:hover:not(.on) {
    color: #ba9765;
}

.close-x {
    background: none; border: none; cursor: pointer;
    color: var(--gray-light); font-size: 2rem; padding: 4px; line-height: 1;
    transition: color 0.18s;
}
.close-x:hover { color: var(--black); }

.popup-line { height: 1px; background: var(--border); }

/* Region cards */
.regions { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 9px; }

.region-card {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 18px;
    border: 2px solid var(--border); border-radius: 6px;
    cursor: pointer; background: none;
    text-align: right;
    transition: border-color 0.18s, background 0.18s, transform 0.12s, box-shadow 0.18s;
    width: 100%; color: var(--black);
    position: relative;
}
.region-card:hover {
    border-color: #ccc; background: #faf8f2;
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(0,0,0,0.06);
}
.region-card.sel {
    border-color: var(--gold); background: var(--gold-bg);
}
.region-card.sel .check-circle {
    background: var(--gold); border-color: var(--gold);
    color: #fff;
}

.card-flags { font-size: 1.8rem; line-height: 1; flex-shrink: 0; letter-spacing: -4px; }

.card-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.card-name { font-weight: 600; letter-spacing: -0.01em; }
.card-sub  { color: var(--gray); }

.check-circle {
    width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid var(--gray-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem; flex-shrink: 0;
    transition: background 0.18s, border-color 0.18s;
    margin-right: auto; /* pushes to left in RTL → visually right */
}
[dir="ltr"] .check-circle { margin-right: unset; margin-left: auto; }

/* Footer of popup */
.popup-foot {
    padding: 14px 20px 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.badge {
    font-size: 1.2rem !important;
    color: var(--gray);
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
    color: #000 !important;
}
.badge.show { opacity: 1; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); flex-shrink: 0; }

.confirm-btn {
    background: #ba9765;
    color: #fff;
    border: none;
    padding: 11px 30px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.18s, transform 0.12s;
}
.confirm-btn:hover:not(:disabled) { background: #1e1e1e; transform: translateY(-1px); }
.confirm-btn:disabled { background: var(--gray-light); cursor: not-allowed; }

/* Footer Bar */
.footer-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #111; border-top: 1px solid #222;
    height: 58px;
    display: flex; align-items: stretch; justify-content: center;
    z-index: 50;
}
.f-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 0 28px; cursor: pointer;
    border: none; background: none;
    color: rgba(255,255,255,0.4);
    transition: color 0.18s, background 0.18s;
    border-left: 1px solid #1e1e1e;
    position: relative;
}
.f-btn:first-child { border-left: none; }
.f-btn:hover { color: rgba(255,255,255,0.75); background: rgba(255,255,255,0.03); }
.f-btn.on { color: #fff; background: rgba(201,168,76,0.06); }
.f-btn.on::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 2px; background: var(--gold);
}
.f-flags { font-size: 1rem; letter-spacing: -2px; }
.f-text { display: flex; flex-direction: column; line-height: 1.3; text-align: right; }
[dir="ltr"] .f-text { text-align: left; }
.f-name { font-size: 0.78rem; font-weight: 500; }
.f-sub  { font-size: 0.62rem; opacity: 0.45; }
.region-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-langs {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.card-lang {
    color: #999;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.2s;
}

.card-lang:hover {
    color: #333;
}

.card-lang.active-lang {
    color: #333;
    font-weight: 600;
}

.card-sep {
    color: #ccc;
}
.card-lang {
    text-decoration: underline;
    cursor: pointer;
}
.flag-img {
    margin: 2px;
    width: 25px;
    height: 25px;
    object-fit: cover;
    border-radius: 3px;
    vertical-align: middle;
}
