/* ============================================================
   NameCraft - 全局样式
   ============================================================ */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --bg: #0f0f11;
    --bg-card: #18181b;
    --bg-card-hover: #1f1f23;
    --bg-input: #27272a;
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border: #3f3f46;
    --border-light: #52525b;
    --success: #22c55e;
    --success-dim: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;
    --error: #ef4444;
    --error-dim: rgba(239, 68, 68, 0.10);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   页面切换
   ============================================================ */
.page { display: none; }
.page.active { display: block; }

/* ============================================================
   搜索主页
   ============================================================ */
.search-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 2rem;
    padding-top: 12vh;
}

.logo-area {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.logo-icon {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.logo-text {
    font-size: 2.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light), #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.logo-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 0.5rem;
    font-weight: 300;
}

/* ============================================================
   语言切换胶囊
   ============================================================ */
.lang-toggle {
    position: relative;
    display: inline-flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
    margin-bottom: 1.25rem;
    user-select: none;
}

.lang-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: var(--primary);
    border-radius: 999px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

.lang-toggle[data-active="zh"] .lang-slider {
    transform: translateX(100%);
}

.lang-opt {
    position: relative;
    z-index: 1;
    padding: 0.35rem 1.2rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.25s;
    min-width: 52px;
    text-align: center;
}

.lang-opt.active {
    color: #fff;
}

/* ============================================================
   类别选择栏
   ============================================================ */
.category-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
    justify-content: center;
    max-width: 640px;
}

.cat-chip {
    padding: 0.4rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.cat-chip:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    color: var(--primary-light);
}

.cat-chip.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    color: var(--primary-light);
    font-weight: 500;
}

/* ============================================================
   搜索框
   ============================================================ */
.search-box {
    display: flex;
    width: 100%;
    max-width: 640px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
    align-items: flex-end;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-box textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 1rem 1.25rem;
    font-size: 0.95rem;
    color: var(--text);
    font-family: inherit;
    resize: none;
    line-height: 1.5;
}

.search-box textarea::placeholder {
    color: var(--text-muted);
}

.search-box button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.3rem;
    margin: 0.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

.search-box button:hover {
    background: var(--primary-dark);
}

/* 快捷标签 */
.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.25rem;
    justify-content: center;
    max-width: 640px;
}

.quick-tags span {
    padding: 0.4rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.quick-tags span:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    color: var(--primary-light);
}

/* ============================================================
   顶部栏
   ============================================================ */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 15, 17, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.top-bar-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
}

.top-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-light);
    white-space: nowrap;
    flex-shrink: 0;
}

.top-desc {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   结果内容区
   ============================================================ */
.result-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

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

.result-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.result-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

.btn-more-round {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid var(--primary);
    color: var(--primary-light);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-more-round:hover {
    background: rgba(99, 102, 241, 0.15);
}

/* ============================================================
   Tab 导航
   ============================================================ */
.result-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.7rem 1.2rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.2s, border-color 0.2s;
    margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text-secondary); }

.tab-btn.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary);
}

.tab-btn svg { opacity: 0.6; }
.tab-btn.active svg { opacity: 1; color: var(--primary-light); }

.tab-badge {
    font-size: 0.72rem;
    background: var(--bg-input);
    padding: 1px 7px;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 600;
}

.tab-btn.active .tab-badge {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================================
   名称卡片网格
   ============================================================ */
.name-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}

.name-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.2s, transform 0.15s;
    animation: card-in 0.3s ease;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.name-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.name-card.available {
    border-left: 3px solid var(--success);
}

.name-card.taken {
    border-left: 3px solid var(--error);
    opacity: 0.85;
}

.name-card-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.name-card-title .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.available { background: var(--success); }
.status-dot.taken { background: var(--error); }

.name-card-tag {
    display: inline-block;
    font-size: 0.68rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.name-card-tag.tag-available {
    background: var(--success-dim);
    color: var(--success);
}

.name-card-tag.tag-taken {
    background: var(--error-dim);
    color: var(--error);
}

.name-card-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.name-card-product {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--error-dim);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.name-card-product strong {
    color: var(--error);
    font-weight: 600;
}

.name-card-url {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.72rem;
    color: var(--primary-light);
    text-decoration: none;
    word-break: break-all;
}

.name-card-url:hover {
    text-decoration: underline;
}

.name-card-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.4rem;
}

.name-card-actions button {
    font-size: 0.72rem;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.name-card-actions button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============================================================
   任务卡片
   ============================================================ */
.task-cards-area {
    width: 100%;
    max-width: 640px;
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: border-color 0.2s;
    animation: task-card-in 0.3s ease;
}

@keyframes task-card-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.task-card-done { border-color: var(--success); border-left: 3px solid var(--success); }
.task-card-error { border-color: var(--error); border-left: 3px solid var(--error); }

.task-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.task-card-vendor {
    font-weight: 600;
    font-size: 0.95rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-card-status {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.task-card-progress {
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 2px;
    width: 0%;
    transition: width 0.4s ease;
    animation: progress-pulse 2s ease-in-out infinite;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.progress-fill.done {
    background: linear-gradient(90deg, var(--success), #4ade80);
    animation: none;
}

.progress-fill.error {
    background: linear-gradient(90deg, var(--error), #f87171);
    animation: none;
}

.task-card-log {
    max-height: 160px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.task-log-line {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.15rem 0;
    font-size: 0.72rem;
    color: var(--text-muted);
    animation: log-line-in 0.2s ease;
}

@keyframes log-line-in {
    from { opacity: 0; transform: translateX(-4px); }
    to { opacity: 1; transform: translateX(0); }
}

.log-icon {
    flex-shrink: 0;
    font-size: 0.7rem;
    line-height: 1.4;
}

.log-text {
    line-height: 1.4;
}

.task-card-actions {
    margin-top: 0.6rem;
    display: flex;
    justify-content: flex-end;
}

.task-card-actions button {
    padding: 0.35rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.task-card-actions button:hover {
    background: var(--primary-dark);
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 0.95rem;
}

/* ============================================================
   历史记录
   ============================================================ */
.history-section {
    width: 100%;
    max-width: 640px;
    margin-top: 2.5rem;
}

.history-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.history-item:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.history-item-info {
    flex: 1;
    min-width: 0;
}

.history-item-desc {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    display: flex;
    gap: 0.75rem;
}

.history-item-stats {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.history-stat {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
}

.history-stat.available {
    background: var(--success-dim);
    color: var(--success);
}

.history-stat.taken {
    background: var(--error-dim);
    color: var(--error);
}

/* ============================================================
   Toast
   ============================================================ */
#toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 640px) {
    .logo-text { font-size: 2rem; }
    .search-box textarea { padding: 0.8rem 1rem; font-size: 0.9rem; }
    .search-box button span { display: none; }
    .name-grid { grid-template-columns: 1fr; }
    .result-header { flex-direction: column; align-items: flex-start; }
    .category-bar { gap: 0.3rem; }
    .cat-chip { font-size: 0.75rem; padding: 0.3rem 0.7rem; }
}
