/* TraceU - 人员行动轨迹管理工具样式 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8fafc;
}

/* 容器样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 页面头部 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.25rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: max(1.25rem, env(safe-area-inset-top));
    box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.15);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    text-align: left;
}

.header-right {
    display: flex;
    align-items: center;
}

.logo {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 300;
}

.settings-btn {
    padding: 0.6rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* 人员选择区域 */
.person-section {
    background: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.person-container {
    max-width: 800px;
    margin: 0 auto;
}

.section-title {
    font-size: 1.1rem;
    color: #1e293b;
    margin-bottom: 0.75rem;
    text-align: center;
}

.person-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    justify-items: center;
}

.person-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.6rem 2.4rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.person-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
}

.person-item.active {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.person-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.35rem;
}

/* 人员颜色定义 */
.person1-color {
    background: linear-gradient(135deg, #ff4757 0%, #ff3742 100%);
}

.person2-color {
    background: linear-gradient(135deg, #2ed573 0%, #1dd65a 100%);
}

.person3-color {
    background: linear-gradient(135deg, #3742fa 0%, #2f3542 100%);
}

.person4-color {
    background: linear-gradient(135deg, #ffa502 0%, #ff6348 100%);
}

.person-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
}

/* 搜索区域 */
.search-section {
    background: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.search-container {
    max-width: 560px;
    margin: 0 auto;
}

.current-person {
    margin-bottom: 1.5rem;
    text-align: center;
}

.current-person-info {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-radius: 25px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.current-person-info .person-avatar {
    width: 40px;
    height: 40px;
    margin-bottom: 0;
    font-size: 1rem;
}

.current-person-info span {
    font-weight: 600;
    color: #374151;
}

.current-person-info .person-avatar span {
    font-weight: 600;
    color: #ffffff;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.prefix-input {
    width: 140px;
    padding: 0.75rem 0.9rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: white;
}

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

.prefix-input:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

.search-input {
    flex: 1;
    padding: 0.9rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: white;
}

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

.search-input:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

.search-btn {
    padding: 0.9rem 1.1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.search-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.search-tips {
    text-align: center;
}

.tip {
    color: #64748b;
    font-size: 0.9rem;
}

/* 加载状态 */
.loading-section {
    background: white;
    padding: 2rem 0;
    text-align: center;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: #64748b;
    font-size: 1rem;
}

/* 搜索结果区域 */
.results-section {
    background: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.location-results {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

.location-item {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.location-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
}

.location-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.location-address {
    color: #64748b;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.location-type {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #f1f5f9;
    color: #475569;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* 主要内容区域 */
.main-content {
    padding: 1rem 0 1.5rem;
    min-height: 60vh;
}

.trace-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.trace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

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

.clear-btn {
    padding: 0.5rem 1rem;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clear-btn:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-1px);
}

.clear-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

/* 轨迹列表 */
.trace-list {
    padding: 1rem;
    min-height: 200px;
}

.trace-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 0.6rem;
    cursor: move;
    transition: all 0.3s ease;
}

.trace-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.trace-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.trace-order {
    width: 28px;
    height: 28px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    margin-right: 1rem;
}

.trace-content {
    flex: 1;
}

.trace-location {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.trace-address {
    font-size: 0.85rem;
    color: #64748b;
}

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

.trace-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.move-btn {
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #e0e7ff;
}

.move-btn:hover {
    background: #e0e7ff;
}

.delete-btn {
    background: #fef2f2;
    color: #ef4444;
}

.delete-btn:hover {
    background: #ef4444;
    color: white;
}

/* 占位内容 */
.placeholder-content {
    text-align: center;
    padding: 3rem 2rem;
}

.placeholder-icon {
    color: #cbd5e1;
    margin-bottom: 1.5rem;
}

.placeholder-title {
    font-size: 1.5rem;
    color: #475569;
    margin-bottom: 1rem;
}

.placeholder-text {
    color: #64748b;
    font-size: 1rem;
    max-width: 400px;
    margin: 0 auto;
}

/* 错误提示 */
.error-message {
    text-align: center;
    padding: 3rem 2rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-top: 2rem;
}

.error-icon {
    color: #ef4444;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 1.5rem;
    color: #dc2626;
    margin-bottom: 1rem;
}

.error-text {
    color: #64748b;
    margin-bottom: 1.5rem;
}

.retry-btn {
    padding: 0.75rem 1.5rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

.retry-btn:hover {
    background: #5a67d8;
}

/* 页面底部 */
.footer {
    background: #1e293b;
    color: #94a3b8;
    text-align: center;
    padding: 1.25rem 0;
    margin-top: 4rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .logo {
        font-size: 2rem;
    }
    
    .person-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }
    
    .search-box {
        flex-direction: column;
    }

    .prefix-input {
        width: 100%;
    }
    
    .search-btn {
        justify-content: center;
    }
    
    .trace-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .trace-item {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .trace-order {
        align-self: flex-start;
    }
    
    .trace-actions {
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .person-list {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem;
    }
    
    .search-input {
        padding: 0.875rem 1rem;
    }
    
    .search-btn {
        padding: 0.875rem 1.5rem;
    }
    
    .trace-list {
        padding: 1rem;
    }
}

/* 设置模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

/* 模态框 - 移动端优化 */
.modal-content {
    position: relative;
    max-width: 100%;
    width: calc(100% - 2rem);
    margin: 0 1rem;
    background: white;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #1e293b;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #e2e8f0;
    color: #374151;
}

.modal-body {
    padding: 1rem;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    justify-content: flex-end;
}

/* 设置表单样式 */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.form-input {
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

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

.form-help {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0;
}

.form-help a {
    color: #667eea;
    text-decoration: none;
}

.form-help a:hover {
    text-decoration: underline;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
}

.status-dot.success {
    background: #10b981;
}

.status-dot.warning {
    background: #f59e0b;
}

.status-text {
    font-size: 0.9rem;
    color: #374151;
}

.save-btn, .test-btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.save-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.test-btn {
    background: #f1f5f9;
    color: #374151;
    border: 1px solid #e2e8f0;
}

.test-btn:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
}

/* 更窄屏（<=360px）精调 */
@media (max-width: 360px) {
    .prefix-input { width: 120px; }
    .logo { font-size: 1.4rem; }
    .subtitle { font-size: 0.85rem; }
    .search-btn { padding: 0.8rem 1rem; }
}

/* 轨迹图区域 */
.trace-map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.trace-map-actions {
    display: flex;
    gap: 0.5rem;
}

.download-btn {
    padding: 0.9rem 1.1rem;
    background: #10b981;
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.download-btn:hover {
    background: #0ea37a;
}

.static-map-preview {
    margin-top: 1rem;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
}

.static-map-preview img {
    width: 100%;
    height: auto;
    display: block;
}

@media (max-width: 768px) {
    .trace-map-header { flex-direction: column; align-items: stretch; gap: 0.5rem; }
    .trace-map-actions { justify-content: flex-end; }
    .static-map-preview { min-height: 200px; }
}