/**
 * 生成器 embed=1 干净模式样式
 * App web-view 内嵌时隐藏网站导航/页脚/生成器页大标题，保留预览与配置/下载能力。
 */

/* ========== 网站全局壳层 ========== */
html.embed-mode header.fixed,
html.embed-mode #sideNavigation,
html.embed-mode #sideNavMembershipCard,
html.embed-mode main > footer,
html.embed-mode #notOpenModal,
html.embed-mode #printCartNavButton,
html.embed-mode .print-cart-float-button {
    display: none !important;
}

html.embed-mode main {
    margin-top: 0 !important;
    margin-left: 0 !important;
}

html.embed-mode body.not-open-bar-visible {
    padding-bottom: 0 !important;
}

/* ========== 生成器通用布局（generators/base.html） ========== */
html.embed-mode .generator-page-header,
html.embed-mode .generator-page-footer {
    display: none !important;
}

html.embed-mode .preview-header {
    top: 0 !important;
}

html.embed-mode .preview-area.has-fixed-header {
    padding-top: 56px !important;
}

/* embed 下强制启用移动端交互：侧滑配置 + 底部下载/打印 */
html.embed-mode .container {
    padding: 0 !important;
    max-width: 100% !important;
}

html.embed-mode .main-content {
    position: relative;
    display: block;
    gap: 0;
}

html.embed-mode .preview-area {
    width: 100%;
    padding: 0;
    padding-bottom: 80px;
    margin: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    min-height: calc(100vh - 88px);
}

html.embed-mode .sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    max-width: 85vw !important;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    background: white;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    left: auto !important;
    right: auto !important;
}

html.embed-mode .sidebar-left {
    left: 0 !important;
}

html.embed-mode .sidebar-right {
    right: 0 !important;
    transform: translateX(100%);
}

html.embed-mode .sidebar.open {
    transform: translateX(0) !important;
}

html.embed-mode .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

html.embed-mode .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

html.embed-mode .sidebar-toggle {
    display: flex !important;
    position: fixed;
    bottom: 100px;
    z-index: 998;
    min-width: 90px;
    height: 44px;
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.98);
    color: #555;
    border: 1.5px solid #d0d0d0;
    border-radius: 22px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    font-size: 13px;
    font-weight: 500;
}

html.embed-mode .sidebar-toggle-left {
    left: 12px;
}

html.embed-mode .sidebar-toggle-right {
    right: 12px;
}

html.embed-mode .sidebar-left .control-section:last-child {
    display: none;
}

html.embed-mode .sidebar-left #exportPDF,
html.embed-mode .sidebar-left #printBtn {
    display: none !important;
}

html.embed-mode .mobile-action-buttons {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 12px 16px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 997;
    gap: 12px;
}

html.embed-mode .mobile-action-buttons button {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
}

html.embed-mode .mobile-action-buttons #printBtn,
html.embed-mode .mobile-action-buttons #printBtnMobile {
    display: none !important;
}

/* ========== 钟表网格 v1（clock_grid.html 独立模板） ========== */
html.embed-mode .clock-grid-page-title {
    display: none !important;
}

html.embed-mode .clock-grid-wrapper {
    min-height: calc(100vh - 88px);
}

html.embed-mode .clock-grid-main-content {
    padding-bottom: 88px;
}

/* 钟表 v1：侧栏改为底部抽屉，下载按钮始终可达 */
html.embed-mode .clock-grid-sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 55vh;
    z-index: 900;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    overflow-y: auto;
    transform: translateY(calc(100% - 48px));
    transition: transform 0.25s ease;
    -webkit-overflow-scrolling: touch;
}

html.embed-mode .clock-grid-sidebar .embed-drawer-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 48px;
    margin: 0;
    padding: 8px 16px;
    border: none;
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1;
}

html.embed-mode .clock-grid-sidebar .embed-drawer-handle-bar {
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #d1d5db;
}

html.embed-mode .clock-grid-sidebar .embed-drawer-handle-text {
    font-size: 12px;
    color: #6b7280;
    line-height: 1;
}

html.embed-mode .clock-grid-sidebar.embed-sidebar-open {
    transform: translateY(0);
}

html.embed-mode .clock-grid-main-content .preview-header {
    display: none !important;
}

html.embed-mode .clock-grid-sidebar .control-panel {
    padding: 12px 16px 16px;
}

/* 安全区（iPhone 底部） */
html.embed-mode .mobile-action-buttons {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

/* 覆盖 generator.css 中 body.generator-page 对移动端按钮的隐藏（后者加载更晚） */
html.embed-mode body .sidebar-toggle,
html.embed-mode body .sidebar-toggle-left,
html.embed-mode body .sidebar-toggle-right,
html.embed-mode body .mobile-action-buttons,
html.embed-mode body #mobileActionButtons {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}
