/* ============================================
   HalaPlanet Webmail - 主样式表
   ============================================ */

:root {
    --primary: #4f6ef7;
    --primary-dark: #3b5de7;
    --primary-light: #eef1ff;
    --bg: #f0f2f5;
    --sidebar-bg: #1a1a2e;
    --sidebar-text: #a0aec0;
    --sidebar-active: #ffffff;
    --card-bg: #ffffff;
    --text: #1a202c;
    --text-secondary: #718096;
    --text-muted: #a0aec0;
    --border: #e2e8f0;
    --hover-bg: #f7fafc;
    --unread-bg: #ebf4ff;
    --unread-dot: #4f6ef7;
    --success: #48bb78;
    --success-bg: #f0fff4;
    --error: #fc8181;
    --error-bg: #fff5f5;
    --warning: #ecc94b;
    --warning-bg: #fffff0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-width: 250px;
    --toolbar-height: 64px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 
                 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ========== 布局 ========== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ========== 侧边栏 ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-name {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-email {
    font-size: 11px;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-compose {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px;
    padding: 11px 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(79, 110, 247, 0.3);
}

.btn-compose:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 110, 247, 0.4);
    color: white;
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
    text-decoration: none;
}

.nav-item.active {
    background: rgba(79, 110, 247, 0.15);
    color: var(--sidebar-active);
}

.nav-item.active .nav-icon {
    filter: brightness(1.2);
}

.nav-icon {
    font-size: 16px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s ease;
}

.btn-logout:hover {
    background: rgba(252, 129, 129, 0.1);
    color: var(--error);
    text-decoration: none;
}

/* ========== 主内容 ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    min-width: 0;
}

/* ========== 工具栏 ========== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.toolbar-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.toolbar-left h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.mail-count {
    font-size: 13px;
    color: var(--text-secondary);
}

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

/* ========== 搜索 ========== */
.search-form {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.search-input {
    border: none;
    padding: 8px 14px;
    font-size: 14px;
    outline: none;
    width: 240px;
    background: transparent;
    color: var(--text);
}

.search-input:focus {
    outline: none;
}

.btn-search {
    background: var(--primary-light);
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--primary);
    transition: background 0.15s;
}

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

.btn-clear-search {
    padding: 8px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
}

.btn-clear-search:hover {
    color: var(--text);
}

.btn-refresh {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 15px;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.btn-refresh:hover {
    background: var(--hover-bg);
    color: var(--text);
}

.btn-send-new {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-send-new:hover {
    background: var(--primary-dark);
    color: white;
    text-decoration: none;
}

.btn-back {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
}

.btn-back:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ========== 邮件列表 ========== */
.mail-list {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.mail-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s ease;
    gap: 12px;
    cursor: pointer;
    position: relative;
}

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

.mail-item:hover {
    background: var(--hover-bg);
    text-decoration: none;
    color: var(--text);
}

.mail-item.unread {
    background: var(--unread-bg);
}

.mail-item.unread:hover {
    background: #dbeafe;
}

.mail-item.unread .mail-from-name,
.mail-item.unread .subject-text {
    font-weight: 600;
}

.mail-checkbox {
    flex-shrink: 0;
}

.mail-select {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.mail-from {
    flex-shrink: 0;
    width: 200px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.mail-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #cbd5e1, #a0aec0);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.mail-item.unread .mail-avatar {
    background: linear-gradient(135deg, var(--primary), #818cf8);
}

.mail-from-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}

.mail-subject {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.subject-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}

.mail-attachment-icon,
.mail-flag-icon {
    flex-shrink: 0;
    font-size: 12px;
}

.mail-meta {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ========== 邮件详情 ========== */
.mail-detail {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.mail-detail-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--hover-bg);
}

.mail-detail-subject {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.flag-badge {
    display: inline-block;
    font-size: 12px;
    background: #fef3c7;
    color: #92400e;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    vertical-align: middle;
}

.mail-detail-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.mail-detail-from {
    display: flex;
    align-items: center;
    gap: 10px;
}

.detail-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.detail-sender {
    display: flex;
    flex-direction: column;
}

.sender-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.sender-email {
    font-size: 12px;
    color: var(--text-secondary);
}

.mail-detail-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item {
    font-size: 13px;
    display: flex;
    gap: 4px;
}

.info-label {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.info-value {
    color: var(--text);
    word-break: break-all;
}

.mail-detail-body {
    padding: 24px;
    min-height: 200px;
}

.mail-body-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    line-height: 1.8;
    color: var(--text);
    font-size: 14px;
}

.html-preview {
    width: 100%;
    border: none;
    border-radius: var(--radius);
    background: white;
}

/* ========== 附件 ========== */
.mail-attachments {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--hover-bg);
}

.mail-attachments h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text);
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
    transition: all 0.15s;
}

.attachment-item:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
    box-shadow: var(--shadow);
}

.att-icon { font-size: 18px; }
.att-name { font-weight: 500; }
.att-size { color: var(--text-muted); font-size: 11px; }
.att-download { margin-left: 4px; }

/* ========== 写邮件 ========== */
.compose-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.compose-field {
    display: flex;
    align-items: flex-start;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.compose-field:last-of-type {
    border-bottom: none;
}

.compose-label {
    width: 70px;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    padding-top: 8px;
}

.required {
    color: var(--error);
}

.compose-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    padding: 6px 0;
    color: var(--text);
    background: transparent;
}

.compose-value {
    flex: 1;
    font-size: 14px;
    padding: 8px 0;
    color: var(--text);
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.from-address {
    color: var(--primary);
    font-weight: 500;
}

.compose-actions-row {
    display: flex;
    gap: 12px;
    padding: 4px 20px;
    border-bottom: 1px solid var(--border);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 0;
}

.btn-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.compose-textarea {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.7;
    color: var(--text);
    background: transparent;
    resize: vertical;
    min-height: 280px;
    padding: 8px 0;
}

.compose-file {
    flex: 1;
    font-size: 13px;
    padding: 8px 0;
    color: var(--text-secondary);
}

.compose-buttons {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.btn-send {
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 110, 247, 0.4);
}

.btn-draft {
    padding: 10px 20px;
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-draft:hover {
    background: var(--hover-bg);
    border-color: var(--text-muted);
}

.btn-cancel {
    padding: 10px 20px;
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-cancel:hover {
    color: var(--error);
}

.file-list {
    padding: 0 20px 12px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    font-size: 13px;
}

.file-name {
    color: var(--text);
    font-weight: 500;
}

.file-size {
    color: var(--text-muted);
}

/* ========== 按钮样式 ========== */
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: all 0.15s;
}

.btn-action:hover {
    background: var(--hover-bg);
    color: var(--text);
    border-color: var(--text-muted);
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s;
}

.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}

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

.page-dots {
    padding: 0 6px;
    color: var(--text-muted);
}

/* ========== 状态提示 ========== */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

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

.btn-compose-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.btn-compose-link:hover {
    text-decoration: underline;
}

/* ========== 提示信息 ========== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-success {
    background: var(--success-bg);
    color: #22543d;
    border: 1px solid #c6f6d5;
}

.alert-error {
    background: var(--error-bg);
    color: #742a2a;
    border: 1px solid #fed7d7;
}

.alert-warning {
    background: var(--warning-bg);
    color: #744210;
    border: 1px solid #fefcbf;
}

.search-notice {
    background: var(--primary-light);
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--primary-dark);
}

/* ========== 批量操作 ========== */
.bulk-actions {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--sidebar-bg);
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 200;
}

.bulk-count {
    font-size: 13px;
    font-weight: 500;
    padding-right: 12px;
    border-right: 1px solid rgba(255,255,255,0.2);
}

.btn-bulk {
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.15s;
}

.btn-bulk:hover {
    background: rgba(255,255,255,0.2);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    
    .sidebar-header {
        padding: 16px 8px;
        justify-content: center;
    }
    
    .sidebar-brand {
        display: none;
    }
    
    .btn-compose {
        margin: 12px 8px;
        padding: 10px;
        justify-content: center;
    }
    
    .btn-compose span {
        display: none;
    }
    
    .nav-item .nav-label {
        display: none;
    }
    
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    
    .nav-icon {
        margin: 0;
    }
    
    .sidebar-footer .btn-logout span {
        display: none;
    }
    
    .sidebar-footer .btn-logout {
        justify-content: center;
    }
    
    .main-content {
        margin-left: 60px;
        padding: 16px;
    }
    
    .mail-from {
        width: 120px;
    }
    
    .mail-meta {
        display: none;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .mail-detail-meta {
        flex-direction: column;
    }
    
    .compose-field {
        flex-direction: column;
        gap: 4px;
    }
    
    .compose-label {
        padding-top: 0;
    }
    
    :root {
        --sidebar-width: 60px;
    }
}
