/* ============================================ */
/*  index.html 专用样式 - 粒子库页面                 */
/* ============================================ */

/* ============================================
   HERO - 页面头部
   ============================================ */
.hero {
    padding: 2rem 2rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

/* Hero Header - Logo 和标题一行 */
.hero-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

.hero .site-logo {
    margin-bottom: 0;
    height: 50px;
}

.hero-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    text-wrap: balance;
}

.hero-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-wrap: pretty;
}

/* ============================================
   TAB 导航
   ============================================ */
.tab-nav {
    padding: 1rem 2rem 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tab-nav::-webkit-scrollbar {
    display: none;
}

.tab-list {
    display: inline-flex;
    gap: 0.5rem;
}

.tab-item {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
    user-select: none;
}

.tab-item:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

/* 当前焦点Tab - 橙色背景+白色文字 */
.tab-item.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
}

/* 有选择的Tab - 显示橙色边框 */
.tab-item.has-selection {
    border-color: var(--accent);
    color: var(--accent);
}

/* 同时是当前焦点和有选择 - 橙色背景+白色文字 */
.tab-item.active.has-selection {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* ============================================
   TAB 分组颜色 - 微妙色倾向
   ============================================ */

/* 定调子 - 暗灰橙 */
.tab-item.group-mood {
    background: rgba(168, 142, 128, 0.12);
}
.tab-item.group-mood:hover {
    border-color: var(--group-mood);
}
.tab-item.group-mood.has-selection {
    border-color: var(--group-mood);
    color: var(--group-mood);
}

/* 定主体 - 暗灰蓝 */
.tab-item.group-subject {
    background: rgba(128, 148, 168, 0.12);
}
.tab-item.group-subject:hover {
    border-color: var(--group-subject);
}
.tab-item.group-subject.has-selection {
    border-color: var(--group-subject);
    color: var(--group-subject);
}

/* 定视角 - 暗灰绿 */
.tab-item.group-perspective {
    background: rgba(128, 158, 138, 0.12);
}
.tab-item.group-perspective:hover {
    border-color: var(--group-perspective);
}
.tab-item.group-perspective.has-selection {
    border-color: var(--group-perspective);
    color: var(--group-perspective);
}

/* 定文字 - 暗灰紫 */
.tab-item.group-text {
    background: rgba(152, 138, 168, 0.12);
}
.tab-item.group-text:hover {
    border-color: var(--group-text);
}
.tab-item.group-text.has-selection {
    border-color: var(--group-text);
    color: var(--group-text);
}

/* 定输出 - 暗灰红 */
.tab-item.group-output {
    background: rgba(168, 128, 138, 0.12);
}
.tab-item.group-output:hover {
    border-color: var(--group-output);
}
.tab-item.group-output.has-selection {
    border-color: var(--group-output);
    color: var(--group-output);
}

/* ============================================
   SHOWCASE - 粒子展示区
   ============================================ */
.showcase {
    flex: 1;
    padding: 1.5rem 2rem;
    background: var(--bg-primary);
}

.showcase-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.showcase-title-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

#currentCategoryTitle {
    display: none;
}

#particleCount {
    font-size: clamp(9px, 1.6vw, 12px);
    line-height: 1.2;
}

.showcase-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.showcase-search {
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 200px;
}

.showcase-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn-action {
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-action:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.showcase-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* ============================================
   PARTICLE CARD
   ============================================ */
.particle-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
}

.particle-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
}

/* 缩略图容器 */
.particle-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.particle-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.particle-card:hover .particle-thumb img {
    transform: scale(1.05);
}

.particle-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.particle-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.particle-name-en {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: "SF Mono", Monaco, monospace;
}

.particle-body {
    padding: 0.75rem;
}

.particle-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.tag {
    padding: 0.125rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

/* ============================================
   PLATFORM BADGES - 平台推荐标签
   ============================================ */
.particle-platforms {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.platform-badge {
    padding: 0.125rem 0.5rem;
    background: #000080;
    border-radius: 4px;
    font-size: 0.65rem;
    color: white;
    font-weight: 500;
}

.particle-prompt {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-height: 6em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.particle-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}

.particle-btn {
    width: 100%;
    padding: 0.5rem;
    background: var(--button-primary);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.particle-btn:hover {
    background: var(--button-primary-hover);
}

.particle-btn.copied {
    background: #22c55e;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    padding: 1rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: calc(2rem + env(safe-area-inset-bottom));
    right: calc(2rem + env(safe-area-inset-right));
    padding: 0.75rem 1.5rem;
    background: #22c55e;
    color: white;
    border-radius: 8px;
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: var(--z-toast);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   LOADING / EMPTY
   ============================================ */
.loading, .empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .hero-title {
        font-size: 1.5rem;
    }

    .hero {
        padding: 1rem 0.75rem 0.75rem;
    }

    .hero-header {
        gap: 0.5rem;
        margin-bottom: 0;
    }

    .hero .site-logo {
        height: 32px;
    }

    .hero-title {
        font-size: 1.1rem;
        white-space: nowrap;
    }

    .hero-subtitle {
        display: none;
    }

    .tab-nav {
        padding: 0.75rem 0.75rem 0;
        overflow-x: visible;
        white-space: normal;
    }

    .tab-list {
        display: flex;
        flex-wrap: wrap;
    }

    .showcase {
        padding: 1rem 0.5rem;
    }

    .showcase-grid {
        /* 移动端双列排行布局 */
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .hero-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-hero {
        width: 100%;
    }

    .showcase-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .showcase-actions {
        width: 100%;
    }

    .showcase-search {
        flex: 1;
    }

    .bottom-bar {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    .btn-generate {
        width: 100%;
    }

    body {
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }

    .modal-content {
        max-height: 90svh;
        max-height: 90dvh;
    }

    .history-item-actions {
        flex-direction: column;
    }

    .history-item-actions button {
        flex: 1;
    }
}

/* ============================================
   BOTTOM BAR - 底部固定栏
   ============================================ */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 2rem calc(1rem + env(safe-area-inset-bottom));
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: var(--z-bottom-bar);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

.bottom-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-reset {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.btn-reset:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-reset:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.bottom-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.bottom-status strong {
    color: var(--accent);
    font-weight: 600;
}

.btn-generate {
    padding: 0.75rem 2rem;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.btn-generate:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-generate:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 为底部栏留出空间 - 增加 padding 防止与 footer 重叠 */
body {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* ============================================
   MODAL - 模态框通用样式
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: calc(1rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right))
             calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 80svh;
    max-height: 80dvh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}

.modal-content-history {
    max-width: 500px;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ============================================
   SELECTED COMPONENTS - 选中元件显示
   ============================================ */
.selected-components {
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
}

.selected-components:empty {
    display: none;
}

/* ============================================
   PROMPT OUTPUT - Prompt 输出区
   ============================================ */
.prompt-output {
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.6;
    white-space: pre-wrap;
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
    min-height: 80px;
}

.btn-modal {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-modal-copy {
    background: var(--button-primary);
    color: white;
}

.btn-modal-copy:hover:not(:disabled) {
    background: var(--button-primary-hover);
}

.btn-modal-favorite {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-modal-favorite:hover:not(:disabled) {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.btn-modal:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================
   HISTORY LIST - 历史记录列表
   ============================================ */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.history-item:hover {
    border-color: var(--border);
}

.history-item-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.history-item-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    max-height: 2em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-actions {
    display: flex;
    gap: 0.5rem;
}

.history-item-actions button {
    padding: 0.375rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.history-item-actions button:hover {
    border-color: var(--accent);
}

.history-item-actions button.btn-delete {
    color: #ef4444;
}

.history-item-actions button.btn-delete:hover {
    border-color: #ef4444;
}

.history-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

/* ============================================
   PARTICLE CARD SELECTED STATE - 元件卡片选择状态
   ============================================ */
.particle-card {
    position: relative;
}

.particle-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

.particle-card.selected::before {
    content: '✓';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: var(--z-content);
}
