/* 数据分析工具集 - 分组详情页（侧栏 + iframe 面板） */

.ag-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: auto;
    gap: 0;
}

/* ---------- 侧边栏 ---------- */
.ag-sidebar {
    border-right: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-secondary, #f9fafb);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ag-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.ag-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 10px 14px;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.ag-breadcrumb-link {
    color: #10b981;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
}

.ag-breadcrumb-link:hover { text-decoration: underline; }

.ag-breadcrumb-sep { color: var(--text-muted, #9ca3af); }

.ag-breadcrumb-cur {
    color: var(--text-secondary, #374151);
    font-weight: 500;
}

.ag-search-wrap {
    position: relative;
    padding: 12px 14px 10px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.ag-search-icon {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #9ca3af);
    font-size: 0.9rem;
    pointer-events: none;
}

.ag-search-input {
    width: 100%;
    padding: 6px 10px 6px 30px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: var(--radius-sm, 6px);
    font-size: 0.85rem;
    background: var(--bg-primary, #fff);
    outline: none;
    box-sizing: border-box;
}

.ag-search-input:focus { border-color: #10b981; }

.ag-nav {
    overflow-y: auto;
    flex: 1;
    padding: 6px 0 16px;
}

.ag-tool-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ag-tool-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    font-size: 0.855rem;
    color: var(--text-secondary, #6b7280);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.ag-tool-btn:hover {
    background: var(--bg-hover, #f3f4f6);
    color: var(--text-primary, #111827);
}

.ag-tool-btn.active {
    background: linear-gradient(90deg, #d1fae5 0%, #ecfdf5 100%);
    color: #059669;
    font-weight: 600;
    border-right: 3px solid #10b981;
}

.ag-tool-btn.hidden { display: none; }

.ag-tool-icon {
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0.75;
}

.ag-tool-btn.active .ag-tool-icon { opacity: 1; }

.ag-tool-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ag-tool-badges {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.ag-badge {
    font-style: normal;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.ag-badge--ai   { background: #ede9fe; color: #7c3aed; }
.ag-badge--pptx { background: #fef3c7; color: #d97706; }
.ag-badge--hot  { background: #fee2e2; color: #dc2626; }
.ag-badge--must { background: #dbeafe; color: #2563eb; }

.ag-tool-tier {
    flex-shrink: 0;
    font-size: 0.58rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 4px;
    white-space: nowrap;
}

.ag-tool-tier--full { background: #d1fae5; color: #047857; }
.ag-tool-tier--preview { background: #e0e7ff; color: #4338ca; }
.ag-tool-tier--browse { background: #f1f5f9; color: #64748b; }

/* ---------- 主内容 ---------- */
.ag-main {
    padding: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: auto;
}

.ag-loading {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 2;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-muted, #9ca3af);
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.88);
}

.ag-spin {
    animation: ag-spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes ag-spin {
    to { transform: rotate(360deg); }
}

.ag-panel {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ag-iframe {
    flex: 0 0 auto;
    width: 100%;
    min-height: 480px;
    height: 480px;
    border: none;
    background: var(--bg-primary, #fff);
    display: block;
}

.ag-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted, #9ca3af);
    padding: 60px 20px;
    flex: 1;
}

.ag-empty i { font-size: 2.5rem; opacity: 0.5; }

/* 移动端顶栏 */
.ag-mobile-bar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-primary, #fff);
    flex-shrink: 0;
}

.ag-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: var(--bg-secondary, #f9fafb);
    cursor: pointer;
    color: var(--text-primary, #111827);
}

.ag-mobile-title {
    font-size: 0.9rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ag-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}

.ag-hub-mobile-hint {
    display: none;
}

@media (max-width: 780px) {
    .ag-layout { grid-template-columns: 1fr; }

    .ag-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        width: 260px;
        height: 100vh;
        z-index: 200;
        transition: left 0.25s ease;
    }

    .ag-sidebar.open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,0.12);
    }

    .ag-overlay.visible { display: block; }

    .ag-mobile-bar { display: flex; }

    .ag-hub-mobile-hint {
        display: block;
        margin: 0;
        padding: 10px 14px;
        font-size: 0.78rem;
        line-height: 1.5;
        color: var(--text-secondary);
        background: #f0f4ff;
        border-bottom: 1px solid #e2e8f0;
    }

    .ag-iframe { min-height: 400px; height: 400px; }
}

/* 工具集外壳页：避免 layout-container 撑出 iframe 与页脚之间的空白 */
body.tool-hub-shell .layout-container {
    min-height: auto;
}

body.tool-hub-shell .main-content {
    padding-bottom: var(--spacing-md);
}

body.tool-hub-shell .ag-iframe {
    position: relative;
    z-index: 1;
}

/* FAB 置于 iframe 之上，避免图标被文档层遮挡 */
body.tool-hub-shell .qc-fab,
body.tool-hub-shell .act-fab,
body.tool-hub-shell .feedback-btn,
body.tool-hub-shell .guide-fab {
    z-index: 1100;
}

body.tool-hub-shell .qc-fab > i,
body.tool-hub-shell .act-fab > i,
body.tool-hub-shell .feedback-btn > i,
body.tool-hub-shell .guide-fab > i {
    position: relative;
    z-index: 1;
    font-family: remixicon !important;
    font-style: normal;
    line-height: 1;
    display: inline-block;
}

@media (max-width: 768px) {
    body.tool-hub-shell .main-content {
        padding-bottom: calc(var(--spacing-md) + 72px);
    }
}
