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

:root {
    --primary-color: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

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

header {
    text-align: center;
    margin-bottom: 3rem;
}

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

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

/* 状态消息 */
.status-message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    font-weight: 500;
}

.status-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.status-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.status-message.info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

.hidden {
    display: none !important;
}

/* 用户信息卡片 */
.user-info {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.info-card {
    background: var(--background);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.info-card p {
    margin: 0.5rem 0;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
}

.badge.active {
    background: #d1fae5;
    color: #065f46;
}

.badge.inactive {
    background: #fee2e2;
    color: #991b1b;
}

/* 主体容器 */
.login-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    /* max-width: 500px; */
    margin: 0 auto;
    text-align: center;
    margin-top: 4rem;
    width: 90%;
    max-width: 1000px;
}

.login-section h2 {
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.login-form {
    margin-top: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

/* 按钮 */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
    text-decoration: none;
}

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

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

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

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

.btn-large {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
}

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

/* 邮件列表 */
.email-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

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

.tabs {
    display: flex;
    gap: 0.5rem;
}

.tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab:hover {
    color: var(--primary-color);
}

.email-list {
    margin-bottom: 1rem;
}

.email-item,
.thread-item {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.email-item:hover,
.thread-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
    transform: translateX(4px);
}

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

.email-subject {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.email-from {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.email-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
}

.email-snippet {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.email-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

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

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--background);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

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

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* 加载指示器 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    color: white;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

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

    header h1 {
        font-size: 2rem;
    }

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

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

    .email-date {
        margin-top: 0.5rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}

/* 文件夹区域 */
.folder-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-top: 2rem;
}

.folders-list {
    margin-top: 1rem;
}

.folder-item {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
}

.folder-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
    transform: translateX(4px);
}

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

.folder-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

/* 同步状态区域 */
.sync-status {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.status-card {
    background: var(--background);
    border-radius: 8px;
    padding: 1.5rem;
}

.status-card h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.status-info {
    margin-bottom: 1rem;
}

.status-info p {
    margin: 0.5rem 0;
}

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

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

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

/* 登录卡片容器：水平并排 */
.login-options {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}

/* 登录卡片样式 */
.login-option {
    background: var(--background);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow-color);
    padding: 2rem;
    flex: 1;
    transition: all 0.3s ease;
    text-align: left;
}

.login-option:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px var(--hover-shadow);
}

.login-option h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.option-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* 分隔线 */
.login-divider {
    width: 2px;
    background: var(--border-color);
}

/* 响应式布局 */
@media (max-width: 768px) {
    .login-options {
        flex-direction: column;
        gap: 1.5rem;
    }

    .login-divider {
        display: none;
    }

    .login-option {
        width: 100%;
    }
}

/* 同步状态栏 */
.sync-status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.sync-status-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sync-item {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
    backdrop-filter: blur(10px);
}

.sync-icon {
    font-size: 20px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.sync-label {
    font-weight: 600;
    font-size: 14px;
}

.sync-text {
    font-size: 14px;
}

.progress-container {
    flex: 1;
    min-width: 200px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: white;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.sync-details {
    font-size: 12px;
    opacity: 0.9;
}

/* 当状态栏显示时，调整容器顶部间距 */
body:has(.sync-status-bar[style*="display: block"]) .container {
    margin-top: 120px;
}

/* Shopify Token 显示样式 */
.shopify-token-info {
    background: var(--background);
    border-radius: 8px;
    padding: 1.5rem;
}

.shopify-token-info .info-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.shopify-token-info .info-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.shopify-token-info .info-item strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.token-display {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.token-display code {
    flex: 1;
    background: #f1f5f9;
    padding: 0.75rem;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    word-break: break-all;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.scopes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 0.5rem;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
    padding: 1rem;
    border-radius: 8px;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .token-display {
        flex-direction: column;
        align-items: stretch;
    }
    
    .token-display code {
        width: 100%;
    }
}

/* Shopify 数据表样式 */
.shopify-data-tabs {
    margin-bottom: 1rem;
}

.shopify-data-tabs .tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.shopify-data-tabs .tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

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

.data-table-wrapper {
    overflow-x: auto;
    max-height: 500px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    background: var(--background);
    z-index: 10;
}

.data-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: var(--background);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.shopify-data-container {
    min-height: 300px;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .data-table {
        font-size: 0.75rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
}