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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    /* 移动端优化 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .duplicate-item:hover {
        background: #f8f9ff; /* 移动端禁用hover效果 */
        border-color: #e8eaff;
        transform: none;
        box-shadow: none;
    }
    
    .keyword-row:hover {
        background-color: inherit; /* 移动端禁用hover效果 */
    }
    
    .select-btn:hover {
        background: white; /* 移动端禁用hover效果 */
        color: #667eea;
        transform: none;
        box-shadow: none;
    }
}

/* 触摸反馈 */
.select-btn:active {
    transform: scale(0.98);
    opacity: 0.8;
}

.btn:active {
    transform: scale(0.98);
}

.duplicate-item:active {
    transform: scale(0.99);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 主要内容区域 */
main {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

section {
    padding: 30px;
    border-bottom: 1px solid #eee;
}

section:last-child {
    border-bottom: none;
}

h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

h3 {
    color: #34495e;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

/* 输入区域样式 */
.input-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

#keywordInput {
    flex: 1;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    min-height: 150px;
    font-family: 'Courier New', monospace;
    /* 移动端优化 */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

#keywordInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-help {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.input-help p {
    margin-bottom: 5px;
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 117, 125, 0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

/* 结果区域样式 */
.result-group {
    margin-bottom: 30px;
}

/* 非重复关键词容器 - 固定高度和独立滚动 */
.keywords-list {
    background: white;
    border-radius: 10px;
    border: 1px solid #dee2e6;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: 400px; /* 固定高度 */
    display: flex;
    flex-direction: column;
}

.keywords-table {
    width: 100%;
    border-collapse: collapse;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.keywords-table-header {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    font-weight: 600;
    flex-shrink: 0; /* 防止表头被压缩 */
}

.keywords-table th,
.keywords-table td {
    padding: 12px 20px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.keywords-table th {
    font-size: 14px;
    letter-spacing: 0.5px;
    text-align: left !important; /* 强制左对齐 */
}

.keywords-table-body {
    flex: 1; /* 占用剩余空间 */
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
    /* 移动端滚动优化 */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.keywords-table-body table {
    width: 100%;
    border-collapse: collapse;
}

.keyword-row {
    transition: background-color 0.2s ease;
    display: table-row;
}

.keyword-row:hover {
    background-color: #f8f9fa;
}

.keyword-row:nth-child(even) {
    background-color: #f9f9f9;
}

.keyword-row:nth-child(even):hover {
    background-color: #f1f1f1;
}

.keyword-text {
    font-weight: 500;
    color: #2c3e50;
    font-size: 14px;
}

.keyword-exposure {
    font-weight: 600;
    color: #28a745;
    font-size: 14px;
}

.keywords-table-body::-webkit-scrollbar {
    width: 8px;
}

.keywords-table-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.keywords-table-body::-webkit-scrollbar-thumb {
    background: #28a745;
    border-radius: 4px;
}

.keywords-table-body::-webkit-scrollbar-thumb:hover {
    background: #1e7e34;
}

/* 移动端隐藏滚动条但保持功能 */
@media (max-width: 768px) {
    .keywords-table-body::-webkit-scrollbar {
        width: 0px;
        background: transparent;
    }
    
    .keywords-table-body {
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE */
    }
}

/* 如果没有数据时的样式 */
.no-keywords {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    font-style: italic;
    font-size: 16px;
}

/* 选择模式控件样式 */
.selection-mode-controls {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.mode-selector {
    display: flex;
    align-items: center;
    gap: 20px;
}

.mode-label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
    min-width: 80px;
}

.radio-group {
    display: flex;
    gap: 30px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px 15px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.radio-option:hover {
    background-color: #e9ecef;
}

.radio-option input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: #667eea;
}

.radio-text {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.mode-description {
    color: #6c757d;
    font-size: 12px;
    font-style: italic;
    margin-left: 5px;
}

/* 重复关键词组样式 - 重新设计颜色 */
.duplicate-group {
    margin-bottom: 25px;
    border: 1px solid #e3f2fd;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
    transition: box-shadow 0.3s ease;
}

.duplicate-group:hover {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.15);
}

.group-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.3px;
}

.group-content {
    padding: 20px;
    background: linear-gradient(to bottom, #f8f9ff 0%, #ffffff 100%);
}

.duplicate-keywords {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.duplicate-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #f8f9ff;
    border-radius: 8px;
    border: 1px solid #e8eaff;
    transition: all 0.3s ease;
    position: relative;
}

.duplicate-item:hover {
    background: #f0f2ff;
    border-color: #d1d9ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.duplicate-item.selected {
    background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
    border: 2px solid #28a745;
    box-shadow: 0 3px 12px rgba(40, 167, 69, 0.2);
}

.duplicate-item.selected::before {
    content: "✓";
    position: absolute;
    left: -1px;
    top: -1px;
    background: #28a745;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.duplicate-item.selected .keyword-text {
    color: #155724;
    font-weight: 600;
}

.duplicate-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.select-btn {
    padding: 8px 16px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.select-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.select-btn.selected {
    background: #28a745;
    color: white;
    border-color: #28a745;
    font-weight: 600;
}

.select-btn.selected:hover {
    background: #218838;
    border-color: #218838;
}

/* 最终结果样式 */
.final-results {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.final-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.summary-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.summary-number {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 5px;
}

.summary-label {
    color: #666;
    font-size: 14px;
}

.final-keywords {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    height: 400px;
    margin-top: 20px;
}

.final-keywords-table-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0;
    margin: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.final-keywords-table-header th {
    font-size: 14px;
    letter-spacing: 0.5px;
    text-align: left !important;
    padding: 12px 20px;
    font-weight: 600;
}

.final-keywords-table-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
    /* 移动端滚动优化 */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.final-keywords-table-body table {
    width: 100%;
    border-collapse: collapse;
}

.final-keyword-row {
    transition: background-color 0.2s ease;
    display: table-row;
}

.final-keyword-row:hover {
    background-color: #f8f9fa;
}

.final-keyword-row:nth-child(even) {
    background-color: #f9f9f9;
}

.final-keyword-row:nth-child(even):hover {
    background-color: #f1f1f1;
}

.final-keyword-text {
    font-weight: 500;
    color: #2c3e50;
    font-size: 14px;
}

.final-keyword-exposure {
    font-weight: 600;
    color: #28a745;
    font-size: 14px;
}

.final-keywords-table-body::-webkit-scrollbar {
    width: 8px;
}

.final-keywords-table-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.final-keywords-table-body::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.final-keywords-table-body::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.final-keyword-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #28a745;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .input-controls {
        flex-direction: column;
    }
    
    #keywordInput {
        min-height: 120px;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    /* 移动设备上的表格优化 */
    .keywords-list {
        height: 300px; /* 移动设备上减小高度 */
    }
    
    .keywords-table th,
    .keywords-table td {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .keywords-table-header th {
        padding: 10px 12px;
    }
    
    .keyword-row td {
        padding: 8px 12px;
    }
    
    /* 重复关键词组移动端优化 */
    .duplicate-group {
        margin-bottom: 20px;
        border-radius: 8px;
    }
    
    .group-header {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .group-content {
        padding: 15px;
    }
    
    .duplicate-item {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 10px;
    }
    
    .duplicate-item > div:first-child {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    
    .keyword-text {
        font-size: 14px;
        word-break: break-word;
    }
    
    .keyword-exposure {
        font-size: 13px;
        align-self: flex-start;
    }
    
    .duplicate-controls {
        justify-content: center;
        width: 100%;
    }
    
    .select-btn {
        padding: 10px 20px;
        font-size: 14px;
        min-height: 44px; /* 触摸友好 */
        border-radius: 8px;
        width: 100%;
        max-width: 200px;
    }
    
    /* 按钮组优化 */
    .btn {
        padding: 14px 24px;
        font-size: 16px;
        min-height: 48px; /* 触摸友好 */
    }
    
    #analyzeBtn {
        width: 100%;
        margin-top: 10px;
    }
    
    #finalizeBtn {
        width: 100%;
        margin-top: 15px;
    }
    
    .final-keywords {
        height: 300px;
    }
    
    .final-keywords-table-header th {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .final-keyword-text,
    .final-keyword-exposure {
        font-size: 13px;
    }
    
    .final-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .summary-card {
        padding: 15px;
    }
    
    .summary-number {
        font-size: 1.5rem;
    }
    
    .final-keywords-table-body::-webkit-scrollbar {
        width: 0px;
        background: transparent;
    }
    
    .final-keywords-table-body {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    /* 选择模式控件移动端适配 */
    .selection-mode-controls {
        padding: 15px;
    }
    
    .mode-selector {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .radio-group {
        flex-direction: column;
        gap: 15px;
        width: 100%;
    }
    
    .radio-option {
        padding: 12px 15px;
        border: 1px solid #e9ecef;
        border-radius: 8px;
        background: white;
    }
    
    .radio-option:hover {
        border-color: #667eea;
        background-color: #f8f9ff;
    }
    
    .mode-description {
        display: block;
        margin-top: 3px;
        margin-left: 24px;
    }
}

/* 更小屏幕适配 (小于480px) */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    section {
        padding: 20px 15px;
    }
    
    .keywords-list {
        height: 250px;
    }
    
    .keywords-table th,
    .keywords-table td {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .group-header {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .group-content {
        padding: 12px;
    }
    
    .duplicate-item {
        padding: 10px;
    }
    
    .select-btn {
        padding: 8px 16px;
        font-size: 13px;
        min-height: 40px;
    }
    
    .final-summary {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .summary-card {
        padding: 12px;
    }
    
    .summary-number {
        font-size: 1.3rem;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 15px;
    }
    
    /* 选择模式控件在更小屏幕的适配 */
    .selection-mode-controls {
        padding: 12px;
    }
    
    .mode-label {
        font-size: 13px;
    }
    
    .radio-text {
        font-size: 13px;
    }
    
    .mode-description {
        font-size: 11px;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .keywords-list {
        height: 200px;
    }
    
    .duplicate-item {
        flex-direction: row;
        align-items: center;
    }
    
    .duplicate-controls {
        width: auto;
    }
    
    .select-btn {
        width: auto;
        min-width: 100px;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 提示样式 */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
} 