/**
 * 邮箱管理控制台 - Apple Style
 * 简洁、优雅、现代
 */

/* ==================== 全局样式 - 紫色主题 ==================== */
:root {
    /* 紫色主题色 */
    --primary-purple: #8B5CF6;
    --primary-purple-dark: #7C3AED;
    --primary-purple-light: #A78BFA;
    --primary-purple-bg: #F3E8FF;
    
    /* 中性色 */
    --primary-black: #1F2937;
    --primary-dark-gray: #374151;
    --primary-gray: #6B7280;
    --primary-light-gray: #9CA3AF;
    --primary-bg-gray: #F5F7FA;
    --primary-white: #FFFFFF;
    --primary-border: #E5E7EB;
    
    /* 辅助色 */
    --success-green: #10B981;
    --danger-red: #EF4444;
    --warning-orange: #F59E0B;
    --info-cyan: #06B6D4;
    
    /* 阴影 */
    --shadow-sm: rgba(0, 0, 0, 0.05);
    --shadow-md: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 
                 'Helvetica Neue', Arial, sans-serif;
    background: var(--primary-bg-gray);
    color: var(--primary-black);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ==================== 左侧导航栏布局 ==================== */
.sidebar-layout {
    display: flex;
    min-height: 100vh;
}

/* 左侧边栏 */
.sidebar {
    width: 220px;
    background: var(--primary-white);
    box-shadow: 2px 0 8px var(--shadow-sm);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

/* 侧边栏头部 */
.sidebar-header {
    padding: 24px 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-black);
    border-bottom: 1px solid var(--primary-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header i {
    color: var(--primary-purple);
    font-size: 22px;
}

/* 侧边栏导航 */
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--primary-gray);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: #F9FAFB;
    color: var(--primary-purple);
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--primary-purple-bg);
    color: var(--primary-purple);
    border-left-color: var(--primary-purple);
}

.sidebar-link i {
    font-size: 16px;
    width: 18px;
    text-align: center;
}

.sidebar-link-logout {
    margin-top: auto;
    border-top: 1px solid var(--primary-border);
    color: var(--primary-purple);
}

.sidebar-link-logout:hover {
    background: var(--primary-purple-bg);
    color: var(--primary-purple-dark);
}

/* 右侧内容区 */
.content-area {
    margin-left: 220px;
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    background: var(--primary-bg-gray);
}

.container-fluid {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* ==================== 导航栏 ==================== */
.navbar {
    background: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.navbar-brand {
    font-size: 22px;
    font-weight: 600;
    color: #212121 !important;
    padding: 20px 0;
    letter-spacing: -0.5px;
}

.navbar-brand i {
    font-size: 24px;
    margin-right: 12px;
    color: #2196F3 !important;
}

/* ==================== 标签页 ==================== */
.nav-tabs {
    border: none;
    background: transparent;
    padding: 32px 0 24px;
    display: flex;
    gap: 8px;
}

.nav-tabs .nav-item {
    margin: 0;
}

.nav-tabs .nav-link {
    border: none;
    background: white;
    color: #212121 !important;
    font-size: 15px;
    font-weight: 500;
    padding: 12px 24px;
    border-radius: 980px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    letter-spacing: -0.2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.nav-tabs .nav-link:hover {
    background: #f5f5f5;
    color: #2196F3 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(33, 150, 243, 0.15);
}

.nav-tabs .nav-link.active {
    background: #424242;
    color: white !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.nav-tabs .nav-link i {
    margin-right: 8px;
    color: inherit !important;
}

/* ==================== 卡片 ==================== */
.card {
    background: white;
    border: none;
    border-radius: 18px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.card-header {
    background: var(--primary-purple) !important;
    border: none;
    padding: 20px 24px;
    font-size: 18px;
    font-weight: 600;
    color: white !important;
    letter-spacing: -0.3px;
    border-radius: 12px 12px 0 0;
}

.card-header i {
    margin-right: 10px;
    color: white !important;
    font-size: 20px;
    vertical-align: middle;
}

.card-body {
    padding: 24px 32px 32px;
}

/* ==================== 表单元素 ==================== */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #212121 !important;
    margin-bottom: 8px;
    letter-spacing: -0.2px;
}

.form-control, 
select.form-control, 
textarea.form-control {
    border: 1px solid #E0E0E0;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 15px;
    background: white;
    color: #212121 !important;
    transition: all 0.2s ease;
    width: 100%;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.form-control:focus,
select.form-control:focus,
textarea.form-control:focus {
    border-color: #2196F3;
    outline: none;
    box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.12), 0 2px 8px rgba(33, 150, 243, 0.08);
    background: white;
    transform: translateY(-1px);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding: 12px 44px 12px 16px;
    line-height: 1.5;
    height: auto;
    min-height: 46px;
    cursor: pointer;
}

select.form-control option {
    padding: 12px 16px;
    line-height: 1.5;
}

/* 邮件文件夹选择框样式优化 */
#mailFolder {
    font-weight: 500;
    color: #212121;
}

#mailFolder option {
    padding: 10px 15px;
    font-weight: 500;
}

/* ==================== 按钮 ==================== */
.btn {
    border: none;
    border-radius: 980px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.2px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-purple) !important;
    color: white !important;
    border-color: var(--primary-purple) !important;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
}

.btn-primary:hover {
    background: var(--primary-purple-dark) !important;
    border-color: var(--primary-purple-dark) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}

.btn-success,
.bg-success {
    background: var(--success-green) !important;
    color: white !important;
    border-color: var(--success-green) !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    background: #059669 !important;
    border-color: #059669 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-danger,
.bg-danger {
    background: var(--danger-red) !important;
    color: white !important;
    border-color: var(--danger-red) !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: #DC2626 !important;
    border-color: #DC2626 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.btn-warning,
.bg-warning {
    background: var(--warning-orange) !important;
    color: white !important;
    border-color: var(--warning-orange) !important;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.btn-warning:hover {
    background: #D97706 !important;
    border-color: #D97706 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.35);
}

.btn-secondary,
.bg-secondary {
    background: var(--primary-gray) !important;
    color: white !important;
    border-color: var(--primary-gray) !important;
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.2);
}

.btn-secondary:hover {
    background: #4B5563 !important;
    border-color: #4B5563 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(107, 114, 128, 0.35);
}

.btn-info,
.bg-info,
.bg-primary {
    background: var(--primary-purple) !important;
    color: white !important;
    border-color: var(--primary-purple) !important;
}

.btn-info:hover {
    background: var(--primary-purple-dark) !important;
    border-color: var(--primary-purple-dark) !important;
}

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

.btn i {
    margin-right: 6px;
}

/* ==================== 统计卡片 ==================== */
/* 统计卡片已移除，保留CSS供未来使用 */
/*
#accountStats {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: white;
    padding: 15px 0;
    margin-top: 20px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
}
*/

/* ==================== 表格 ==================== */
.table-responsive {
    border-radius: 12px;
    margin-top: 16px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    max-height: 600px;
    overflow-y: scroll;
    overflow-x: hidden;
    position: relative;
}

/* 确保表格容器内滚动时表头固定 */
.table-responsive table {
    position: relative;
    width: calc(100% - 10px);
}

/* 滚动条样式优化 - 使其在框内 */
.table-responsive::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 0;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--primary-purple);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--primary-purple-dark);
}

table {
    width: 100%;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    transition: opacity 0.3s ease;
    table-layout: fixed;
}

/* 列宽度设置 */
table th:nth-child(1),
table td:nth-child(1) {
    width: 50px;  /* ID列 */
}

table th:nth-child(2),
table td:nth-child(2) {
    width: 180px;  /* 用户名列 */
}

table th:nth-child(3),
table td:nth-child(3) {
    width: 240px;  /* 邮箱列 */
}

table th:nth-child(4),
table td:nth-child(4) {
    width: 150px;  /* 密码列 */
}

table th:nth-child(5),
table td:nth-child(5) {
    width: 160px;  /* 创建时间列 */
}

table th:nth-child(6),
table td:nth-child(6) {
    width: 120px;  /* 邮件数列 */
}

table th:nth-child(7),
table td:nth-child(7) {
    width: 200px;  /* 操作列 */
}

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

table thead th {
    padding: 14px 12px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--primary-purple-dark);
    background: var(--primary-purple);
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 第一列ID单独设置 */
table thead th:first-child,
table tbody td:first-child {
    text-align: center;
    padding-left: 8px;
    padding-right: 8px;
}

table tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid #E0E0E0;
    background: white;
}

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

table tbody tr:hover {
    background: rgba(33, 150, 243, 0.08);
    transform: scale(1.002);
}

table tbody td {
    padding: 14px 12px;
    font-size: 14px;
    color: #424242;
    word-wrap: break-word;
    overflow-wrap: break-word;
    vertical-align: middle;
}

table tbody td strong {
    font-weight: 600;
}

/* ==================== 徽章 ==================== */
.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.1px;
}

.badge-success {
    background: rgba(48, 209, 88, 0.15);
    color: #4CAF50;
}

.badge-secondary {
    background: rgba(134, 134, 139, 0.15);
    color: #757575;
}

.badge-primary {
    background: rgba(0, 113, 227, 0.15);
    color: #2196F3;
}

/* ==================== 操作按钮组 ==================== */
.action-buttons {
    display: flex;
    gap: 8px;
}

.action-buttons .btn {
    padding: 8px 12px;
    border-radius: 8px;
}

/* ==================== 提示框 ==================== */
.alert {
    border: none;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 15px;
    font-weight: 500;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.alert-success {
    background: rgba(48, 209, 88, 0.1);
    color: #1e7d34;
}

.alert-danger {
    background: rgba(255, 59, 48, 0.1);
    color: #d32f2f;
}

.alert-warning {
    background: rgba(255, 149, 0, 0.1);
    color: #f57c00;
}

.alert-info {
    background: rgba(33, 150, 243, 0.1);
    color: #1976D2 !important;
}

/* ==================== 加载动画 ==================== */
.spinner-border {
    border-width: 3px;
}

/* ==================== 工具类 ==================== */
.hidden {
    display: none !important;
}

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

.text-muted {
    color: #757575 !important;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.py-5 {
    padding-top: 3rem;
    padding-bottom: 3rem;
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    /* 左侧导航栏变窄，只显示图标 */
    .sidebar {
        width: 60px;
    }
    
    .sidebar-header span {
        display: none;
    }
    
    .sidebar-header {
        padding: 20px 10px;
        justify-content: center;
    }
    
    .sidebar-link span {
        display: none;
    }
    
    .sidebar-link {
        padding: 14px 10px;
        justify-content: center;
    }
    
    .content-area {
        margin-left: 60px;
        padding: 16px;
    }
    
    .card-header {
        font-size: 16px;
        padding: 16px;
    }
    
    .card-body {
        padding: 16px;
    }
    
    .table-responsive {
        max-height: 400px;
    }
    
    table {
        font-size: 13px;
    }
    
    table thead th,
    table tbody td {
        padding: 10px 6px;
    }
}

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

.card {
    animation: fadeIn 0.5s ease;
}

/* ==================== 分页控件样式 ==================== */
#paginationControls {
    padding: 15px 0;
    border-top: 1px solid #e0e0e0;
    position: relative;
    z-index: 1;
    background: white;
}

#paginationControls select {
    position: relative;
    z-index: 100;
}

.pagination-label {
    font-size: 13px;
}

.pagination-select {
    width: 90px;
}

/* 确保下拉框选项可见 */
select.form-control {
    background-color: white;
}

select.form-control-sm {
    height: auto;
    padding: 6px 30px 6px 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-color: white;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.pagination {
    margin: 0;
}

.pagination .page-item {
    margin: 0 2px;
}

.pagination .page-link {
    border-radius: 6px;
    border: 1px solid #dee2e6;
    color: var(--primary-purple);
    padding: 8px 12px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.pagination .page-link:hover {
    background-color: var(--primary-purple-bg);
    border-color: var(--primary-purple);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-purple);
    border-color: var(--primary-purple);
    color: white;
    font-weight: 600;
}

.pagination .page-item.disabled .page-link {
    color: #6c757d;
    pointer-events: none;
    cursor: not-allowed;
    background-color: #f8f9fa;
}

/* ==================== 模态框内表格样式 ==================== */
#resultModalBody .table-responsive {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 0;
}

#resultModalBody table {
    width: 100%;
    table-layout: fixed;
    margin-bottom: 0;
}

#resultModalBody table td,
#resultModalBody table th {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    padding: 10px 8px;
    font-size: 13px;
}

#resultModalBody table td:first-child,
#resultModalBody table th:first-child {
    width: 35%;
}

#resultModalBody table td:nth-child(2),
#resultModalBody table th:nth-child(2) {
    width: 30%;
}

#resultModalBody table td:nth-child(3),
#resultModalBody table th:nth-child(3) {
    width: 35%;
}

/* ==================== 复选框样式 ==================== */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2196F3;
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 64px;
    color: #757575;
    opacity: 0.5;
    margin-bottom: 20px;
}

.empty-state p {
    font-size: 17px;
    color: #757575;
    font-weight: 500;
}

/* ==================== 搜索框 ==================== */
.input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.input-group .form-control {
    flex: 1;
}

/* ==================== 固定提示框 ==================== */
.alert.fixed-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    min-width: 320px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==================== 细节优化 ==================== */
code {
    background: #BDBDBD;
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 14px;
    color: #F44336;
}

hr {
    border: none;
    border-top: 1px solid #E0E0E0;
    margin: 24px 0;
}

/* ==================== 页面标题 ==================== */
.page-title {
    font-size: 48px;
    font-weight: 700;
    color: #424242;
    margin-bottom: 12px;
    letter-spacing: -1px;
}

.page-subtitle {
    font-size: 21px;
    color: #757575;
    margin-bottom: 32px;
    font-weight: 400;
    letter-spacing: -0.3px;
}

/* ==================== 邮件详情样式 ==================== */
.mail-detail {
    font-size: 14px;
}

.mail-detail .mail-header {
    margin-bottom: 20px;
}

.mail-detail .mail-subject {
    color: var(--primary-black);
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-blue);
}

.mail-detail .mail-meta p {
    margin: 8px 0;
    color: var(--primary-dark-gray);
}

.mail-detail .mail-meta strong {
    color: var(--primary-black);
    min-width: 80px;
    display: inline-block;
}

.mail-detail .mail-body h6 {
    color: var(--primary-black);
    font-weight: 600;
    margin-bottom: 10px;
}

.mail-detail .mail-content {
    line-height: 1.6;
    word-wrap: break-word;
}

.mail-detail .mail-path {
    font-size: 12px;
}

/* 导航栏按钮 */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-actions .btn {
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.navbar-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}
