/**
 * SimilarWeb 流量查询工具 - 样式文件
 * 现代、简洁、美观的UI设计
 */

/* 重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 
                 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* 容器 */
.container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 1rem 2rem;
    box-sizing: border-box;
}

/* 头部 */
header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* 标签页区域 */
.tabs-section {
    margin-bottom: 2rem;
}

.tabs {
    display: flex;
    gap: 1rem;
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

.tab-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.tab-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tab-btn.disabled:hover {
    transform: none;
}

.tab-icon {
    font-size: 1.2rem;
}

.tab-name {
    font-weight: 600;
}

.tab-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
}

.tab-badge.unavailable {
    background: var(--error-color);
    color: white;
}

/* 输入区域 */
.input-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

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

.input-header label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.input-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#domains-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    resize: vertical;
    transition: border-color 0.3s;
}

#domains-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 按钮组 */
.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

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

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

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-export {
    background: var(--success-color);
    color: white;
}

.btn-export:hover {
    background: #059669;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 进度条区域 */
.progress-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    border-radius: 6px;
    width: 0%;
    transition: width 0.3s ease;
}

/* 结果区域 */
.results-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

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

.results-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.results-summary {
    display: flex;
    gap: 1.5rem;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.summary-item.success {
    color: var(--success-color);
}

.summary-item.failed {
    color: var(--error-color);
}

.summary-item.total {
    color: var(--primary-color);
}

/* 表格 */
.table-container {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

#results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#results-table th {
    background: var(--bg-color);
    color: var(--text-primary);
    font-weight: 600;
    text-align: left;
    padding: 1rem 0.75rem;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

/* 可排序列样式 */
#results-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s;
}

#results-table th.sortable:hover {
    background-color: rgba(67, 97, 238, 0.1);
}

#results-table th.sortable.sorted {
    background-color: rgba(67, 97, 238, 0.15);
    font-weight: 700;
}

.sort-icon {
    margin-left: 0.25rem;
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: bold;
}

#results-table td {
    padding: 0.875rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

/* 月度趋势和关键词单元格 */
.monthly-visits-cell,
.keywords-cell {
    font-size: 0.85rem;
    line-height: 1.4;
    max-width: 300px;
    min-width: 180px;
    word-break: break-word;
    white-space: normal;
}

.monthly-visits-cell div,
.keywords-cell div {
    padding: 1px 0;
}

#results-table tbody tr:hover {
    background: var(--bg-color);
}

.status-success {
    color: var(--success-color);
    font-weight: 600;
}

.status-failed {
    color: var(--error-color);
    font-weight: 600;
}

.traffic-sources {
    font-size: 0.85rem;
    line-height: 1.4;
}

.countries-list {
    font-size: 0.85rem;
    line-height: 1.4;
}

.category-cell {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 导出按钮 */
.export-buttons {
    display: flex;
    gap: 1rem;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

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

    .results-summary {
        flex-wrap: wrap;
    }

    .export-buttons {
        flex-direction: column;
    }

    #results-table {
        font-size: 0.8rem;
    }

    #results-table th,
    #results-table td {
        padding: 0.5rem 0.25rem;
    }
}

/* 加载动画 */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading {
    animation: spin 1s linear infinite;
}

