/* ============================================================
   WebMail Team - Main Stylesheet
   Dark theme với accent tím (Indigo/Violet)
   ============================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================================ */
:root {
  /* Colors */
  --bg-primary:      #0f1117;
  --bg-secondary:    #161b27;
  --bg-tertiary:     #1e2535;
  --card-bg:         #1a2033;
  --sidebar-bg:      #141926;
  --border-color:    #2a3147;
  --border-hover:    #3d4f72;

  /* Text */
  --text-primary:    #e4e8f0;
  --text-secondary:  #9ca3af;
  --text-muted:      #6b7280;

  /* Accent */
  --accent-primary:  #6366f1;
  --accent-hover:    #5558e5;
  --accent-glow:     rgba(99, 102, 241, 0.3);
  --accent-subtle:   rgba(99, 102, 241, 0.08);

  /* Status */
  --unread-bg:       #1a2033;
  --unread-bg-hover: #1f2840;
  --read-bg:         #141926;
  --read-bg-hover:   #192032;

  /* UI */
  --navbar-height:   60px;
  --sidebar-width:   260px;
  --input-bg:        #1e2535;
  --login-bg:        linear-gradient(135deg, #0c0e16 0%, #111827 50%, #0f1729 100%);

  /* Shadows */
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:       0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.5);

  /* Radius */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   24px;

  /* Transitions */
  --transition-fast:   all 0.15s ease;
  --transition-normal: all 0.25s ease;
  --transition-slow:   all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--text-primary); }
a { color: var(--accent-primary); transition: var(--transition-fast); }
a:hover { color: var(--accent-hover); text-decoration: none; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.font-mono { font-family: 'Fira Code', 'Consolas', monospace; letter-spacing: 0.05em; }

code {
  background: rgba(99,102,241,0.1);
  color: #a78bfa;
  padding: 0.15em 0.5em;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'Consolas', monospace;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.wb-navbar {
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  height: var(--navbar-height);
  padding: 0 1rem;
  box-shadow: 0 1px 16px rgba(0,0,0,0.3);
  z-index: 1030;
}

.brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: white;
  box-shadow: 0 3px 10px var(--accent-glow);
}
.brand-text { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.brand-sub  { color: var(--accent-primary); }

/* Account Select in Navbar */
.account-selector-wrapper { flex: 1; max-width: 480px; }
.wb-account-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-fast);
  max-width: 340px;
}
.wb-account-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
  outline: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.wb-account-select option { background: var(--bg-secondary); }

/* User Button */
.wb-user-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: var(--transition-fast);
}
.wb-user-btn:hover { border-color: var(--accent-primary); color: var(--text-primary); background: var(--bg-tertiary); }

/* User Avatar bubble */
.user-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: white;
  flex-shrink: 0;
}

/* Dropdown */
.wb-dropdown {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  overflow: hidden;
}
.wb-dropdown .dropdown-item {
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  transition: var(--transition-fast);
}
.wb-dropdown .dropdown-item:hover { background: var(--accent-subtle); color: var(--text-primary); }
.wb-dropdown .dropdown-item.text-danger:hover { background: rgba(239,68,68,0.1); color: #f87171; }
.wb-dropdown .dropdown-divider { border-color: var(--border-color); }
.wb-dropdown .dropdown-item-text { color: var(--text-muted); font-size: 0.8rem; padding: 0.4rem 1rem; }

/* Flash Alerts */
.wb-flash-alert {
  margin: calc(var(--navbar-height) + 8px) 1rem 0;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  border: none;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PAGE LAYOUT: Sidebar + Mail Panel
   ============================================================ */
.wb-wrapper {
  padding-top: var(--navbar-height);
  height: 100vh;
  overflow: hidden; /* toàn bộ scroll xảy ra bên trong panel */
}

.wb-page-container {
  display: flex;
  height: calc(100vh - var(--navbar-height));
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.wb-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: sticky;
  top: var(--navbar-height);
  height: calc(100vh - var(--navbar-height));
  overflow-y: auto;
}

/* Account Card in Sidebar */
.sidebar-account-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
}
.admin-sidebar-card { border-color: rgba(99,102,241,0.3); }

.account-avatar {
  width: 40px; height: 40px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.1rem;
  box-shadow: 0 3px 10px var(--accent-glow);
}
.admin-avatar {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 3px 10px rgba(245,158,11,0.3);
}

.sidebar-mail-count {
  font-size: 0.78rem; color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Sidebar Search */
.sidebar-search-form .form-control,
.sidebar-search-form .input-group-text {
  background: var(--input-bg);
  border-color: var(--border-color);
  color: var(--text-primary);
  font-size: 0.85rem;
}
.sidebar-search-form .form-control:focus {
  border-color: var(--accent-primary);
  box-shadow: none;
  background: var(--input-bg);
  color: var(--text-primary);
}
.sidebar-search-form .form-control::placeholder { color: var(--text-muted); }
.sidebar-search-form .btn-outline-secondary {
  border-color: var(--border-color); color: var(--text-muted);
}

/* Sidebar Nav */
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav-item {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 500;
  text-decoration: none;
  transition: var(--transition-fast);
  cursor: pointer;
}
.sidebar-nav-item:hover { background: var(--accent-subtle); color: var(--text-primary); }
.sidebar-nav-item.active { background: var(--accent-subtle); color: var(--accent-primary); }
.sidebar-nav-item i { font-size: 1rem; width: 18px; flex-shrink: 0; }

.sidebar-divider { border-color: var(--border-color); margin: 0.25rem 0; }

/* Sidebar Accounts */
.sidebar-accounts-section { margin-top: auto; }
.sidebar-section-title {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
  padding: 0 0.5rem; margin-bottom: 0.375rem;
}
.sidebar-account-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.82rem;
  text-decoration: none; transition: var(--transition-fast);
}
.sidebar-account-item:hover { background: var(--accent-subtle); color: var(--text-primary); }
.sidebar-account-item.active { color: var(--accent-primary); }
.acc-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-hover); flex-shrink: 0; transition: var(--transition-fast);
}
.acc-dot.active { background: var(--accent-primary); }

/* ============================================================
   MAIL PANEL (main content area)
   ============================================================ */
.wb-mail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* Panel chiếm toàn bộ chiều cao còn lại, scroll nội bộ */
  height: 100%;
  overflow: hidden;
}

/* Panel Header — cố định đầu panel, KHÔNG sticky (panel cha đã fixed) */
.mail-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0; /* Không co lại */
  z-index: 5;
}
.panel-title {
  font-size: 1rem; font-weight: 600;
  color: var(--text-primary);
}

/* ============================================================
   MAIL LIST — scroll bên trong panel
   ============================================================ */
.mail-list,
.mail-content-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mail-item {
  display: flex; align-items: center; gap: 0.875rem;
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  transition: var(--transition-fast);
  position: relative;
  cursor: pointer;
}

/* UNREAD MAIL - Bold + Light background */
.mail-item.mail-unread {
  background: var(--unread-bg);
}
.mail-item.mail-unread:hover { background: var(--unread-bg-hover); }
.mail-item.mail-unread .mail-from {
  font-weight: 700; color: var(--text-primary);
}
.mail-item.mail-unread .mail-subject {
  font-weight: 600; color: var(--text-primary);
}
.mail-item.mail-unread .mail-unread-dot {
  opacity: 1;
}

/* READ MAIL - Normal weight + Darker background */
.mail-item.mail-read {
  background: var(--read-bg);
}
.mail-item.mail-read:hover { background: var(--read-bg-hover); }
.mail-item.mail-read .mail-from {
  font-weight: 400; color: var(--text-secondary);
}
.mail-item.mail-read .mail-subject {
  font-weight: 400; color: var(--text-secondary);
}
.mail-item.mail-read .mail-unread-dot { opacity: 0; }

/* Unread indicator dot */
.mail-unread-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-primary);
  flex-shrink: 0;
  transition: opacity 0.2s;
  box-shadow: 0 0 6px var(--accent-glow);
}

/* Sender Avatar */
.mail-avatar {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem; color: white;
  box-shadow: var(--shadow-sm);
}

/* Mail Info */
.mail-info { flex: 1; min-width: 0; }
.mail-from-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.2rem; }
.mail-from { font-size: 0.9rem; }
.mail-date { font-size: 0.78rem; color: var(--text-muted); flex-shrink: 0; margin-left: 0.5rem; }
.mail-subject { font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-preview { font-size: 0.8rem; }

/* Arrow */
.mail-arrow {
  color: var(--text-muted);
  font-size: 0.875rem;
  opacity: 0;
  transform: translateX(-4px);
  transition: var(--transition-fast);
  flex-shrink: 0;
}
.mail-item:hover .mail-arrow { opacity: 1; transform: translateX(0); }

/* Empty / Error States */
.mail-empty-state,
.mail-error-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4rem 2rem; text-align: center; color: var(--text-muted);
}
.empty-icon, .error-icon {
  font-size: 3.5rem; margin-bottom: 1rem; opacity: 0.5;
}

/* Pagination */
.mail-pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  gap: 1rem; flex-wrap: wrap;
}
.pagination-info { font-size: 0.82rem; color: var(--text-muted); }
.pagination .page-link {
  background: var(--bg-tertiary); border-color: var(--border-color);
  color: var(--text-secondary); font-size: 0.82rem;
  transition: var(--transition-fast);
}
.pagination .page-link:hover { background: var(--accent-subtle); border-color: var(--accent-primary); color: var(--accent-primary); }
.pagination .page-item.active .page-link {
  background: var(--accent-primary); border-color: var(--accent-primary); color: white;
}
.pagination .page-item.disabled .page-link { background: var(--bg-secondary); color: var(--text-muted); }

/* ============================================================
   MAIL DETAIL
   ============================================================ */
.mail-detail-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.mail-detail-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.mail-detail-subject {
  font-size: 1.3rem; font-weight: 700;
  color: var(--text-primary); line-height: 1.4;
  word-break: break-word;
  margin-bottom: 1rem;
}

.mail-meta-block {
  display: flex; flex-direction: column; gap: 0.5rem;
}
.mail-meta-row { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.meta-label { font-size: 0.8rem; color: var(--text-muted); flex-shrink: 0; min-width: 60px; }
.meta-value { font-size: 0.875rem; color: var(--text-secondary); word-break: break-word; }
.mail-meta-from { color: var(--text-primary); font-weight: 500; }

/* Attachments */
.mail-attachments { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.attachments-title { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.5rem; }
.attachments-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.attachment-item {
  display: flex; align-items: center;
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}

/* Mail Body */
.mail-body-container {
  flex: 1; display: flex; flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

.mail-body-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.btn-xs { font-size: 0.75rem; padding: 0.2rem 0.5rem; }

.mail-iframe-wrapper {
  flex: 1; overflow: hidden;
  background: #ffffff; /* Email content always light bg */
  transition: var(--transition-normal);
}
.mail-iframe-wrapper.expanded { position: fixed; inset: 0; z-index: 9999; }

.mail-iframe {
  width: 100%; border: none;
  min-height: 300px; max-height: none;
  display: block;
  background: #ffffff;
}

/* ============================================================
   ADMIN PANEL
   ============================================================ */
.admin-section { padding: 1.5rem; }
.admin-section-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap;
}
.admin-section-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.25rem; }
.admin-section-desc { font-size: 0.85rem; color: var(--text-muted); margin: 0; }
.section-divider { border-color: var(--border-color); margin: 0 1.5rem; }

/* Table */
.wb-table {
  color: var(--text-primary);
  border-collapse: separate; border-spacing: 0;
  font-size: 0.875rem;
}
.wb-table thead th {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-muted);
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.625rem 1rem;
}
.wb-table tbody td {
  border-color: var(--border-color);
  padding: 0.75rem 1rem;
  vertical-align: middle;
  transition: background 0.15s;
}
.wb-table tbody tr { transition: background 0.15s; }
.wb-table tbody tr:hover td { background: var(--accent-subtle); }
.wb-table tbody td:first-child { border-left: 3px solid transparent; }
.wb-table tbody tr:hover td:first-child { border-left-color: var(--accent-primary); }

/* Mini Avatar in table */
.mini-avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: white;
}
.mini-avatar.admin { background: linear-gradient(135deg, #f59e0b, #ef4444); }

.gmail-addr {
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

/* Admin Empty State */
.admin-empty-state {
  text-align: center; padding: 3rem;
  color: var(--text-muted);
}

/* ============================================================
   MODALS
   ============================================================ */
.wb-modal {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
}
.wb-modal .modal-header {
  border-color: var(--border-color);
  padding: 1.25rem 1.5rem;
}
.wb-modal .modal-title { font-size: 1rem; font-weight: 700; }
.wb-modal .modal-footer { border-color: var(--border-color); }
.wb-modal .btn-close { filter: invert(0.8); }

/* Form controls in modal */
.wb-modal .form-control,
.wb-modal .form-select {
  background: var(--input-bg);
  border: 1.5px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: var(--transition-fast);
}
.wb-modal .form-control:focus,
.wb-modal .form-select:focus {
  background: var(--input-bg);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
  color: var(--text-primary);
}
.wb-modal .form-control::placeholder { color: var(--text-muted); }
.wb-modal .form-label { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0.375rem; }
.wb-modal .form-text { color: var(--text-muted); font-size: 0.8rem; }
.wb-modal .input-group .btn { border-color: var(--border-color); color: var(--text-muted); }
.wb-modal .form-check-input { background-color: var(--bg-tertiary); border-color: var(--border-color); }
.wb-modal .form-check-input:checked { background-color: var(--accent-primary); border-color: var(--accent-primary); }
.wb-modal .form-select option { background: var(--bg-secondary); }
.modal-backdrop { background: rgba(0,0,0,0.7); }

/* ============================================================
   BUTTONS - Custom Overrides
   ============================================================ */
.btn { font-weight: 500; border-radius: var(--radius-sm); transition: var(--transition-fast); }
.btn-primary {
  background: var(--accent-primary); border-color: var(--accent-primary);
}
.btn-primary:hover {
  background: var(--accent-hover); border-color: var(--accent-hover);
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-outline-primary { color: var(--accent-primary); border-color: var(--accent-primary); }
.btn-outline-primary:hover {
  background: var(--accent-primary); border-color: var(--accent-primary);
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-outline-secondary { color: var(--text-muted); border-color: var(--border-color); }
.btn-outline-secondary:hover { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border-hover); }
.btn-outline-info { color: #67e8f9; border-color: #67e8f9; }
.btn-outline-info:hover { background: rgba(103,232,249,0.1); color: #67e8f9; }
.btn-outline-warning { color: #fbbf24; border-color: #fbbf24; }
.btn-outline-warning:hover { background: rgba(251,191,36,0.1); color: #fbbf24; }
.btn-outline-danger { color: #f87171; border-color: #f87171; }
.btn-outline-danger:hover { background: rgba(248,113,113,0.1); color: #f87171; }

/* ============================================================
   BADGES
   ============================================================ */
.bg-success-subtle { background: rgba(34,197,94,0.1) !important; }
.text-success-emphasis { color: #4ade80 !important; }
.border-success-subtle { border-color: rgba(34,197,94,0.3) !important; }

.bg-danger-subtle { background: rgba(239,68,68,0.1) !important; }
.text-danger-emphasis { color: #f87171 !important; }
.border-danger-subtle { border-color: rgba(239,68,68,0.3) !important; }

.bg-warning-subtle { background: rgba(245,158,11,0.1) !important; }
.text-warning-emphasis { color: #fbbf24 !important; }
.border-warning-subtle { border-color: rgba(245,158,11,0.3) !important; }

.bg-primary-subtle { background: rgba(99,102,241,0.1) !important; }
.text-primary-emphasis { color: #818cf8 !important; }
.border-primary-subtle { border-color: rgba(99,102,241,0.3) !important; }

.bg-secondary-subtle { background: rgba(107,114,128,0.1) !important; }
.text-secondary-emphasis { color: #9ca3af !important; }

.bg-info-subtle { background: rgba(103,232,249,0.1) !important; }
.text-info-emphasis { color: #67e8f9 !important; }
.border-info-subtle { border-color: rgba(103,232,249,0.3) !important; }

/* ============================================================
   ALERTS in main layout
   ============================================================ */
.alert {
  border: none;
  border-left: 4px solid;
  border-radius: var(--radius-sm);
}
.alert-success { background: rgba(34,197,94,0.1); color: #4ade80; border-left-color: #4ade80; }
.alert-danger   { background: rgba(239,68,68,0.1); color: #f87171; border-left-color: #f87171; }
.alert-info     { background: rgba(99,102,241,0.1); color: #818cf8; border-left-color: #818cf8; }
.alert-warning  { background: rgba(245,158,11,0.1); color: #fbbf24; border-left-color: #fbbf24; }
.alert .btn-close { filter: invert(0.6); }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.toast-body { color: var(--text-primary); font-size: 0.875rem; }
.text-bg-success { background: rgba(34,197,94,0.9) !important; color: white !important; }
.text-bg-danger  { background: rgba(239,68,68,0.9)  !important; color: white !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991px) {
  :root { --sidebar-width: 220px; }
}

@media (max-width: 767px) {
  .wb-sidebar { display: none; }
  .mail-item { padding: 0.75rem 1rem; gap: 0.625rem; }
  .mail-avatar { width: 32px; height: 32px; font-size: 0.8rem; }
  .mail-detail-header { padding: 1rem; }
  .mail-detail-subject { font-size: 1.1rem; }
  .admin-section { padding: 1rem; }
  .mail-panel-header { padding: 0.75rem 1rem; }
}

@media (max-width: 575px) {
  .mail-pagination { flex-direction: column; align-items: stretch; }
}

/* ============================================================
   FOLDER TABS (sidebar nav items với màu riêng)
   ============================================================ */
.folder-item { position: relative; }
.folder-item .folder-count {
  margin-left: auto;
  font-size: 0.72rem;
  background: var(--accent-primary);
  color: white;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}
.folder-item.folder-spam.active  { color: #f87171; }
.folder-item.folder-trash.active { color: #fb923c; }
.folder-item.folder-spam:hover,
.folder-item.folder-trash:hover  { color: var(--text-primary); }

/* Search bar trong panel header */
.panel-search-wrapper {
  display: flex; align-items: center;
  background: var(--input-bg);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex: 1; max-width: 420px;
  transition: var(--transition-fast);
}
.panel-search-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.panel-search-icon {
  padding: 0 0.625rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}
.panel-search-input {
  flex: 1; border: none; background: transparent;
  color: var(--text-primary);
  font-size: 0.875rem;
  padding: 0.45rem 0;
  outline: none;
  font-family: inherit;
}
.panel-search-input::placeholder { color: var(--text-muted); }
.panel-search-btn {
  background: var(--accent-primary); border: none; color: white;
  padding: 0.45rem 0.75rem; font-size: 0.8rem; cursor: pointer;
  transition: var(--transition-fast); flex-shrink: 0;
}
.panel-search-btn:hover { background: var(--accent-hover); }
.panel-search-clear {
  background: none; border: none; color: var(--text-muted);
  padding: 0.45rem 0.625rem; cursor: pointer; font-size: 0.85rem;
  transition: var(--transition-fast);
}
.panel-search-clear:hover { color: var(--text-primary); }

/* ============================================================
   LOADING OVERLAY — hiện khi đang fetch IMAP
   ============================================================ */
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(15, 17, 23, 0.7);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
  gap: 1rem;
}
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  color: var(--text-secondary); font-size: 0.875rem;
  animation: pulse-text 1.5s ease-in-out infinite;
}
@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* Mail panel relative for overlay */
.wb-mail-panel { position: relative; }

/* Skeleton loading cho mail items */
.mail-skeleton {
  display: flex; align-items: center; gap: 0.875rem;
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.skeleton-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-color) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  flex-shrink: 0;
}
.skeleton-line {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-color) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* Pagination — cố định ở dưới panel */
.mail-pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.625rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  gap: 1rem; flex-wrap: wrap;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .mail-detail-subject { font-size: 1.1rem; }
  .admin-section { padding: 1rem; }
  .mail-panel-header { padding: 0.75rem 1rem; }
}

@media (max-width: 575px) {
  .mail-pagination { flex-direction: column; align-items: stretch; }
}
