/* 通用样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
    overflow-x: hidden;
}

.container {
    width: calc(100vw - 16px);
    max-width: none;
    margin: 0 auto;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    margin-top: 8px;
    margin-bottom: 8px;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 3px solid #007bff;
    padding-bottom: 20px;
}

.header h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    font-weight: 300;
}

/* 区块样式 */
.section {
    margin-bottom: 40px;
    padding: 25px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    align-items: start;
}

.section-grid-item {
    min-width: 0;
}

.section h3 {
    color: #495057;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-size: 1.4rem;
    font-weight: 500;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* 按钮样式 */
.btn {
    display: inline-block;
    padding: 12px 24px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    margin-right: 10px;
    margin-bottom: 10px;
}

.btn:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.btn-success {
    background-color: #28a745;
}

.btn-success:hover {
    background-color: #218838;
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.btn-danger {
    background-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

.btn-info {
    background-color: #17a2b8;
}

.btn-info:hover {
    background-color: #138496;
    box-shadow: 0 4px 8px rgba(23, 162, 184, 0.3);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

/* 按钮组 */
.btn-group {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.inline-form {
    display: inline-block;
}

.batch-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.batch-actions-wrap {
    align-items: center;
}

.batch-status {
    margin-left: 8px;
}

/* 表格样式 */
.table-responsive {
    overflow-x: auto;
    margin-top: 15px;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    margin-top: 15px;
    background-color: white;
}

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

.table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table tbody tr {
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

.table tbody tr:nth-child(even) {
    background-color: #fcfcfc;
}

/* 状态样式 */
.status-online {
    color: #28a745;
    font-weight: 600;
    font-size: 14px;
}

.status-offline {
    color: #dc3545;
    font-weight: 600;
    font-size: 14px;
}

.status-warning {
    color: #ffc107;
    font-weight: 600;
    font-size: 14px;
}

/* 文本样式 */
.small-text {
    font-size: 0.85em;
    color: #6c757d;
    overflow-wrap: anywhere;
}

.email-address-cell {
    min-width: 220px;
}

.email-address-text {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 8px;
    background: #f3f7fb;
    color: #1f2937;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.5;
    overflow-wrap: anywhere;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.16);
}

.email-inline-details-cell {
    background: #fafafa;
    border-top: 0;
    padding: 12px 14px;
}

.email-inline-details-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.email-inline-details-title {
    font-size: 14px;
    color: #111827;
}

.email-inline-refresh-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.email-inline-refresh-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #374151;
}

.email-refresh-interval-input {
    width: 72px;
    min-width: 72px;
    padding: 6px 8px;
    font-size: 12px;
}

.email-inline-card-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
}

.email-inline-card {
    min-width: 220px;
    max-width: 100%;
    height: 360px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    flex: 0 1 320px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.email-card--tiny {
    flex-basis: clamp(220px, 24%, 280px);
}

.email-inline-card--compact {
    flex-basis: clamp(240px, 28%, 320px);
}

.email-inline-card--wide {
    flex-basis: clamp(320px, 42%, 520px);
}

.email-inline-card--full {
    flex-basis: min(100%, 820px);
}

.email-inline-card-meta {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
    overflow-wrap: anywhere;
}

.email-inline-card-tags {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.email-inline-tag-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.email-inline-tag-label {
    font-size: 12px;
    color: #4b5563;
}

.email-inline-tag-value {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 12px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.email-inline-tag-row .btn {
    margin: 0;
}

.email-inline-card-subject {
    font-weight: 700;
    margin-bottom: 8px;
    color: #111827;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.email-inline-card-code {
    display: inline-block;
    margin-bottom: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #ecfdf3;
    color: #166534;
    font-weight: 700;
}

.email-inline-card-content {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
    font-size: 13px;
    color: #111827;
    margin-top: 2px;
    flex: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 12;
    -webkit-box-orient: vertical;
}

.toolbar-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-search-input {
    flex: 1 1 320px;
    min-width: 220px;
    max-width: 520px;
}

.toolbar-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 4px;
}

.result-actions-row {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.subject-cell {
    max-width: 300px;
}

.subject-cell span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 提示框样式 */
.alert {
    padding: 15px 20px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    position: relative;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

/* 空状态样式 */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 0;
}

/* 页脚样式 */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
    color: #6c757d;
    font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        width: calc(100vw - 16px);
        margin: 8px;
        padding: 15px;
        border-radius: 6px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .section {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .table th,
    .table td {
        padding: 8px;
        font-size: 14px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .btn-group {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-group .btn,
    .btn-group .inline-form,
    .btn-group .inline-form .btn {
        width: 100%;
        margin-right: 0;
    }
    
    .batch-actions .btn {
        display: block;
        width: 100%;
        margin-bottom: 10px;
    }

    .batch-status {
        width: 100%;
        margin-left: 0;
    }

    .toolbar-row {
        align-items: stretch;
    }

    .toolbar-search-input {
        max-width: none;
        min-width: 100%;
        flex-basis: 100%;
    }

    .toolbar-row .btn,
    .toolbar-toggle {
        width: 100%;
        justify-content: center;
        margin-right: 0;
    }

    .table {
        min-width: 860px;
    }

    .email-address-cell {
        min-width: 180px;
    }

    .email-address-text {
        font-size: 13px;
        padding: 4px 7px;
    }

    .email-inline-card-grid {
        gap: 10px;
    }

    .email-card--tiny,
    .email-inline-card--compact,
    .email-inline-card--wide,
    .email-inline-card--full {
        flex-basis: calc(50% - 5px);
        min-width: 220px;
    }

    .email-inline-card {
        height: 340px;
    }
}

@media (max-width: 480px) {
    .container {
        width: 100vw;
        margin: 0;
        border-radius: 0;
        padding: 12px;
    }

    .header h1 {
        font-size: 1.5rem;
    }
    
    .table-responsive {
        font-size: 12px;
    }
    
    .subject-cell {
        max-width: 150px;
    }

    .section-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .table {
        min-width: 760px;
    }

    .email-address-text {
        font-size: 12.5px;
    }

    .email-inline-details-header {
        align-items: stretch;
        flex-direction: column;
    }

    .email-inline-refresh-controls {
        width: 100%;
    }

    .email-inline-details-header .btn {
        width: 100%;
        margin-right: 0;
    }

    .email-inline-card-grid {
        display: block;
    }

    .email-inline-card {
        width: 100%;
        min-width: 0;
        height: 320px;
    }

    .email-inline-card-content {
        -webkit-line-clamp: 10;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* 加载状态 */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ========== AJAX 分页样式 ========== */

/* 加载动画 */
.loading-spinner {
    text-align: center;
    padding: 40px 0;
    color: #666;
}

.loading-spinner .spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

.loading-spinner p {
    font-size: 14px;
    color: #999;
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-top: 20px;
    border-top: 1px solid #eee;
    flex-wrap: wrap;
    gap: 15px;
}

.pagination-info {
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
}

.pagination-controls .btn-sm {
    padding: 6px 12px;
    font-size: 14px;
    min-width: 38px;
    height: 32px;
    text-align: center;
    cursor: pointer;
    border: 1px solid #ddd;
    background: white;
    color: #333;
    transition: all 0.2s ease;
    border-radius: 4px;
    font-weight: 500;
}

.pagination-controls .btn-sm:hover:not(.disabled):not(.active) {
    background-color: #f8f9fa;
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.15);
}

.pagination-controls .btn-sm.active {
    background-color: #007bff;
    color: white;
    font-weight: bold;
    border-color: #007bff;
    cursor: default;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.pagination-controls .btn-sm.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background-color: #f8f9fa;
}

.pagination-controls .ellipsis {
    padding: 6px 8px;
    color: #999;
    font-size: 14px;
    user-select: none;
}

/* 表格容器过渡效果 */
#email-list-container {
    transition: opacity 0.3s ease;
}

/* Section header for better spacing */
.section-header {
    margin-bottom: 20px;
}

.section-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

#email-count-info {
    font-size: 0.85em;
    color: #666;
    font-weight: normal;
}

/* 响应式设计 - 移动端优化 */
@media (max-width: 768px) {
    .pagination {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .pagination-info {
        text-align: center;
    }
    
    .pagination-controls {
        justify-content: center;
    }
    
    .pagination-controls .btn-sm {
        padding: 8px 10px;
        min-width: 32px;
        font-size: 13px;
    }
}
