/* --- 全局与基础样式 --- */
:root {
    --bg-color: #0d1117;
    --primary-color: #00A9FF;
    --primary-color-dark: #0088cc;
    --glass-bg: rgba(22, 27, 34, 0.6);
    --border-color: rgba(60, 68, 80, 0.5);
    --font-color: #c9d1d9;
    --font-color-secondary: #8b949e;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --error-color: #f85149;
    --success-color: #3fb950;
    --info-color: #58a6ff;
    --font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--font-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 3rem 1rem;
    overflow-x: hidden;
    position: relative;
}

/* --- 高级背景 --- */
.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at top, #1f2b3e, var(--bg-color) 70%),
                radial-gradient(ellipse at bottom, #2c1a3e, var(--bg-color) 70%);
    z-index: 0;
}
.background-shapes div {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    z-index: 0;
}
.shape1 { width: 350px; height: 350px; background: #005f99; top: -10%; left: -5%; animation: move 25s infinite alternate; }
.shape2 { width: 450px; height: 450px; background: #3d1c63; bottom: -15%; right: -10%; animation: move 30s infinite alternate-reverse; }
.shape3 { width: 250px; height: 250px; background: #533483; top: 40%; right: 40%; animation: move 20s infinite alternate; }

@keyframes move {
    from { transform: translate(0, 0) rotate(0deg) scale(1); }
    to { transform: translate(120px, 80px) rotate(120deg) scale(1.2); }
}

/* --- 运行中状态悬浮提示 --- */
.running-task-status {
    position: fixed;
    top: 1rem;
    left: 50%;
    width: min(480px, calc(100% - 2rem));
    transform: translateX(-50%);
    z-index: 20;
}

.liquid-capsule {
    width: 100%;
    min-height: 80px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    background: linear-gradient(135deg, rgba(30, 38, 56, 0.58) 0%, rgba(15, 20, 30, 0.32) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.55),
        0 10px 30px rgba(58, 130, 247, 0.12),
        inset 0 6px 12px rgba(255, 255, 255, 0.14),
        inset 0 -6px 12px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(24px) saturate(120%);
    -webkit-backdrop-filter: blur(24px) saturate(120%);
}

.status-area {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.spinner-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    flex: 0 0 auto;
    justify-content: center;
    align-items: center;
}

.spinner-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    transform: translate(-50%, -50%) rotate(45deg);
    filter: blur(10px);
    opacity: 0.85;
    z-index: 0;
    pointer-events: none;
}

.spinner-svg {
    position: relative;
    z-index: 1;
    width: 40px;
    height: 40px;
    animation: rotate 2s linear infinite;
}

.spinner-track {
    fill: none;
    stroke: rgba(0, 0, 0, 0.4);
    stroke-width: 5;
}

.spinner-progress {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 90;
    stroke-dashoffset: 0;
}

.running-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.25rem;
}

.status-text {
    color: #f8fafc;
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.2;
}

.running-task-note {
    color: var(--font-color-secondary);
    font-size: 0.85rem;
    line-height: 1.35;
}

@keyframes rotate { 100% { transform: rotate(360deg); } }

/* --- 主容器 --- */
.main-container {
    width: 100%;
    max-width: 800px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 2.5rem;
    box-shadow: 0 16px 48px 0 var(--shadow-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 1;
    transition: all 0.3s ease;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- 头部 --- */
.app-header { text-align: center; margin-bottom: 2rem; }
.app-header h1 { font-size: 2rem; font-weight: 700; color: #fff; margin-bottom: 0.5rem; }
.app-header p { font-size: 1rem; color: var(--font-color-secondary); }

/* --- 表单 --- */
.log-form { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 2rem; }
.input-group { position: relative; }
.input-group input {
    width: 100%;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 0.625rem;
    color: #fff;
    font-size: 1rem;
    transition: all 0.3s ease;
}
.input-group label {
    position: absolute; left: 1rem; top: 1rem; color: var(--font-color-secondary);
    pointer-events: none; transition: all 0.2s ease;
}
.input-group input:focus, .input-group input:not(:placeholder-shown) {
    border-color: var(--primary-color); outline: none; background: rgba(0,0,0,0.1);
}
.input-group input:focus + label, .input-group input:not(:placeholder-shown) + label {
    top: -0.625rem; left: 0.75rem; font-size: 0.75rem; color: var(--primary-color);
    background: #161b22; padding: 0 0.25rem;
}

/* --- 按钮 --- */
#submit-btn {
    display: flex; justify-content: center; align-items: center; gap: 0.75rem;
    padding: 0.875rem 1.25rem; border: none; border-radius: 0.625rem;
    background-color: var(--primary-color); color: #fff;
    font-size: 1rem; font-weight: 500; cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    position: relative; overflow: hidden;
}
#submit-btn:hover:not(:disabled) {
    background-color: var(--primary-color-dark);
    transform: translateY(-3px); box-shadow: 0 10px 20px -10px var(--primary-color);
}
#submit-btn:disabled { background-color: #8b949e; cursor: not-allowed; }

/* 按钮加载状态 */
#submit-btn .btn-spinner {
    display: none;
    width: 1.25rem; height: 1.25rem;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
#submit-btn.loading .btn-text { font-size: 0; } /* 隐藏文本 */
#submit-btn.loading .btn-icon { display: none; }
#submit-btn.loading .btn-spinner { display: block; }
#submit-btn.loading .btn-text::after {
    content: '查询中';
    font-size: 1rem; /* 恢复字号 */
    margin-left: -0.6rem; /* 抵消gap */
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- 统计区域 --- */
.stats-container {
    margin-bottom: 2rem;
    padding: 1.25rem;
    border: 1px solid rgba(0, 169, 255, 0.18);
    border-radius: 1rem;
    background:
        linear-gradient(180deg, rgba(0, 169, 255, 0.08), rgba(22, 27, 34, 0.3)),
        rgba(8, 16, 26, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

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

.stats-header h2 {
    font-size: 1.05rem;
    color: #fff;
    margin-bottom: 0.25rem;
}

.stats-header p,
.stats-updated-at {
    color: var(--font-color-secondary);
    font-size: 0.9rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem;
}

.stats-card {
    padding: 1rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.04);
}

.stats-label {
    display: block;
    color: var(--font-color-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.stats-value {
    display: block;
    color: #fff;
    font-size: 1.4rem;
    font-weight: 700;
}


/* --- 主内容加载器 --- */
.main-loader-container {
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    gap: 1rem; padding: 4rem 0; transition: opacity 0.3s ease;
}
.main-loader-container.hidden { display: none; }
.main-loader-container .loader {
    width: 48px; height: 48px; border-radius: 50%;
    display: inline-block;
    border-top: 4px solid var(--primary-color);
    border-right: 4px solid transparent;
    animation: spin 1s linear infinite;
}
.main-loader-container p { color: var(--font-color-secondary); font-size: 1rem; }


/* --- 日志卡片 --- */
.result-container { display: flex; flex-direction: column; gap: 1rem; }
.log-card {
    background: var(--glass-bg); border: 1px solid var(--border-color);
    border-radius: 0.75rem; overflow: hidden;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    cursor: pointer;
}
.log-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 24px var(--shadow-color);
    border-color: rgba(0, 169, 255, 0.5);
}

.log-summary {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.25rem; gap: 1rem;
}
.log-action {
    background-color: rgba(0, 169, 255, 0.15);
    color: var(--primary-color);
    padding: 0.3rem 0.75rem; border-radius: 20px;
    font-size: 0.8rem; font-weight: 500; white-space: nowrap;
}
.log-preview {
    flex-grow: 1; font-size: 0.9rem; color: var(--font-color-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.log-time { font-size: 0.9rem; color: var(--font-color-secondary); white-space: nowrap; }
.expand-icon {
    flex-shrink: 0; color: var(--font-color-secondary);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.log-card.expanded .expand-icon { transform: rotate(180deg); }

/* 日志详情 */
.log-details {
    max-height: 0; overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}
.log-card.expanded .log-details { max-height: 600px; }
.log-content {
    background-color: rgba(0, 0, 0, 0.4);
    margin: 0 1.25rem 1.25rem; padding: 1rem;
    border-radius: 0.5rem; font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem; color: #b0bec5; white-space: pre-wrap;
    word-break: break-all; max-height: 400px; overflow-y: auto;
    border-left: 3px solid var(--primary-color);
}

/* --- 消息提示 --- */
.message-container {
    text-align: center; padding: 1rem; border-radius: 0.625rem;
    margin-top: 1.5rem; font-weight: 500;
    opacity: 0; transform: translateY(-20px);
    transition: all 0.3s ease-in-out;
    display: none;
}
.message-container.show { opacity: 1; transform: translateY(0); display: block; }
.message-container.error { background-color: rgba(248, 81, 73, 0.15); color: var(--error-color); }
.message-container.success { background-color: rgba(63, 185, 80, 0.15); color: var(--success-color); }
.message-container.info { background-color: rgba(88, 169, 255, 0.15); color: var(--info-color); }

/* --- 响应式设计 --- */
@media (max-width: 768px) {
    body { padding: 2rem 1rem; }
    .main-container { padding: 1.5rem; }
    .app-header h1 { font-size: 1.8rem; }
    .stats-header,
    .log-summary { flex-wrap: wrap; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .log-preview { display: none; } /* 在小屏幕上隐藏预览 */
}

@media (max-width: 480px) {
    .running-task-status { top: 0.75rem; width: calc(100% - 1rem); }
    .liquid-capsule { min-height: 74px; padding: 0 18px; }
    .status-area { gap: 12px; }
    .spinner-wrapper { width: 40px; height: 40px; }
    .spinner-svg { width: 36px; height: 36px; }
    .status-text { font-size: 1.1rem; }
    .running-task-note { font-size: 0.78rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .stats-value { font-size: 1.2rem; }
    .log-summary { padding: 0.8rem 1rem; }
    .log-action { font-size: 0.75rem; }
    .log-time { font-size: 0.8rem; }
}
