/* ══════════════════════════════════════
   Viscar - Top Bar: Nav, Auth, Dropdown
   ══════════════════════════════════════ */

/* 3-column layout */
.top-bar { display: grid !important; grid-template-columns: auto 1fr auto; align-items: center; gap: 1.5rem; }

/* Center navigation - bigger & bolder */
.top-nav { display: flex; align-items: center; justify-content: center; gap: 0.15rem; }
.top-nav-link {
    padding: 0.45rem 1.05rem; border-radius: 0.5rem;
    font-size: 0.94rem; font-weight: 600; color: var(--txt2);
    text-decoration: none; transition: color 0.2s, background 0.2s;
    letter-spacing: 0.01em;
}
.top-nav-link:hover { color: var(--cyan); background: rgba(0,194,255,0.06); }
.top-nav-link.active { color: var(--txt); }

    /* ── Try Demo nav link - subtle gold accent ── */
    .top-nav-link#demoNavLink {
        color: #c4a35f;
        background: rgba(196, 163, 95, 0.08);
        border: 1px solid rgba(196, 163, 95, 0.22);
        font-weight: 600;
    }

        .top-nav-link#demoNavLink:hover {
            color: #d4b76e;
            background: rgba(196, 163, 95, 0.14);
            border-color: rgba(196, 163, 95, 0.38);
        }

/* Auth buttons group */
.top-auth { display: flex; align-items: center; gap: 0.55rem; }

/* Prevent flash: hide until auth state resolved */
.top-auth[data-state="loading"] > * { visibility: hidden; }

/* Log In */
.top-auth-login {
    padding: 0.42rem 1.05rem; border-radius: 0.5rem; border: none;
    background: transparent; color: var(--txt2);
    font-family: var(--font); font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: color 0.2s, background 0.2s;
}
.top-auth-login:hover { color: var(--cyan); background: rgba(0,194,255,0.06); }

/* Sign Up */
.top-auth-signup {
    padding: 0.44rem 1.2rem; border-radius: 0.5rem; border: none;
    background: var(--blue); color: #fff;
    font-family: var(--font); font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s; letter-spacing: 0.01em;
}
.top-auth-signup:hover { background: #3a80ff; box-shadow: 0 4px 16px rgba(30,111,255,0.35); transform: translateY(-1px); }

/* Dashboard link (when logged in) */
.top-auth-dash {
    padding: 0.42rem 1.05rem; border-radius: 0.5rem; border: none;
    background: transparent; color: var(--txt2);
    font-family: var(--font); font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: color 0.2s, background 0.2s;
    text-decoration: none; display: inline-flex; align-items: center;
}
.top-auth-dash:hover { color: var(--cyan); background: rgba(0,194,255,0.06); }

/* ── Profile Avatar + Dropdown ── */
.profile-menu { position: relative; }
.profile-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--violet));
    border: 2px solid transparent;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: #fff;
    cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s;
    user-select: none; padding: 0; font-family: inherit;
}
.profile-avatar:hover { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0,194,255,0.15); }

.profile-dropdown {
    display: none; position: absolute; top: calc(100% + 8px); right: 0;
    width: 220px; background: var(--bg3);
    border: 1px solid var(--border); border-radius: 0.75rem;
    box-shadow: 0 16px 48px rgba(0,0,0,0.45);
    padding: 0.4rem 0; z-index: 500;
    animation: dropIn 0.18s ease;
}
.profile-dropdown.open { display: block; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.profile-dropdown a, .profile-dropdown button {
    display: flex; align-items: center; gap: 0.65rem;
    width: 100%; padding: 0.6rem 1rem; border: none;
    background: transparent; color: var(--txt2);
    font-family: var(--font); font-size: 0.85rem; font-weight: 500;
    text-decoration: none; cursor: pointer; transition: all 0.15s;
    text-align: left;
}
.profile-dropdown a:hover, .profile-dropdown button:hover { color: var(--cyan); background: rgba(0,194,255,0.06); }
.profile-dropdown svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.5; }
.profile-dropdown a:hover svg, .profile-dropdown button:hover svg { opacity: 1; }
.profile-dd-divider { height: 1px; background: var(--border2); margin: 0.3rem 0; }

.profile-dropdown button.dd-logout { color: var(--red); }
.profile-dropdown button.dd-logout:hover { background: rgba(255,69,58,0.06); color: var(--red); }

/* ── Mobile nav: hamburger button (shown ≤600px) ── */
.nav-toggle {
    display: none;
    width: 40px; height: 40px; padding: 0;
    flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    background: transparent; border: 1px solid var(--border2); border-radius: 0.5rem;
    cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.nav-toggle:hover { border-color: var(--border); background: rgba(255,255,255,0.03); }
.nav-toggle span {
    display: block; width: 18px; height: 2px; border-radius: 2px;
    background: var(--txt2); transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Mobile */
@media (max-width: 768px) {
    .top-bar { gap: 0.5rem; }
    .top-nav-link { font-size: 0.82rem; padding: 0.35rem 0.55rem; }
    .top-auth-login, .top-auth-dash { font-size: 0.82rem; padding: 0.5rem 0.7rem; min-height: 40px; }
    .top-auth-signup { font-size: 0.82rem; padding: 0.5rem 0.85rem; min-height: 40px; }
}

/* Phones: collapse the inline nav into a hamburger dropdown so the links stay
   reachable (they used to be hidden at ≤480px with no replacement). */
@media (max-width: 600px) {
    .nav-toggle { display: flex; }
    /* Reclaim space on narrow screens: keep the logo mark, drop the wordmark. */
    .top-logo-text { display: none; }
    /* Logo on the left, controls (menu / theme / auth) pushed to the right. */
    .top-bar { display: flex !important; justify-content: space-between; gap: 0.85rem; }
    .top-nav {
        position: absolute; top: calc(100% + 8px); right: 12px; left: 12px;
        flex-direction: column; align-items: stretch; gap: 0.15rem;
        padding: 0.5rem; display: none;
        background: var(--bg3); border: 1px solid var(--border);
        border-radius: 0.75rem; box-shadow: 0 16px 48px rgba(0,0,0,0.45);
        z-index: 600;
    }
    .top-nav.open { display: flex; animation: dropIn 0.18s ease; }
    .top-nav-link { font-size: 0.95rem; padding: 0.7rem 0.9rem; border-radius: 0.5rem; text-align: left; }
    .top-nav-link#demoNavLink { text-align: center; }
}


/* ══════════════════════════════════════
   Viscar - Auth Modals
   ══════════════════════════════════════ */

.auth-overlay {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(2,8,18,0.82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    align-items: center; justify-content: center; animation: authFadeIn 0.22s ease;
}
.auth-overlay.active { display: flex; }
@keyframes authFadeIn { from { opacity: 0; } to { opacity: 1; } }

.auth-modal {
    display: none; width: 100%; max-width: 420px;
    background: var(--bg3); border: 1px solid var(--border); border-radius: 1.1rem;
    padding: 2.4rem 2rem 2rem; position: relative;
    box-shadow: 0 24px 80px rgba(0,0,0,0.55); animation: authSlideUp 0.28s ease;
}
.auth-modal.active { display: block; }
@keyframes authSlideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.auth-close {
    position: absolute; top: 1rem; right: 1rem; width: 32px; height: 32px;
    border-radius: 8px; border: 1px solid var(--border2); background: transparent;
    color: var(--txt3); cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.auth-close:hover { color: var(--txt); border-color: var(--border); background: rgba(255,255,255,0.03); }
.auth-close svg { width: 16px; height: 16px; }

.auth-header { text-align: center; margin-bottom: 1.8rem; }
/* Default shows the Viscar logo as a bg-image, which is what plain auth
   modals (login, register, etc.) want. The ApiKeys flow overrides
   background via inline style and renders a contextual SVG inside -
   keep display:flex so that child SVG remains centred. */
.auth-logo {
    width: 44px; height: 44px; margin: 0 auto 1rem;
    background: url('/images/viscar-logo.png') center/cover no-repeat;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.auth-title { font-size: 1.35rem; font-weight: 700; color: var(--txt); margin-bottom: 0.3rem; }
.auth-subtitle { font-size: 0.88rem; color: var(--txt2); }

.auth-field { margin-bottom: 1rem; }
.auth-label {
    display: block; font-family: var(--mono); font-size: 0.68rem; font-weight: 600;
    color: var(--txt3); letter-spacing: 0.08em; margin-bottom: 0.4rem; text-transform: uppercase;
}
.auth-input {
    width: 100%; padding: 0.72rem 0.9rem; background: var(--bg2);
    border: 1px solid var(--border2); border-radius: 0.55rem; color: var(--txt);
    font-family: var(--font); font-size: 1rem; transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
.auth-input:focus { border-color: rgba(0,194,255,0.5); box-shadow: 0 0 0 3px rgba(0,194,255,0.1); }
.auth-input::placeholder { color: var(--txt3); }
.auth-input.error { border-color: var(--red); }

.pw-strength { display: flex; gap: 4px; margin-top: 0.5rem; }
.pw-bar { flex: 1; height: 3px; border-radius: 2px; background: var(--bg5); transition: background 0.3s; }
.pw-bar.weak { background: var(--red); }
.pw-bar.medium { background: var(--orange); }
.pw-bar.strong { background: var(--green); }
.pw-hint { font-size: 0.72rem; color: var(--txt3); margin-top: 0.35rem; }
.pw-hint.error { color: var(--red); }

.auth-btn {
    width: 100%; padding: 0.75rem;
    background: linear-gradient(135deg, var(--blue) 0%, var(--cyan) 100%);
    color: #fff; border: none; border-radius: 0.55rem;
    font-family: var(--font); font-size: 0.92rem; font-weight: 700;
    cursor: pointer; transition: all 0.2s; box-shadow: 0 4px 18px rgba(30,111,255,0.3);
}
.auth-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 28px rgba(30,111,255,0.45); filter: brightness(1.06); }
.auth-btn:disabled { opacity: 0.5; pointer-events: none; }

.auth-divider { display: flex; align-items: center; gap: 0.8rem; margin: 1.3rem 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border2); }
.auth-divider span { font-size: 0.75rem; color: var(--txt3); font-weight: 500; white-space: nowrap; }

.auth-oauth { display: flex; flex-direction: column; gap: 0.6rem; }
.auth-oauth-btn {
    width: 100%; padding: 0.65rem; background: rgba(255,255,255,0.04);
    border: 1px solid var(--border2); border-radius: 0.55rem;
    color: var(--txt2); font-family: var(--font); font-size: 0.88rem; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 0.6rem;
}
.auth-oauth-btn:hover { border-color: var(--border); background: rgba(255,255,255,0.06); color: var(--txt); }
.auth-oauth-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.auth-footer { text-align: center; margin-top: 1.2rem; }
.auth-footer span { font-size: 0.84rem; color: var(--txt3); }
.auth-link {
    background: none; border: none; padding: 0; color: var(--cyan);
    font-family: var(--font); font-size: 0.84rem; font-weight: 600;
    cursor: pointer; transition: color 0.2s; text-decoration: none;
}
.auth-link:hover { color: var(--txt); }
.auth-forgot { display: block; text-align: right; margin-top: -0.5rem; margin-bottom: 0.6rem; }

.code-inputs { display: flex; gap: 0.5rem; justify-content: center; margin: 1.5rem 0; }
.code-input {
    width: 48px; height: 56px; background: var(--bg2); border: 1px solid var(--border2);
    border-radius: 0.55rem; color: var(--txt); font-family: var(--mono);
    font-size: 1.5rem; font-weight: 700; text-align: center; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.code-input:focus { border-color: rgba(0,194,255,0.5); box-shadow: 0 0 0 3px rgba(0,194,255,0.1); }
.code-resend { text-align: center; margin-top: 0.8rem; }
.code-resend span { font-size: 0.8rem; color: var(--txt3); }

@media (max-width: 480px) {
    .auth-modal { margin: 1rem; padding: 1.8rem 1.3rem 1.5rem; max-width: none; }
    .code-input { width: 42px; height: 48px; font-size: 1.2rem; }
}
