/* 主框架布局 */
.layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar-overlay,
.sidebar-toggle,
.sidebar-close {
    display: none;
}

/* 侧边栏 */
.sidebar {
    width: 220px;
    background: var(--bg-white);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar-logo {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: #8B8B8B;
    border-bottom: 1px solid var(--border-light);
    justify-content: center;
}

.sidebar-logo-image {
    height: 34px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-close {
    position: absolute;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-hint);
    border-radius: var(--radius);
    cursor: pointer;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.menu-group {
    margin-bottom: 4px;
}

.menu-group-title {
    padding: 8px 16px;
    font-size: 11px;
    color: var(--text-hint);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.menu-item:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.menu-item.active {
    background: var(--tag-blue-bg);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 500;
}

[data-theme="dark"] .menu-item.active {
    background: rgba(24, 144, 255, 0.12);
}

.menu-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* 主内容区 */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* 顶部栏 */
.topbar {
    height: 56px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-left .breadcrumb {
    color: var(--text-hint);
    font-size: 13px;
}

.topbar-left .breadcrumb .current {
    color: var(--text-primary);
    font-weight: 500;
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text-secondary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-right .user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
}

.topbar-right .btn-logout {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-hint);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius);
    border: none;
    background: none;
    transition: all 0.2s;
}

.topbar-right .btn-logout:hover {
    color: var(--danger);
    background: var(--tag-red-bg);
}

.topbar-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-theme {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, color 0.2s;
}

.btn-theme:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.lang-select-wrap select {
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--bg-white);
    color: var(--text-primary);
    min-width: 100px;
}

/* 内容iframe区 */
.content-frame {
    flex: 1;
    border: none;
    background: var(--bg-gray);
}

.footerbar {
    height: 42px;
    padding: 0 20px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-white);
    color: var(--text-hint);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.footer-desktop,
.footer-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex-wrap: wrap;
}

.footer-mobile {
    display: none;
}

.footer-nav {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}

.footer-nav-item {
    color: var(--text-secondary);
}

.footer-separator {
    color: var(--text-hint);
}

.footer-link {
    color: var(--primary);
    text-decoration: none;
}

.footer-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* 联系我们下拉 */
.footer-contact-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.footer-contact-trigger {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    user-select: none;
}

.footer-contact-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg, 0 4px 16px rgba(0,0,0,0.12));
    padding: 6px 0;
    z-index: 2000;
    flex-direction: column;
}

.footer-contact-dropdown::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 16px;
    width: 10px;
    height: 10px;
    background: var(--bg-white);
    border-right: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    transform: rotate(45deg);
}

.footer-contact-wrap:hover .footer-contact-dropdown,
.footer-contact-wrap.open .footer-contact-dropdown {
    display: flex;
}

.footer-contact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.footer-contact-item:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.footer-contact-item i {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .layout {
        min-height: 100vh;
        height: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(82vw, 280px);
        z-index: 1100;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }

    .layout.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 1090;
    }

    .layout.sidebar-open .sidebar-overlay {
        display: block;
    }

    .sidebar-toggle,
    .sidebar-close {
        display: inline-flex;
    }

    .sidebar-logo {
        position: relative;
    }

    .topbar {
        height: auto;
        min-height: 56px;
        padding: 10px 12px;
        gap: 10px;
        align-items: center;
        flex-wrap: wrap;
    }

    .topbar-left {
        width: 100%;
        min-width: 0;
    }

    .topbar-left .breadcrumb {
        display: flex;
        align-items: center;
        gap: 4px;
        flex-wrap: wrap;
    }

    .topbar-right {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }

    .topbar-right .user-info {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .footerbar {
        height: auto;
        min-height: 42px;
        padding: 10px 12px;
        justify-content: center;
        text-align: center;
        line-height: 1.6;
        gap: 6px;
        flex-wrap: wrap;
    }

    .footer-desktop {
        display: none;
    }

    .footer-mobile {
        display: inline-flex;
    }

    .footer-nav {
        width: 100%;
        margin-left: 0;
        gap: 4px;
        justify-content: center;
    }
}

/* ===== 协议强制阅读弹窗 ===== */
.legal-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 11000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.legal-modal-overlay.show {
    display: flex;
}

.legal-modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 900px;
    height: 88vh;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.legal-modal-header {
    flex-shrink: 0;
    padding: 16px 20px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.legal-modal-header i {
    color: var(--primary);
    font-size: 20px;
}

.legal-modal-tabs {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
    padding: 10px 16px 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-light);
}

.legal-tab {
    border: none;
    background: transparent;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s, border-color 0.2s;
}

.legal-tab:hover {
    color: var(--primary);
}

.legal-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.legal-modal-body {
    flex: 1;
    min-height: 0;
    position: relative;
    background: var(--bg-gray);
}

.legal-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.legal-frame.is-hidden {
    display: none;
}

.legal-modal-footer {
    flex-shrink: 0;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-white);
}

.legal-modal-tip {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-hint);
    line-height: 1.5;
}

.legal-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.legal-btn-reject {
    height: 40px;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: border-color 0.2s, color 0.2s;
}

.legal-btn-reject:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.legal-btn-agree {
    height: 40px;
    padding: 0 24px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s, opacity 0.2s;
}

.legal-btn-agree:hover:not(:disabled) {
    background: var(--primary-dark);
}

.legal-btn-agree:disabled {
    background: var(--text-hint);
    cursor: not-allowed;
    opacity: 0.75;
}

.legal-countdown {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

@media (max-width: 768px) {
    .legal-modal {
        height: 92vh;
        max-height: 92vh;
    }
    .legal-modal-actions {
        flex-direction: column-reverse;
    }
    .legal-btn-reject,
    .legal-btn-agree {
        width: 100%;
        justify-content: center;
    }
}

/* ===== 自动更新提醒徽标 ===== */
.btn-update-notify {
    position: relative;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-hint);
    cursor: pointer;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.2s, color 0.2s;
}

.btn-update-notify:hover {
    background: var(--bg-gray);
    color: var(--text-secondary);
}

/* 有新版本时点亮为橙色 */
.btn-update-notify.has-update {
    color: var(--warning);
}

/* 红点默认隐藏，仅有新版本时显示 */
.btn-update-notify .update-dot {
    display: none;
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 1px solid var(--bg-white);
    animation: updatePulse 1.6s ease-in-out infinite;
}

.btn-update-notify.has-update .update-dot {
    display: block;
}

@keyframes updatePulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.6; }
}

/* ===== 自动更新弹窗 ===== */
.update-modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.update-modal .modal-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--text-hint);
    cursor: pointer;
}

.update-modal .modal-close:hover {
    color: var(--text-primary);
}

.update-modal-body {
    padding: 20px;
}

.update-version-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.update-version-badge i {
    color: var(--primary);
    font-size: 18px;
}

.update-version-badge strong {
    color: var(--primary);
    font-size: 16px;
}

.update-tip {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 14px;
}

.update-new-row .legal-btn-agree {
    width: 100%;
    justify-content: center;
}

.update-latest-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.update-latest-row p {
    margin: 0;
}

.update-ok-icon {
    color: var(--success);
    font-size: 22px;
}

.update-mode-section {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.update-mode-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.update-mode-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.update-mode-opt {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.update-mode-opt:hover {
    border-color: var(--primary);
}

.update-mode-opt input {
    margin-top: 3px;
    flex-shrink: 0;
}

.update-mode-opt span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.update-mode-opt strong {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
}

.update-mode-opt em {
    font-size: 12px;
    color: var(--text-hint);
    font-style: normal;
}

.update-uninstalled {
    font-size: 13px;
    color: var(--text-hint);
    margin: 0;
    text-align: center;
    padding: 12px 0;
}
