/* ============================================================
   MINIJAYA GEMS — SETTINGS PAGE STYLES (settings.html only)
   Shared chrome (sidebar, nav, search, mobile bars, footer,
   cart drawer, toasts, modal) lives in shared.css.
   Everything below adapts to light/dark via the CSS variables
   defined in shared.css.
   ============================================================ */

/* ============================================================
   THEME SAFETY NET
   Mirrors the light-theme variables from shared.css. If the live
   layout/shared.css is an older revision without its light-theme
   block, the Appearance toggle still works fully on this page.
   Same values, so it is a harmless no-op when shared.css is up
   to date.
   ============================================================ */
body.light-theme {
    --bg-color: #fcfaf7;
    --text-color: #1a1a1a;
    --sidebar-bg: rgba(255, 255, 255, 0.7);
    --sidebar-hover: rgba(255, 255, 255, 0.98);
    --card-bg: #ffffff;
    --border-color: rgba(0, 0, 0, 0.1);
    --nav-link-color: #444;
    --input-bg: #f0f0f0;
    --glass: rgba(0, 0, 0, 0.03);
    --mobile-nav-bg: rgba(252, 250, 247, 0.98);
}

/* ============ STICKY NAV ENABLER ============ */
/* shared.css sets html/body to overflow-x: hidden, which silently disables
   position: sticky for every descendant (body becomes the sticky containing
   box instead of the viewport). overflow-x: clip keeps the identical
   horizontal-overflow protection without creating a scroll container. */
html, body { overflow-x: clip; }

/* ============ PAGE SHELL ============ */
.settings-main {
    position: relative;
    z-index: 2;
    padding: 84px 5% 0;
    min-height: 70vh;
}
.settings-main::before {
    content: '';
    position: absolute;
    top: -40px; left: 50%;
    transform: translateX(-50%);
    width: min(640px, 90vw); height: 420px;
    background: radial-gradient(circle, rgba(198,168,123,0.07) 0%, transparent 65%);
    pointer-events: none;
}

/* ============ TOP ACCOUNT HERO (full-width, above the fold) ============ */
.account-hero {
    max-width: 1100px;
    margin: 0 auto 32px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 36px 40px;
    position: relative;
    overflow: hidden;
    scroll-margin-top: 92px;
}
.account-hero::before {
    content: '';
    position: absolute;
    top: -60%; right: -10%;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(198,168,123,0.08) 0%, transparent 70%);
    pointer-events: none;
}
.account-hero-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    position: relative;
    z-index: 1;
}

/* Large avatar in the hero — this is the element that flies to nav */
.profile-avatar-xl {
    width: 88px; height: 88px;
    border-radius: 50%;
    border: 2px solid rgba(198,168,123,0.4);
    background: var(--glass);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    color: var(--gold);
    font-size: 2rem;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 8px 32px rgba(198,168,123,0.12);
    will-change: transform, opacity, filter;
}
.profile-avatar-xl img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: none;
}
.profile-avatar-xl.has-photo img { display: block; }
.profile-avatar-xl.has-photo i { display: none; }

.account-hero-info { flex: 1; min-width: 0; }
.account-hero-name {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.8rem; font-weight: 600; line-height: 1.15;
    letter-spacing: 0.5px;
}
.account-hero-email {
    font-size: 0.78rem; color: #888; margin-top: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-hero-meta {
    display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap;
}
.member-chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 12px; border-radius: 20px;
    font-size: 0.55rem; font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
    color: var(--gold); background: rgba(198,168,123,0.07);
    border: 1px solid rgba(198,168,123,0.35);
}
.member-chip i { font-size: 0.6rem; }
.account-status-inline {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 0.65rem; letter-spacing: 1.5px; text-transform: uppercase;
    color: #666;
}
.account-status-inline .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; flex-shrink: 0;
}
.account-status-inline.active { color: var(--gold); }

/* Sign-in / Sign-out row inside hero */
.account-hero-actions {
    display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}

/* ============ LAYOUT (below hero) ============ */
.settings-layout {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 36px;
    max-width: 1100px;
    margin: 0 auto;
    padding-bottom: 5rem;
    align-items: start;
}

/* ============ SECTION NAV (sticky, scrollspy) ============ */
.settings-nav {
    position: sticky; top: 96px;
    display: flex; flex-direction: column; gap: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px; padding: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.18);
}
.settings-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 10px;
    color: var(--nav-link-color); text-decoration: none;
    font-size: 0.72rem; letter-spacing: 1.5px; text-transform: uppercase;
    transition: background 0.3s, color 0.3s;
    white-space: nowrap;
}
.settings-nav a i {
    color: var(--gold); width: 18px; text-align: center;
    font-size: 0.85rem; opacity: 0.75; transition: opacity 0.3s;
}
.settings-nav a:hover { color: var(--text-color); background: var(--glass); }
.settings-nav a:hover i { opacity: 1; }
.settings-nav a.active { background: rgba(198,168,123,0.1); color: var(--gold); }

/* ============ PANELS ============ */
.settings-content { display: flex; flex-direction: column; gap: 26px; min-width: 0; }
.settings-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 30px;
    scroll-margin-top: 92px;
}
.panel-header { display: flex; align-items: center; gap: 14px; }
.panel-icon {
    width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
    background: rgba(198,168,123,0.08);
    border: 1px solid rgba(198,168,123,0.22);
    color: var(--gold);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.95rem;
}
.panel-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem; font-weight: 600; letter-spacing: 1px;
}
.panel-desc { font-size: 0.72rem; color: #777; letter-spacing: 0.5px; margin: 10px 0 4px; }
.panel-divider { height: 1px; background: var(--border-color); margin: 20px 0; }

/* ============ SETTING ROWS ============ */
.setting-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 14px 0;
}
.setting-row + .setting-row { border-top: 1px solid var(--border-color); }
.setting-info h4 {
    font-size: 0.82rem; font-weight: 600; letter-spacing: 0.5px;
    margin-bottom: 3px;
}
.setting-info p {
    font-size: 0.7rem; color: #777; letter-spacing: 0.3px;
}

/* ============ STATUS VALUES ============ */
.status-value {
    font-size: 0.68rem; letter-spacing: 2px; text-transform: uppercase;
    color: var(--gold); flex-shrink: 0;
    display: inline-flex; align-items: center; gap: 7px;
}
.status-value.muted { color: #666; }
.status-value .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ============ AVATAR DOCK IN TOP NAV (fly-to-nav target) ============ */
/* Invisible slot that reserves the dock position inside the nav bars so the
   layout never jumps; the flying clone lands exactly on top of it. */
.nav-avatar-anchor {
    width: 34px; height: 34px; border-radius: 50%;
    flex-shrink: 0; position: relative;
    margin-left: 16px;
    transition: width 0.4s var(--s-ease, ease), margin-left 0.4s ease;
}

/* The flying clone — GSAP controls transform, opacity, filter */
.nav-avatar-clone {
    position: fixed; top: 0; left: 0;
    width: 88px; height: 88px; border-radius: 50%;
    border: 2px solid rgba(198,168,123,0.4);
    background: var(--card-bg);
    color: var(--gold); font-size: 2rem;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    z-index: 1500;
    opacity: 0;
    pointer-events: none;
    will-change: transform, opacity, filter;
    box-shadow: 0 8px 26px rgba(0,0,0,0.28);
    transform-origin: 0 0; /* x/y target the anchor's top-left corner, so scale must shrink from that same corner, not the center */
}
.nav-avatar-clone img { width: 100%; height: 100%; object-fit: cover; display: none; }
.nav-avatar-clone.has-photo img { display: block; }
.nav-avatar-clone.has-photo i { display: none; }
.nav-avatar-clone.live { pointer-events: auto; }
.nav-avatar-clone.docked { cursor: pointer; }

/* ============ LIGHT-THEME POLISH (page grays) ============ */
body.light-theme .panel-desc { color: #666; }
body.light-theme .account-hero-email { color: #666; }
body.light-theme .account-status-inline { color: #777; }
body.light-theme .status-value.muted { color: #777; }
body.light-theme .settings-nav { box-shadow: 0 20px 50px rgba(0,0,0,0.08); }
body.light-theme .slider { background-color: #d8d3ca; }

/* ============ SELECT WRAP (gold chevron) ============ */
.select-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.select-wrap::after {
    content: '';
    position: absolute; right: 13px; top: 50%;
    transform: translateY(-40%);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--gold);
    pointer-events: none;
}
.select-wrap select { padding-right: 32px; cursor: pointer; transition: border-color 0.3s; }
.select-wrap select:hover { border-color: rgba(198,168,123,0.4); }

/* ============ FORM INPUTS ============ */
.setting-input {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    outline: none;
    transition: border-color 0.3s;
}
.setting-input:focus { border-color: var(--gold); }

/* ============ TOGGLE SWITCH ============ */
.theme-switch {
    position: relative; display: inline-block;
    width: 46px; height: 26px; flex-shrink: 0;
}
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0;
    background-color: #3a3a3a;
    border-radius: 26px;
    cursor: pointer;
    transition: background-color 0.3s;
}
.slider::before {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #fff;
    bottom: 3px; left: 3px;
    transition: transform 0.3s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.theme-switch input:checked + .slider { background-color: var(--gold); }
.theme-switch input:checked + .slider::before { transform: translateX(20px); }

/* ============ BUTTONS ============ */
.settings-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 22px; border-radius: 30px;
    font-family: 'Inter', sans-serif; font-size: 0.68rem; font-weight: 600;
    letter-spacing: 2px; text-transform: uppercase;
    cursor: pointer; transition: all 0.3s;
    border: 1px solid transparent; flex-shrink: 0; white-space: nowrap;
}
.settings-btn.gold {
    background: var(--gold); color: #000;
}
.settings-btn.gold:hover {
    background: var(--gold-bright); transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(198,168,123,0.25);
}
.settings-btn.ghost {
    background: none; border-color: var(--border-color); color: var(--text-color);
}
.settings-btn.ghost:hover { border-color: var(--gold); color: var(--gold); }
.settings-btn.danger {
    background: rgba(255,80,80,0.08); border-color: rgba(255,80,80,0.25); color: #ff5050;
}
.settings-btn.danger:hover { background: rgba(255,80,80,0.15); transform: translateY(-1px); }

/* ============ DANGER PANEL ============ */
.settings-panel.danger { border-color: rgba(255,80,80,0.18); }
.settings-panel.danger .panel-icon {
    background: rgba(255,80,80,0.06);
    border-color: rgba(255,80,80,0.22);
    color: #ff5050;
}
.settings-panel.danger .panel-title { color: #ff5050; }

/* ============ GOOGLE SIGN-IN TARGET ============ */
#settings-google-target { min-width: 140px; display: flex; justify-content: flex-end; }

/* ============ AMBIENT FX OFF GUARD ============ */
body.fx-off #cursor-glow,
body.fx-off .dust { display: none !important; }

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
    /* block flow so the tab strip's sticky containment spans the whole page
       (inside a single-column grid, a sticky item cannot leave its grid row) */
    .settings-layout { display: block; }
    .settings-nav {
        position: sticky; top: 56px; z-index: 900;
        flex-direction: row; align-items: center;
        overflow-x: auto; padding: 8px;
        margin-bottom: 22px;
        background: var(--mobile-nav-bg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .settings-nav::-webkit-scrollbar { display: none; }
    .settings-nav a { flex-shrink: 0; padding: 9px 14px; }
}
@media (max-width: 768px) {
    .settings-main { padding: 86px 4% 0; }
    .account-hero { padding: 24px 20px; border-radius: 18px; }
    .account-hero-inner { gap: 16px; flex-wrap: wrap; }
    .profile-avatar-xl { width: 64px; height: 64px; font-size: 1.5rem; }
    .account-hero-name { font-size: 1.35rem; }
    .account-hero-actions { width: 100%; justify-content: flex-start; margin-top: 4px; flex-basis: 100%; }
    .settings-panel { padding: 22px 18px; border-radius: 16px; scroll-margin-top: 118px; }
    .nav-avatar-anchor { width: 30px; height: 30px; margin-left: 8px; }
    .nav-avatar-clone { width: 64px; height: 64px; font-size: 1.5rem; }
    /* collapse the dock slot while the mobile search field is expanded */
    .mobile-top-bar.search-open #navAvatarAnchorMobile,
    .mobile-top-bar:has(.mobile-search-bar.expanded) #navAvatarAnchorMobile { width: 0; margin-left: 0; }
    .setting-row { flex-wrap: wrap; }
    #settings-google-target { justify-content: flex-start; }
    .settings-btn { padding: 10px 18px; }
}
