/* ============================================================
   mailer - Notion 设计风格
   canvas: #ffffff | primary: #5645d4 | ink: #0a1530
   surface: #f7f7f7 | hairline: #e5e5e5 | rounded: 8px
   font: Inter, sans-serif
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #0a1530; background: #ffffff; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: #0a1530; text-decoration: none; }
a:hover { color: #5645d4; }
code { background: #f0f0f0; padding: 2px 8px; border-radius: 4px; font-size: 0.9em; font-family: "JetBrains Mono", ui-monospace, monospace; color: #37352f; }
.text-center { text-align: center; }
.text-muted { color: #6b7280; }

/* --- Login Page --- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: #ffffff;
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: #ffffff; border-radius: 12px; padding: 40px;
    border: 1px solid #e5e5e5;
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-icon { font-size: 42px; margin-bottom: 8px; }
.login-header h1 { font-size: 22px; font-weight: 700; color: #0a1530; margin-bottom: 4px; letter-spacing: -0.3px; }
.login-header p { font-size: 14px; color: #6b7280; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 500; color: #37352f; font-size: 14px; }
.login-form input {
    width: 100%; padding: 10px 14px; border: 1px solid #e5e5e5; border-radius: 8px;
    font-size: 15px; transition: border-color 0.15s; outline: none; height: 40px; background: #ffffff;
}
.login-form input:focus { border-color: #5645d4; box-shadow: 0 0 0 2px rgba(86,69,212,0.15); }

/* --- Alert --- */
.alert { padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* --- Admin Layout --- */
.admin-body { display: flex; min-height: 100vh; background: #fafafa; }

/* --- Sidebar (Notion clean) --- */
.sidebar {
    width: 220px; background: #ffffff; display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; overflow-y: auto;
    border-right: 1px solid #ededed;
}
.sidebar-header {
    padding: 20px; display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid #f0f0f0;
}
.sidebar-logo { font-size: 24px; }
.sidebar-title { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; color: #0a1530; }
.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 20px;
    color: #6b7280; text-decoration: none; transition: all 0.1s; font-size: 14px; font-weight: 500;
    border-left: 2px solid transparent;
}
.nav-item:hover { background: #f7f7f7; color: #0a1530; }
.nav-item.active { background: #f7f7f7; color: #0a1530; border-left-color: #5645d4; font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; opacity: 0.7; }
.nav-divider { height: 1px; background: #f0f0f0; margin: 8px 20px; }
.nav-logout { margin-top: auto; color: #9ca3af; }
.sidebar-footer {
    padding: 12px 20px; border-top: 1px solid #f0f0f0;
    font-size: 13px; color: #9ca3af;
}

/* --- Main Content --- */
.main-content {
    flex: 1; margin-left: 220px; display: flex; flex-direction: column; min-height: 100vh;
}
.content-header {
    padding: 20px 28px; background: #ffffff; display: flex; justify-content: space-between;
    align-items: center; border-bottom: 1px solid #e5e5e5; position: sticky; top: 0; z-index: 40;
}
.content-header h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; color: #0a1530; }
.content-body { padding: 24px 28px; flex: 1; }

/* --- Stats Grid --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: #ffffff; border-radius: 12px; padding: 20px; display: flex; align-items: center;
    gap: 16px; border: 1px solid #e5e5e5;
}
.stat-icon { font-size: 32px; }
.stat-number { font-size: 24px; font-weight: 700; line-height: 1.2; color: #0a1530; }
.stat-label { font-size: 13px; color: #6b7280; font-weight: 500; }

/* --- Cards --- */
.card {
    background: #ffffff; border-radius: 8px; margin-bottom: 20px; overflow: hidden;
    border: 1px solid #e5e5e5;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; border-bottom: 1px solid #f0f0f0;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: #0a1530; }
.card-body { padding: 20px; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }

/* --- Buttons (Notion purple) --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: 8px; font-size: 14px; font-weight: 500;
    cursor: pointer; transition: all 0.1s; line-height: 1.4; height: 36px;
    font-family: Inter, sans-serif;
}
.btn-primary { background: #5645d4; color: #ffffff; }
.btn-primary:hover { background: #4534b3; }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary { background: #ffffff; color: #0a1530; border: 1px solid #e5e5e5; }
.btn-secondary:hover { background: #f7f7f7; }
.btn-info { background: #e8e4ff; color: #5645d4; border: 1px solid #d4ccff; }
.btn-info:hover { background: #ddd6ff; }
.btn-warning { background: #f59e0b; color: #ffffff; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: #dc2626; color: #ffffff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; color: #37352f; border: 1px solid #e5e5e5; }
.btn-outline:hover { background: #f7f7f7; }
.btn-block { width: 100%; }
.btn-lg { padding: 10px 20px; font-size: 15px; height: 40px; }
.btn-sm { padding: 4px 12px; font-size: 13px; height: 28px; border-radius: 6px; border: none; cursor: pointer; font-weight: 500; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; background: #f0f0f0; color: #9ca3af; border: none; }
.btn[disabled]:hover { background: #f0f0f0; color: #9ca3af; }

/* --- Forms (Notion clean) --- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 500; font-size: 14px; color: #37352f; }
.form-control {
    width: 100%; padding: 8px 14px; border: 1px solid #e5e5e5; border-radius: 8px;
    font-size: 14px; transition: border-color 0.15s; outline: none;
    height: 40px; font-family: Inter, sans-serif; color: #0a1530; background: #ffffff;
}
.form-control:focus { border-color: #5645d4; box-shadow: 0 0 0 2px rgba(86,69,212,0.12); }
.form-control:disabled { background: #fafafa; cursor: not-allowed; color: #9ca3af; }
.form-control::placeholder { color: #9ca3af; }
select.form-control { appearance: auto; cursor: pointer; }
textarea.form-control {
    resize: vertical; min-height: 100px; height: auto; line-height: 1.5; padding: 10px 14px;
}
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.form-group small { display: block; margin-top: 4px; color: #6b7280; font-size: 12px; }
.required { color: #dc2626; }
.radio-group { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-inline { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; color: #37352f; }
.radio-inline input[type="radio"] { accent-color: #5645d4; }

/* --- Tables --- */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 8px 14px; text-align: left; font-weight: 500; font-size: 13px;
    color: #6b7280; border-bottom: 1px solid #e5e5e5; white-space: nowrap; background: #fafafa;
}
.data-table td {
    padding: 8px 14px; border-bottom: 1px solid #f0f0f0; font-size: 14px; vertical-align: middle; color: #37352f;
}
.data-table tr:hover td { background: #f7f7f7; }
.data-table .action-cell { white-space: nowrap; display: flex; gap: 4px; }

/* --- Status Tags (Notion pill) --- */
.status-tag { display: inline-block; padding: 2px 10px; border-radius: 9999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.status-active, .status-success, .status-sent { background: #d1fae5; color: #065f46; }
.status-inactive, .status-error, .status-failed { background: #fee2e2; color: #991b1b; }
.status-checking, .status-pending, .status-sending { background: #fef3c7; color: #92400e; }

/* --- Badge --- */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 9999px; font-size: 12px; font-weight: 500;
    background: #f0f0f0; color: #37352f;
}
.badge-manual { background: #e0e7ff; color: #3730a3; }
.badge-ai { background: #f3e8ff; color: #6b21a8; }

/* --- Modal (Notion clean) --- */
.modal {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.25); z-index: 1;
}
.modal-content {
    position: relative; z-index: 2; background: #ffffff; border-radius: 8px;
    width: 90%; max-width: 520px; max-height: 85vh; overflow-y: auto;
    border: 1px solid #e5e5e5;
    animation: modalIn 0.15s ease;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 24px; border-bottom: 1px solid #f0f0f0;
}
.modal-header h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.3px; color: #0a1530; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #9ca3af; padding: 0; line-height: 1; transition: color 0.1s; }
.modal-close:hover { color: #0a1530; }
.modal-content .form-group { padding: 0 24px; }
.modal-content .form-actions { padding: 0 24px 16px; }
.modal-content .form-group:first-of-type { margin-top: 16px; }

/* --- Detail Grid --- */
.detail-grid { padding: 16px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-item label { font-size: 11px; color: #6b7280; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-item span { font-size: 14px; color: #0a1530; }

/* --- Quick Actions --- */
.quick-actions { margin-bottom: 24px; }
.quick-actions h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: #0a1530; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.action-card {
    background: #ffffff; border-radius: 8px; padding: 20px; display: flex; flex-direction: column;
    align-items: center; gap: 8px; text-decoration: none; color: #0a1530;
    transition: all 0.1s; cursor: pointer; border: 1px solid #e5e5e5;
}
.action-card:hover { border-color: #5645d4; }
.action-icon { font-size: 32px; }
.action-card small { font-size: 12px; color: #6b7280; }

/* --- Toast Notification --- */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 10px 18px; border-radius: 8px; font-size: 14px; color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08); animation: slideIn 0.2s ease; max-width: 400px;
    display: flex; align-items: center; gap: 8px; font-weight: 500;
}
.toast-success { background: #1aae39; }
.toast-error { background: #dc2626; }
.toast-warning { background: #f59e0b; color: #0a1530; }
.toast-info { background: #5645d4; }
@keyframes slideIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar { width: 180px; }
    .main-content { margin-left: 180px; }
    .content-header { padding: 16px 20px; }
    .content-body { padding: 16px 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .action-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
}

/* ===== 🔒 用户自定义（换风格时保留此段） ===== */
.data-table th,
.data-table td {
    padding-top: 15px;
    padding-bottom: 15px;
}
