/* Messages CSS */
.msg-container{max-width:800px;margin:20px auto;padding:0 20px}
.msg-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;flex-wrap:wrap;gap:12px}
.msg-header h2{margin:0;font-size:1.4rem;color:#1a1a2e}
.btn-compose{background:#667eea;color:#fff;padding:10px 20px;border-radius:8px;text-decoration:none;font-weight:600;font-size:.9rem}
.btn-compose:hover{background:#5a67d8}

/* Tabs */
.msg-tabs{display:flex;gap:0}
.msg-tab{padding:10px 20px;text-decoration:none;font-weight:600;font-size:.9rem;color:#667eea;background:#f0f0f0;border:1px solid #e0e0e0;border-right:none}
.msg-tab:last-child{border-right:1px solid #e0e0e0;border-radius:0 8px 8px 0}
.msg-tab:first-child{border-radius:8px 0 0 8px}
.msg-tab.active{background:#1a1a2e;color:#fff;border-color:#1a1a2e}
.msg-tab:hover:not(.active){background:#e8e8e8}

/* Message List */
.msg-list{background:#fff;border-radius:12px;box-shadow:0 2px 12px rgba(0,0,0,.08);overflow:hidden}
.msg-item{display:flex;align-items:flex-start;padding:16px 20px;border-bottom:1px solid #eee;gap:12px;transition:background .2s;text-decoration:none;color:inherit}
.msg-item:hover{background:#f8f9fa}
.msg-item:last-child{border-bottom:none}
.msg-item.received{border-left:3px solid #667eea}
.msg-item.sent{border-left:3px solid #10b981}

/* Avatar with profile link */
.msg-avatar-link{flex-shrink:0;display:block}
.msg-avatar-img{width:32px;height:32px;border-radius:50%;object-fit:cover;display:block}
.msg-avatar-link:hover .msg-avatar-img{opacity:.8}
.msg-avatar-placeholder{width:32px;height:32px;background:#e0e0e0;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:1rem;color:#666}
.msg-item.received .msg-avatar-placeholder{background:#eef2ff;color:#667eea}
.msg-item.sent .msg-avatar-placeholder{background:#d1fae5;color:#10b981}

/* Legacy avatar */
.msg-avatar{width:32px;height:32px;background:#e0e0e0;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:1rem;color:#666;flex-shrink:0}
.msg-item.received .msg-avatar{background:#eef2ff;color:#667eea}
.msg-item.sent .msg-avatar{background:#d1fae5;color:#10b981}

.msg-content{flex:1;min-width:0}
.msg-meta{display:flex;justify-content:space-between;font-size:.8rem;color:#888;margin-bottom:4px;flex-wrap:wrap;gap:4px}
.msg-from{font-weight:500;color:#333}
.msg-from a{color:#333;text-decoration:none}
.msg-from a:hover{color:#667eea;text-decoration:underline}
.msg-dir-received{color:#667eea;font-weight:600}
.msg-dir-received a{color:#1a1a2e;font-weight:700}
.msg-dir-sent{color:#10b981;font-weight:600}
.msg-dir-sent a{color:#1a1a2e;font-weight:700}
.msg-subject{display:block;font-weight:600;color:#1a1a2e;text-decoration:none;margin-bottom:4px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.msg-subject:hover{color:#667eea}
.msg-preview{font-size:.85rem;color:#666;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-height:1.3em}
.msg-body-link{display:block;color:#333;text-decoration:none;font-size:.9rem;line-height:1.5;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;word-break:break-word}
.msg-body-link:hover{color:#667eea}

.msg-actions{display:flex;gap:8px;flex-shrink:0;align-items:center}
.btn-view,.btn-reply{padding:6px 12px;border-radius:6px;font-size:.8rem;text-decoration:none;font-weight:500}
.btn-view{background:#f0f0f0;color:#333}
.btn-reply{background:#667eea;color:#fff}
.btn-view:hover{background:#e0e0e0}
.btn-reply:hover{background:#5a67d8}
.btn-del-sm{padding:6px 10px;border-radius:6px;font-size:1rem;text-decoration:none;background:#fff;border:1px solid #fecaca;color:#dc2626;cursor:pointer}
.btn-del-sm:hover{background:#fef2f2}

/* Pagination */
.msg-pagination{display:flex;justify-content:center;align-items:center;gap:16px;padding:16px;background:#fff;border-radius:12px;margin-top:16px;box-shadow:0 2px 12px rgba(0,0,0,.08)}
.btn-page{display:inline-block;padding:10px 20px;background:#667eea;color:#fff;border-radius:8px;text-decoration:none;font-weight:500;font-size:.9rem}
.btn-page:hover{background:#5a67d8}
.page-info{color:#666;font-size:.9rem}

/* Empty State */
.msg-empty{text-align:center;padding:60px 20px;color:#888;background:#fff;border-radius:12px;box-shadow:0 2px 12px rgba(0,0,0,.08)}
.msg-empty p{margin:8px 0}

/* Note Box */
.msg-note{background:#f0f9ff;border-left:4px solid #667eea;padding:12px 16px;border-radius:0 8px 8px 0;font-size:.9rem;color:#1e40af;margin-bottom:20px}

/* View Message */
.msg-back{display:inline-block;color:#667eea;text-decoration:none;margin-bottom:20px;font-size:.9rem}
.msg-back:hover{text-decoration:underline}
.msg-view-header{background:#fff;padding:24px;border-radius:12px 12px 0 0;box-shadow:0 2px 12px rgba(0,0,0,.08)}
.msg-view-header h1{margin:0 0 12px;font-size:1.3rem;color:#1a1a2e}
.msg-view-meta{display:flex;gap:20px;flex-wrap:wrap;font-size:.9rem;color:#666}
.msg-view-body{background:#fff;padding:24px;border-radius:0 0 12px 12px;box-shadow:0 2px 12px rgba(0,0,0,.08);white-space:pre-wrap;word-break:break-word;line-height:1.7}
.msg-view-actions{margin-top:20px;display:flex;gap:12px;flex-wrap:wrap}
.msg-view-actions .btn{padding:12px 24px;border-radius:8px;text-decoration:none;font-weight:600}
.btn-reply{background:#667eea;color:#fff}
.btn-contact{background:#10b981;color:#fff}
.btn-contact:hover{background:#059669}
.btn-del{background:#fee2e2;color:#dc2626}
.btn-del:hover{background:#fecaca}

/* Compose/Reply */
.msg-original{background:#f8f9fa;padding:16px;border-radius:8px;margin-bottom:20px}
.msg-quoted{font-style:italic;color:#666;margin-top:8px}
.fg{margin-bottom:20px}
.fg label{display:block;font-weight:600;margin-bottom:8px;color:#333}
.fg input,.fg textarea{width:100%;padding:12px;border:1px solid #ddd;border-radius:8px;font-size:1rem;font-family:inherit;box-sizing:border-box}
.fg input:focus,.fg textarea:focus{outline:none;border-color:#667eea}
.fg .hint{font-size:.8rem;color:#888;margin-top:6px}
.btn{display:inline-block;background:#667eea;color:#fff;padding:12px 24px;border-radius:8px;border:none;font-size:1rem;font-weight:600;cursor:pointer}
.btn:hover{background:#5a67d8}

/* Success/Error */
.msg-success{background:#d1fae5;color:#065f46;padding:24px;border-radius:12px;text-align:center;margin-bottom:20px}
.msg-success h2{margin:0 0 8px}
.msg-error{background:#fee2e2;color:#991b1b;padding:24px;border-radius:12px;text-align:center}
.msg-error h2{margin:0 0 12px}
.msg-error .btn{background:#667eea;color:#fff;margin-top:16px}

/* Conversation List */
.conv-list{background:#fff;border-radius:12px;box-shadow:0 2px 12px rgba(0,0,0,.08);overflow:hidden}
.conv-item{display:flex;align-items:center;padding:16px 20px;border-bottom:1px solid #eee;color:inherit;gap:14px;transition:background .2s}
.conv-item:last-child{border-bottom:none}
.conv-item:hover{background:#f8f9fa}
.conv-item.awaiting{background:#fffbeb;border-left:3px solid #f59e0b}
.conv-item.replied{border-left:3px solid transparent}
.conv-avatar-link{flex-shrink:0}
.conv-avatar-link:hover .conv-avatar{box-shadow:0 0 0 2px #667eea}
.conv-avatar{width:44px;height:44px;border-radius:50%;object-fit:cover;flex-shrink:0;transition:box-shadow .15s}
.conv-body{flex:1;min-width:0;text-decoration:none;color:inherit;display:block}
.conv-header{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:4px;gap:8px}
.conv-name{font-weight:700;color:#1a1a2e;font-size:.95rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.conv-item.awaiting .conv-name{color:#92400e}
.conv-time{font-size:.78rem;color:#999;white-space:nowrap;flex-shrink:0}
.conv-preview{font-size:.88rem;color:#555;line-height:1.4;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;word-break:break-word}
.conv-dot{width:10px;height:10px;border-radius:50%;background:#ef4444;flex-shrink:0;display:inline-block}

/* Mark All Banner */
.mark-all-banner{display:flex;align-items:center;justify-content:space-between;gap:12px;background:#fffbeb;border:1px solid #fde68a;border-radius:10px;padding:12px 16px;margin-bottom:12px;font-size:.88rem;color:#92400e;flex-wrap:wrap}
.btn-mark-all{background:#f59e0b;color:#fff;padding:7px 14px;border-radius:7px;text-decoration:none;font-weight:600;font-size:.85rem;white-space:nowrap;flex-shrink:0}
.btn-mark-all:hover{background:#d97706}

/* Responsive */
@media(max-width:600px){
.msg-item{flex-wrap:wrap}
.msg-actions{width:100%;margin-top:12px;justify-content:flex-end}
.msg-view-meta{flex-direction:column;gap:8px}
.msg-view-actions{flex-direction:column}
.msg-view-actions .btn{text-align:center}
.btn-page{padding:10px 16px;font-size:.85rem}
}



