/* style.css - Giao diện Boxed Center (Khung giữa màn hình) */

:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    /* Màu nền bên ngoài khung (đậm hơn chút để làm nổi bật khung) */
    --bg-body: #e2e8f0; 
    --bg-sidebar: #ffffff;
    --border-color: #cbd5e1;
    --text-main: #0f172a;
    --text-sub: #64748b;
    --hover-bg: #f8fafc;
}

body { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    background-color: var(--bg-body); 
    color: var(--text-main);
    height: 100vh; 
    width: 100vw;
    margin: 0;
    /* Căn giữa khung ứng dụng vào chính giữa màn hình */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tùy chỉnh thanh cuộn */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- KHUNG ỨNG DỤNG (THE BOX) --- */
.container { 
    /* Kích thước khung */
    width: 1400px;      /* Độ rộng tối đa */
    max-width: 95%;     /* Không vượt quá 95% màn hình */
    height: 90vh;       /* Cao 90% màn hình */
    
    /* Trang trí khung */
    background-color: #fff;
    border-radius: 16px; /* Bo tròn góc khung */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); /* Đổ bóng sâu */
    
    /* Layout bên trong */
    display: flex; 
    overflow: hidden; /* Cắt những phần thừa ra khỏi góc bo */
    box-sizing: border-box;
    padding: 0; /* Bỏ padding để sidebar dính sát viền */
}

/* --- SIDEBAR --- */
.sidebar { 
    width: 350px; 
    flex-shrink: 0; 
    background: var(--bg-sidebar); 
    border-right: 1px solid var(--border-color);
    display: flex; 
    flex-direction: column; 
    height: 100%; /* Cao full khung chứa */
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: #fff;
}

#email-list-container {
    overflow-y: auto; 
    flex-grow: 1; 
    padding: 10px;
}

/* Email Item */
.email-item { 
    padding: 12px 15px; 
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;       
    transition: all 0.2s ease; 
    border: 1px solid transparent;
}

.email-item:hover { 
    background-color: var(--hover-bg); 
}

.email-item.selected { 
    background-color: var(--primary-light); 
    color: var(--primary);
    font-weight: 600;
}

.email-text {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;     
    margin-right: 10px; font-size: 0.9rem; flex-grow: 1; display: block;
}

/* Action Buttons */
.action-buttons { display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.email-item:hover .action-buttons { opacity: 1; }
.icon-btn.relogin {
    color: #f59e0b; /* Màu cam */
    background-color: #fffbeb;
    border: 1px solid #fcd34d;
}
.icon-btn.relogin:hover {
    background-color: #d97706;
    color: white;
}
.icon-btn {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px; border: none; cursor: pointer;
    transition: all 0.2s; background: transparent;
}
.icon-btn:hover { background: #e2e8f0; transform: scale(1.1); }
.icon-btn.delete:hover { background: #fee2e2; color: #ef4444; }
.icon-btn.copy:hover { background: #dbeafe; color: #2563eb; }

/* --- MAIN CONTENT --- */
.main-content { 
    flex-grow: 1; 
    background: #fff; 
    height: 100%; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}

/* Pane Danh Sách Mail */
#mail-list-pane {
    flex: 0 0 45%; 
    overflow-y: auto;
    border-bottom: 1px solid var(--border-color);
    background: #fff;
}

#mail-results table { width: 100%; border-collapse: collapse; table-layout: fixed; }

/* Header bảng dính (Sticky) */
#mail-results th { 
    text-align: left; 
    background: #f8fafc; 
    padding: 12px 20px; 
    position: sticky; top: 0; z-index: 5; 
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-sub); font-weight: 600;
}

#mail-results td { 
    padding: 12px 20px; 
    border-bottom: 1px solid #f1f5f9; 
    cursor: pointer; 
    font-size: 0.9rem; color: var(--text-main);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background 0.1s;
}

#mail-results tr:hover td { background-color: #f8fafc; }
#mail-results tr.active-mail td { background-color: var(--primary-light); color: var(--primary); }

/* Style Chưa đọc (Gạch xanh bên trái) */
#mail-results tr.unread td { 
    font-weight: 700; 
    color: #000; 
    background-color: #fff;
}
#mail-results tr.unread td:first-child {
    border-left: 4px solid var(--primary);
    padding-left: 16px; /* Bù lại padding bị border chiếm */
}

/* Cột Avatar & Sender */
.sender-cell { display: flex; align-items: center; gap: 10px; }
.avatar-circle {
    width: 32px; height: 32px; border-radius: 50%;
    background: #e2e8f0; color: #475569;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: bold; text-transform: uppercase;
    flex-shrink: 0;
}

/* Pane Đọc Mail */
#mail-view-pane {
    flex: 1; 
    overflow-y: auto;
    padding: 0;
    background-color: #fff;
    display: flex; flex-direction: column;
}

.mail-view-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    background: #fff;
}
.mail-subject-large { font-size: 1.25rem; font-weight: 700; color: #1e293b; margin-bottom: 15px; }
.mail-meta-row { display: flex; justify-content: space-between; align-items: flex-start; }
.meta-info { display: flex; gap: 15px; align-items: center; }
.avatar-large { width: 48px; height: 48px; font-size: 1.2rem; }

#mail-content-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 30px;
    line-height: 1.6;
    color: #334155;
}

/* Skeleton Loading */
.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: loading 1.5s infinite; border-radius: 4px; }
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.sk-text { height: 16px; margin-bottom: 8px; width: 100%; }
.sk-avatar { width: 32px; height: 32px; border-radius: 50%; }

/* Buttons & Inputs */
.btn-primary { 
    background: var(--primary); color: white; border: none; padding: 10px 20px; 
    border-radius: 6px; font-weight: 500; cursor: pointer; width: 100%; transition: 0.2s; 
}
.btn-primary:hover { background: #1d4ed8; }

.search-input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-color); 
    border-radius: 6px; outline: none; transition: 0.2s; background: #f8fafc;
    box-sizing: border-box; /* Đảm bảo padding không làm vỡ layout */
}
.search-input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-light); }

/* Modal Styles */
.modal { display: none; position: fixed; z-index: 50; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }
.modal-content { background-color: #fff; margin: 10vh auto; padding: 25px; border-radius: 12px; width: 500px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
.close { float: right; font-size: 28px; cursor: pointer; color: #94a3b8; }
.close:hover { color: #0f172a; }
.import-area { width: 100%; height: 150px; border: 1px solid var(--border-color); padding: 12px; border-radius: 8px; font-family: monospace; font-size: 13px; background: #f8fafc; box-sizing: border-box; resize: none;}
.import-area:focus { outline: none; border-color: var(--primary); background: #fff; }
.btn-secondary {
    background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; 
    padding: 10px 20px; border-radius: 6px; font-weight: 500; 
    cursor: pointer; width: 100%; transition: 0.2s; text-align: center; display: block; text-decoration: none; box-sizing: border-box;
}
.btn-secondary:hover { background: #e2e8f0; color: #0f172a; }

/* Style cho icon nút Key (Copy Full) */
.icon-btn.key:hover { background: #fef3c7; color: #d97706; }