/* =========================================================
   1. Variables & Reset
   ========================================================= */
:root {
    --bg: #0b1220;
    --panel: #0f1a33;
    --panel2: #0c162c;
    --border: rgba(148, 163, 184, 0.18);
    --text: #e5e7eb;
    --muted: #9ca3af;
    --brand: #38bdf8;
    --ok: #22c55e;
    --warn: #f59e0b;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden; /* Prevent double scrollbars on the outermost layer */
    background: radial-gradient(1200px 600px at 20% 0%, rgba(56, 189, 248, 0.12), transparent 50%),
    radial-gradient(900px 500px at 80% 10%, rgba(34, 197, 94, 0.10), transparent 55%),
    var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Globally hide scrollbar styles but preserve functionality */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 0;
    height: 0;
}

a {
    text-decoration: none;
}

/* =========================================================
   2. Layout Shell
   ========================================================= */
.pg-shell {
    display: flex;
    height: 100vh; /* Force full viewport height */
    width: 100vw;
    align-items: stretch;
    overflow: hidden; /* Handle content overflow in child elements */
}

/* =========================================================
   3. Sidebar
   ========================================================= */
.pg-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.2s ease, transform 0.25s cubic-bezier(.4, 0, .2, 1);
    will-change: transform, width;
}

.brand {
    display: flex;
    gap: 10px;
    align-items: center;
    color: var(--text);
    padding: 16px 12px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    display: block;
    object-fit: contain;
    filter: invert(1);
}

.brand-title {
    font-weight: 800;
    letter-spacing: 0.6px;
    padding-left: 0; /* Remove */
    line-height: 1.2; /* Control line height */
}

.brand-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

/* Nav */
.nav {
    margin-top: 14px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 0 12px;
}

.nav-title {
    font-size: 12px;
    color: var(--muted);
    padding: 10px 10px 6px;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 12px;
    color: var(--text);
    border: 1px solid rgba(148, 163, 184, 0.10);
    background: rgba(15, 23, 42, 0.25);
}

.nav-link:hover {
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.06);
}

.nav-link.is-active {
    border-color: rgba(56, 189, 248, 0.65);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18);
    background: rgba(56, 189, 248, 0.08);
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 14px 12px 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.10);
    display: grid;
    gap: 10px;
}

.sidebar-footer .lang-switch {
    width: 100%;
    border-radius: 14px;
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.sidebar-footer .lang-btn {
    width: 100%;
    justify-content: center;
}

/* =========================================================
   Layout Fix for Footer & Full Height Content
   ========================================================= */

/* 1. Set pg-main as a flex container */
.pg-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    overflow: hidden;
}

/* =========================================================
   Layout Fix: Sticky Footer
   ========================================================= */

/* 1. Outer container: responsible for generating scrollbars */
.pg-content-all {
    /* Let the container fill all space below the Header */
    flex: 1;
    min-height: 0;

    /* Generate vertical scrollbar */
    overflow-y: auto;
    overflow-x: hidden;

    /* Key 1: Must be Flex Column */
    display: flex;
    flex-direction: column;

    /* Remove Padding, let internal .pg-content handle it */
    padding: 0;

    /* Hide scrollbar styles */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.pg-content-all::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* 2. Content wrapper: must expand automatically */
/* Originally wrote .pg-scroll-body (class does not exist in HTML) */
/* Corrected to .pg-content (corresponding to your HTML) */
.pg-content {
    width: 100%;
    padding: 16px;

    /* Key 2: Change to flex: 1 */
    /* This forces this block to "grow" and fill all remaining empty height, pushing the Footer to the bottom */
    flex: 1;

    /* Prevent compression */
    flex-shrink: 0;
}

/* 3. Footer container and body */
#footer-container {
    flex-shrink: 0; /* Ensure Footer container is not compressed */
}

.pg-footer {
    width: 100%;
    height: 34px;

    /* Styles */
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(2, 6, 23, 0.35);
    backdrop-filter: blur(10px);

    display: flex;
    align-items: center;
    justify-content: center;
}

.pg-footer-inner {
    font-size: 10px;
    color: rgba(229, 231, 235, 0.70);
    text-align: center;
}

/* =========================================================
   5. Topbar
   ========================================================= */
.topbar {
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(2, 6, 23, 0.35);
    backdrop-filter: blur(10px);
    flex-shrink: 0; /* Prevent Header from being compressed */
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-right {
    gap: 12px;
    flex-wrap: nowrap;
}

.sidebar-toggle-btn {
    border-radius: 9999px;
    border: 1px solid #4b5563;
    background: #020617;
    color: #e5e7eb;
    padding: 4px 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sidebar-toggle-btn:hover {
    background: #111827;
    transform: translateY(-1px);
}

/* =========================================================
   6. Elements & Components
   ========================================================= */
/* Hero */
.hero {
    padding: 0 0 8px;
    border: none;
    background: transparent;
}

.hero h1, .hero p {
    padding-left: 14px;
}

.hero h1 {
    font-size: 18px;
    margin-bottom: 8px;
}

.hero p {
    font-size: 13px;
    color: var(--muted);
}

/* Grid & Card */
.grid {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.card, .panel {
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(2, 6, 23, 0.35);
    padding: 14px;
}

.card:hover {
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.06);
}

.card.is-active {
    border-color: rgba(56, 189, 248, 0.65);
    background: rgba(56, 189, 248, 0.08);
}

.card-title {
    color: white;
    font-weight: 800;
    margin-bottom: 6px;
}

.card-desc {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 10px;
}

.card-actions {
    display: flex;
    gap: 8px;
}

/* Buttons & Tags */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 9999px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.40);
    color: var(--text);
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 800;
}

.btn:hover {
    background: rgba(56, 189, 248, 0.10);
    border-color: rgba(56, 189, 248, 0.35);
}

.tag {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 9999px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tagReady {
    border-color: rgba(34, 197, 94, 0.35);
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.10);
}

.tagSoon {
    border-color: rgba(245, 158, 11, 0.35);
    color: #fde68a;
    background: rgba(245, 158, 11, 0.08);
}

.tagOnly {
    border-color: rgba(239, 68, 68, 0.45);
    color: #fecaca;
    background: rgba(239, 68, 68, 0.12);
}

/* Language Switch & Dropdown */
.lang-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.35);
    padding: 6px 10px;
    border-radius: 9999px;
}

.lang-btn {
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(2, 6, 23, 0.55);
    color: var(--text);
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 9999px;
    cursor: pointer;
}

.lang-btn:hover {
    background: rgba(2, 6, 23, 0.75);
}

.lang-btn.is-active {
    border-color: rgba(56, 189, 248, 1);
    background: rgba(56, 189, 248, 0.15);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
}

.lang-dropdown {
    position: relative;
    display: inline-flex;
}

.lang-trigger {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.lang-trigger svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 120px;
    padding: 10px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transition: all .15s ease;
    z-index: 50;
}

.lang-dropdown.is-open .lang-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* Topbar Special Link */
.topbar-right .itshin-switch {
    position: relative;
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 9999px;
    background: rgba(2, 6, 23, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.22);
    backdrop-filter: blur(10px);
    transition: box-shadow 0.35s ease;
}

.topbar-right .itshin-switch::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 2px;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.9), rgba(34, 197, 94, 0.9));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.75;
    z-index: 0;
    transition: opacity 0.35s ease;
}

.topbar-right .itshin-link {
    position: relative;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 700;
    color: #e5e7eb;
    background: transparent;
    border: none;
    z-index: 1;
    outline: none;
}

.topbar-right .itshin-switch:hover {
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.22), 0 0 18px rgba(56, 189, 248, 0.35);
}

.topbar-right .itshin-switch:hover::before {
    opacity: 1;
}

.topbar-right .itshin-switch:hover .itshin-link {
    color: #fff;
}

/* =========================================================
   7. Responsive
   ========================================================= */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

@media (min-width: 981px) {
    .tag-mobile {
        display: none !important;
    }

    body.sidebar-collapsed .pg-sidebar {
        width: 0;
        padding: 0;
        border: none;
    }

    body.sidebar-collapsed .pg-sidebar > * {
        opacity: 0;
        pointer-events: none;
    }
}

@media (max-width: 980px) {
    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: block;
    }

    .tag-pc {
        display: none !important;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .iframe-wrap {
        height: 70vh;
    }

    .sidebar-footer .lang-switch {
        grid-template-columns: 1fr 1fr;
    }

    /* Mobile Drawer */
    .pg-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(86vw, 320px);
        z-index: 9999;
        transform: translateX(0);
        border-right: 1px solid var(--border);
    }

    body.sidebar-collapsed .pg-sidebar {
        display: block !important;
        transform: translateX(-105%);
    }

    body.sidebar-collapsed .pg-sidebar > * {
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .pg-sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 9998;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    body:not(.sidebar-collapsed) .pg-sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    body:not(.sidebar-collapsed) {
        overflow: hidden;
    }
}

/* ===============================
   Language icon: Never glow
   =============================== */
.lang-trigger,
.lang-trigger:hover,
.lang-trigger.is-active {
    box-shadow: none !important;
    background: rgba(2, 6, 23, 0.55);
    border-color: rgba(148, 163, 184, 0.18);
}

.lang-trigger {
    padding: 6px;
    width: 36px;
    height: 36px;
    justify-content: center;
    background: rgba(2, 6, 23, 0.45);
}

.lang-trigger:hover {
    background: rgba(15, 23, 42, 0.65);
}

/* ===============================
   Language icon base style (Restore appearance)
   =============================== */
.lang-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 36px;
    height: 36px;
    padding: 0;

    /* Three key things */
    color: var(--text); /* Make SVG appear */
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(2, 6, 23, 0.55);

    border-radius: 9999px;
    cursor: pointer;
}

/* Align text and icon side by side (failsafe) */
.itshin-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap; /* Already exists, but kept */
}

.itshin-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    white-space: nowrap; /* Prevent line wrapping */
    min-width: 0; /* Allow compression */
}

.itshin-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    max-width: 12ch; /* You can adjust: 10~14ch is comfortable */
}

.brand {
    display: flex;
    align-items: center;

    white-space: nowrap; /* No wrapping for the whole block */
    min-width: 0; /* Allow flex compression */
}

.brand-text {
    display: flex;
    flex-direction: column;

    min-width: 0; /* Without this line, ellipsis won't work */
}

.brand-sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    max-width: 12ch; /* Adjustable: 10–14ch */
}

.brand-title {
    white-space: nowrap;
}

@media (max-width: 420px) {
    .brand-sub {
        display: none;
    }
}

/* ===============================
   Mobile: Shrink AISIN AI button
   =============================== */
@media (max-width: 480px) {
    .topbar-right .itshin-switch {
        padding: 4px 6px; /* Shrink outer frame */
        border-radius: 9999px;
    }

    .topbar-right .itshin-link {
        padding: 4px 10px; /* Shrink padding */
        font-size: 11px; /* Smaller font */
        gap: 4px; /* Shrink icon gap */
    }

    .topbar-right .out-icon svg {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 360px) {
    .topbar-right .itshin-link {
        font-size: 10px;
        padding: 3px 8px;
    }
}

/* itshin-link should not glow even if is-active */
.lang-btn.itshin-link.is-active {
    box-shadow: none !important;
}

.brand {
    display: flex;
    align-items: center; /* Vertically center logo + text */
    gap: 12px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Key: Force left alignment */
}

.brand-sub {
    line-height: 1.2;
    margin-top: 2px; /* Micro-spacing, use margin instead of padding */
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px; /* Originally 10–12px -> Reduced to 8px (Recommended) */
}

