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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --success-color: #10b981;
    --error-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 1.5rem 1rem;
    color: var(--text-primary);
}

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

header {
    text-align: center;
    color: white;
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

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

main {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.search-section {
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

#mobileInput {
    flex: 1;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    transition: all 0.2s;
    outline: none;
}

#mobileInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-primary {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--primary-color);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

.btn-primary:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

.hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

/* 提示和刷新行 */
.hint-refresh-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
}

/* 倒计时提示 - 独立显示 */
.countdown {
    color: var(--success-color);
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
    margin-left: auto;
    margin-right: 0.5rem;
}

.countdown.hidden {
    display: none;
}

/* 自动刷新开关 */
.auto-refresh-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.switch-label {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    cursor: pointer;
}

.switch-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border-radius: 24px;
    transition: 0.3s;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

.switch-input:checked + .switch-slider {
    background-color: var(--success-color);
}

.switch-input:checked + .switch-slider:before {
    transform: translateX(24px);
}

.switch-input:disabled + .switch-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.switch-text {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
}
    font-weight: 500;
}

.countdown {
    color: var(--success-color);
    font-weight: 600;
    font-size: 0.875rem;
}

.loading {
    text-align: center;
    padding: 3rem 1rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-secondary);
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

.results-section {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

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

.message-count {
    background: var(--primary-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.message-card {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    transition: background 0.2s;
}

.message-card:last-child {
    border-bottom: none;
}

.message-card:hover {
    background: var(--bg-color);
}

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

.message-sender {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.sender-icon {
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.sender-id {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.message-content {
    background: transparent;
    padding: 0;
    border: none;
    line-height: 1.5;
    color: var(--text-primary);
    word-wrap: break-word;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.message-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.meta-label {
    font-weight: 500;
}

.status-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
}

.status-success {
    background: #d1fae5;
    color: #065f46;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

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

.empty-state p {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.hidden {
    display: none;
}

/* 历史记录下拉列表 */
.history-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
    box-shadow: var(--shadow);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: -0.5rem;
}

.history-dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.history-dropdown-item:last-child {
    border-bottom: none;
}

.history-dropdown-item:hover {
    background: var(--bg-color);
}

.history-dropdown-item .mobile-number {
    font-weight: 500;
    color: var(--text-primary);
}

.history-dropdown-item .query-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-dropdown-item .delete-btn {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s;
}

.history-dropdown-item:hover .delete-btn {
    opacity: 1;
}

.history-dropdown-item .delete-btn:hover {
    color: #dc2626;
}

/* 历史记录区域 */
.input-group {
    position: relative;
}

.history-section {
    margin-top: 1rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
}

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

.history-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.btn-clear {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: var(--error-color);
    color: white;
    border-color: var(--error-color);
}

.history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: center;
}

.history-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.history-tag .mobile-number {
    color: var(--primary-color);
    font-size: 0.875rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px dashed transparent;
}

.history-tag .mobile-number:hover {
    color: var(--primary-hover);
    border-bottom-color: var(--primary-hover);
}

.history-tag .remove-tag {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    margin-left: -0.25rem;
    transition: color 0.2s;
}

.history-tag .remove-tag:hover {
    color: var(--error-color);
}

@media (max-width: 640px) {
    header h1 {
        font-size: 2rem;
    }

    main {
        padding: 1.5rem;
    }

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

    .btn-primary {
        width: 100%;
    }
    
    .hint-refresh-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .countdown {
        align-self: flex-end;
        margin-left: 0;
        margin-right: 0;
    }
    
    .auto-refresh-control {
        width: 100%;
        justify-content: space-between;
    }

    .message-header {
        flex-direction: column;
    }

    .message-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .history-dropdown {
        position: fixed;
        left: 1rem;
        right: 1rem;
        max-height: 50vh;
    }
}
