/* lihi 實驗室共用導覽列
 *
 * 從 public/lihiqrcode/css/styles.css 抽出來的導覽列樣式，
 * 桌機段第 29-336 行、手機段第 843-874 行，選擇器與數值原封不動。
 * 改動只有兩處：那組 CSS 變數改名成 --lihi-nav-*（避免跟 lab 自己的樣式撞名），
 * 以及補一條 body 的上方留白，因為導覽列是固定定位的。
 */

:root {
    --lihi-nav-safe-top: env(safe-area-inset-top, 0px);
    --lihi-nav-header-height: 72px;
    --lihi-nav-side-padding: 0px;
    --lihi-nav-padding-y: 16px;
}

/* 導覽列是固定定位，頁面內容要讓開 */
body {
    padding-top: calc(var(--lihi-nav-header-height) + var(--lihi-nav-safe-top));
}

.nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: calc(var(--lihi-nav-padding-y) + var(--lihi-nav-safe-top)) 0 var(--lihi-nav-padding-y);
    transition: all 0.3s ease;
    background: #fff;
    border-bottom: 1px solid rgba(26, 26, 94, 0.08);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

.nav-logo img {
    height: 40px;
    width: auto;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 32px;
    list-style: none;
}

.nav-links .has-dropdown {
    position: relative;
}

.nav-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    padding: 6px 0;
    min-width: 160px;
    list-style: none;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.has-dropdown:hover .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.nav-dropdown li a {
    display: block;
    padding: 10px 20px;
    font-size: 14px;
    color: #1a1a5e;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-dropdown li a:hover {
    background: #fff0f5;
    color: #ff6b9d;
}

.nav-links a,
.nav-links .nav-dropdown-toggle,
.lihi-site-footer-links a,
.lihi-site-footer-social a {
    color: #1a1a5e;
    transition: color 0.2s ease;
}

.nav-links a,
.nav-links .nav-dropdown-toggle {
    font-size: 15px;
    font-weight: 500;
}

.nav-links .nav-dropdown-toggle {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.nav-links a:hover,
.nav-links .nav-dropdown-toggle:hover,
.lihi-site-footer-links a:hover,
.lihi-site-footer-social a:hover {
    color: #ff6b9d;
}

.nav-cta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.nav-cta.mobile {
    gap: 8px;
    margin-left: auto;
    margin-right: 8px;
}

.nav-cta.mobile .lihi-btn-primary {
    padding: 8px 16px;
    font-size: 14px;
    box-shadow: none;
}

.nav-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
    border: 0;
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 2;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.nav-hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    border-radius: 2px;
    background: #1a1a5e;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center;
}

.nav-hamburger.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-hamburger.active span:nth-child(2) {
    opacity: 0;
}

.nav-hamburger.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-mobile-overlay {
    display: none;
    position: fixed;
    top: var(--lihi-nav-header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.nav-mobile-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.nav-mobile-menu {
    display: none;
    position: fixed;
    top: var(--lihi-nav-header-height);
    left: 0;
    right: 0;
    background: #fff;
    padding: 24px;
    max-height: calc(100vh - var(--lihi-nav-header-height));
    overflow-y: auto;
    box-shadow: none;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.nav-mobile-menu.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.mobile-only {
    display: none !important;
}

.nav-mobile-menu a,
.nav-mobile-menu .mobile-submenu-toggle {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 0;
    font-size: 16px;
    color: #1a1a5e;
    background: none;
    border: 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-family: inherit;
}

.mobile-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    padding-left: 16px;
}

.mobile-submenu.open {
    max-height: 200px;
}

.mobile-submenu a {
    font-size: 15px;
    color: #6b7280;
}

.nav-mobile-menu .mobile-cta-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.nav-mobile-menu .mobile-cta-row a {
    border-bottom: none;
    padding: 14px;
    font-size: 16px;
    text-align: center;
    flex: 1;
}

.nav-mobile-menu .mobile-cta-row .lihi-btn-secondary {
    color: #ff6b9d;
    border: 2px solid #ff6b9d;
}

/* 上面的 .nav-mobile-menu a 帶 background:none，specificity 壓過 .lihi-btn-primary，
   會讓選單裡的「免費註冊」變成白字白底的空色塊，這裡補回實心底色。 */
.nav-mobile-menu .mobile-cta-row .lihi-btn-primary {
    background: #ff6b9d;
}

body.menu-open {
    overflow: hidden;
}

.lihi-btn-primary,
.lihi-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    padding: 10px 18px;
    transition: all 0.2s ease;
}

.lihi-btn-primary {
    background: #ff6b9d;
    color: #fff;
    box-shadow: 0 10px 24px rgba(255, 107, 157, 0.22);
}

.lihi-btn-primary:hover {
    background: #f2558c;
    color: #fff;
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 12px 28px rgba(255, 107, 157, 0.32);
}

.lihi-btn-secondary {
    background: transparent;
    border: 2px solid #ff6b9d;
    color: #ff6b9d;
    font-weight: 600;
}

.lihi-btn-secondary:hover {
    background: #ff6b9d;
    color: #fff;
}

@media (max-width: 640px) {
    :root {
        --lihi-nav-side-padding: max(14px, env(safe-area-inset-right, 0px));
    }

    .nav-inner {
        padding-left: max(14px, env(safe-area-inset-left, 0px));
        padding-right: max(18px, env(safe-area-inset-right, 0px));
    }

    .nav-hamburger {
        padding: 10px;
        margin-right: -2px;
    }

    .desktop-only,
    .nav-links,
    .nav-cta.desktop {
        display: none !important;
    }

    .mobile-only.nav-hamburger {
        display: flex !important;
    }

    .mobile-only.nav-cta.mobile {
        display: flex !important;
    }

    .mobile-only.nav-mobile-menu,
    .mobile-only.nav-mobile-overlay {
        display: block !important;
    }

    body.menu-open .desktop-only {
        display: none !important;
    }


    .lihi-site-footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .lihi-site-mobile-cta-row .lihi-btn-primary,
    .lihi-site-mobile-cta-row .lihi-btn-secondary {
        flex: 1;
        padding-left: 12px;
        padding-right: 12px;
    }

    .lihi-site-footer-right {
        text-align: left;
    }

    .lihi-site-footer-links,
    .lihi-site-footer-social {
        justify-content: flex-start;
    }
}

/* ── 頁尾 ─────────────────────────────────────────────
 * 抽自 styles.css 第 357-402 行（桌機）與第 875-894 行（手機）。
 * 連結與社群圖示的 a 樣式在上面導覽列那段就一起帶進來了。
 * 寬度與左右內距改成跟 .nav-inner 一樣（lihiqrcode 原本是 56rem），
 * 頁尾內容才會跟導覽列的 logo、按鈕對齊。
 */
.lihi-site-footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 40px;
    border-top: 1px solid rgba(26, 26, 94, 0.08);
}

.lihi-site-footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 28px;
    color: #6b7280;
}

.lihi-site-footer-left p {
    margin: 0 0 6px;
    font-size: 13px;
    line-height: 1.55;
}

.lihi-site-footer-logo {
    width: 120px;
    height: auto;
    margin-bottom: 14px;
}

.lihi-site-footer-right {
    text-align: right;
}

.lihi-site-footer-links,
.lihi-site-footer-social {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.lihi-site-footer-links {
    margin-bottom: 12px;
}

.lihi-site-footer-links a {
    font-size: 13px;
}

/* ── 移植補丁 ─────────────────────────────────────────────
 * lihiqrcode 有載入 Tailwind，preflight 會把 a 的底線拿掉，
 * 所以原本的樣式沒有自己寫 text-decoration。labs 頁面沒有那層 reset，
 * 連結會冒出瀏覽器預設的底線，這裡補回來。
 */
.nav a,
.nav button,
.lihi-site-footer a {
    text-decoration: none;
}

/* ── 額度顯示 ───────────────────────────────────────── */

.lihi-quota {
    font-size: 13px;
    color: #6B6B8F;
    white-space: nowrap;
    margin-right: 12px;
}

.lihi-quota-message {
    max-width: 860px;
    margin: 0 auto 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255, 107, 157, 0.10);
    color: #D6317A;
    font-size: 14px;
}

/* 「這次拿到的是預設範本」的警告。
   顏色要跟額度訊息分得開 —— 那個是「你沒額度了」，這個是「你有額度、
   也扣了，但拿到的不是 AI 寫的」，兩種要處理的事完全不同。 */
.lihi-fallback-warning {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-radius: 12px;
    border-left: 4px solid #E8A33D;
    background: rgba(232, 163, 61, 0.12);
    color: #8A5B12;
    font-size: 14px;
    line-height: 1.6;
}

.lihi-fallback-warning[hidden] {
    display: none;
}

@media (max-width: 640px) {
    .lihi-quota { display: none; }

    /* 左右內距跟手機版 .nav-inner 一樣。要放在頁尾基本規則之後才蓋得過去 */
    .lihi-site-footer {
        padding-left: max(14px, env(safe-area-inset-left, 0px));
        padding-right: max(18px, env(safe-area-inset-right, 0px));
    }
}

/* ── 需要登入的提示框 ─────────────────────────────────── */
/* 形狀照 public/lihiqrcode 那顆 goToDashboardModal，但不引入 Tailwind，
   用這份自己的樣式。各 lab 的 CSS 先載入，所以這裡的規則蓋得過去。 */

.lihi-login-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.lihi-login-modal[hidden] {
    display: none;
}

.lihi-login-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 17, 34, 0.55);
    backdrop-filter: blur(4px);
}

.lihi-login-modal-panel {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(17, 17, 34, 0.24);
    padding: 32px 28px 24px;
    text-align: center;
    animation: lihi-login-modal-in 0.18s ease-out;
}

@keyframes lihi-login-modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

/* 使用者關掉動畫時就不要動。這顆是被錯誤觸發的，不該再加一層晃動 */
@media (prefers-reduced-motion: reduce) {
    .lihi-login-modal-panel { animation: none; }
}

.lihi-login-modal-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: rgba(255, 107, 157, 0.12);
    color: #D6317A;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lihi-login-modal-panel h3 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: #1A1A2E;
}

.lihi-login-modal-panel p {
    margin: 0 0 6px;
    font-size: 14px;
    line-height: 1.6;
    color: #6B6B8F;
}

.lihi-login-modal-note {
    font-size: 13px !important;
    color: #9A9AB8 !important;
}

.lihi-login-modal-actions {
    display: flex;
    gap: 10px;
    margin: 22px 0 6px;
}

.lihi-login-modal-actions > a {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.lihi-login-modal-actions > a:hover {
    opacity: 0.88;
}

.lihi-login-modal-primary {
    background: linear-gradient(135deg, #FF6B9D 0%, #C44FD8 100%);
    color: #fff;
}

.lihi-login-modal-secondary {
    background: #F3F3F8;
    color: #4A4A6A;
}

.lihi-login-modal-dismiss {
    width: 100%;
    padding: 10px;
    border: 0;
    background: none;
    color: #9A9AB8;
    font-size: 13px;
    cursor: pointer;
}

.lihi-login-modal-dismiss:hover {
    color: #6B6B8F;
}

@media (max-width: 480px) {
    .lihi-login-modal-actions {
        flex-direction: column;
    }
}

/* ── 建立短網址的彈窗 ─────────────────────────────────────────────
 *
 * 只有帶 #toggle-url-settings 的工具會打開它（文案 + 素材產生器）。
 * 版面跟登入彈窗同一套，但它是表單所以左對齊、寬一點。
 */
.lihi-url-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.lihi-url-modal[hidden] {
    display: none;
}

.lihi-url-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 17, 34, 0.45);
}

.lihi-url-modal-panel {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(17, 17, 34, 0.24);
    padding: 24px 28px 20px;
    text-align: left;
}

.lihi-url-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.lihi-url-modal-head h3 {
    margin: 0;
    font-size: 19px;
    color: #111122;
}

.lihi-url-modal-x {
    border: 0;
    background: none;
    font-size: 26px;
    line-height: 1;
    color: #98a2b3;
    cursor: pointer;
    padding: 0 4px;
}

.lihi-url-field {
    display: block;
    margin-top: 16px;
}

.lihi-url-field > span {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #344054;
    margin-bottom: 6px;
}

.lihi-url-field > span em,
.lihi-url-utm legend em {
    font-style: normal;
    font-weight: 400;
    color: #98a2b3;
    margin-left: 6px;
}

.lihi-url-field input,
.lihi-url-field select,
.lihi-url-utm input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    font-size: 14px;
    color: #111122;
    background: #fff;
}

.lihi-url-field input:focus,
.lihi-url-field select:focus,
.lihi-url-utm input:focus {
    outline: 2px solid #7a5cff;
    outline-offset: -1px;
    border-color: #7a5cff;
}

.lihi-url-utm {
    margin: 18px 0 0;
    padding: 0;
    border: 0;
}

.lihi-url-utm legend {
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    color: #344054;
}

.lihi-url-utm-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 6px;
}

.lihi-url-utm-grid label span {
    display: block;
    font-size: 12px;
    color: #667085;
    margin-bottom: 4px;
}

@media (max-width: 480px) {
    .lihi-url-utm-grid { grid-template-columns: 1fr; }
}

.lihi-url-error {
    margin: 14px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fef3f2;
    color: #b42318;
    font-size: 13px;
}

.lihi-url-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.lihi-url-modal-primary,
.lihi-url-modal-secondary {
    flex: 1;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
}

.lihi-url-modal-primary {
    background: #7a5cff;
    color: #fff;
}

.lihi-url-modal-primary[disabled] {
    opacity: 0.6;
    cursor: default;
}

.lihi-url-modal-secondary {
    background: #fff;
    color: #344054;
    border-color: #d0d5dd;
}

/* 8.2 的提示。產出的短網址不是自訂網域時掛在連結下面。 */
.lihi-url-upsell {
    margin: 8px 0 0;
    font-size: 13px;
    color: #475467;
}

.lihi-url-upsell a {
    color: #7a5cff;
    font-weight: 600;
    text-decoration: underline;
}

/* 基礎行銷攻略自己帶了一整套導覽列與頁尾（它原本是獨立的 landing page）。
 *
 * Worker 每一頁都會注入我們的導覽列與頁尾，所以那一頁會有兩套。藏掉它自己
 * 那份，不去改 tools/marketing-guide/index.html —— 那個檔案下次撈上游新版
 * 會被整份覆蓋。
 *
 * 藏的是外框不是內容：它的 hero、四張攻略卡片、下載按鈕都留著。
 */
body[data-lihi-lab="marketing-guide"] .site-nav,
body[data-lihi-lab="marketing-guide"] .site-footer {
  display: none !important;
}

/* 登入完轉回基礎行銷攻略時，把他本來要下載的那一顆標出來。
 * 不自動開新分頁 —— 那不是使用者手勢觸發的，會被彈窗阻擋器擋掉而且沒有提示。*/
.lihi-guide-ready {
  outline: 3px solid #7a5cff;
  outline-offset: 3px;
  border-radius: 10px;
}
