:root {
  --hint-purple: #7f5af0;
  --hint-purple-2: #6246ea;
}

/* Header container: allow wrap on small screens */
.app-header .container-fluid {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap; /* allows items to move to next line on xs */
  min-height: 56px;
}

/* Reduce underline repaints on scroll + respect reduced motion */
.app-header {
  background: #fff;
  border: 0;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  position: relative;
  will-change: transform; /* tiny perf hint */
}
@media (prefers-reduced-motion: reduce) {
  .app-header::after {
    transition: none !important;
  }
}
.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: linear-gradient(90deg, var(--hint-purple), var(--hint-purple-2));
  opacity: 0.35;
}

/* Brand: prevent layout jumps and allow truncation on tiny screens */
.brand {
  gap: 0.6rem;
  text-decoration: none;
  color: #1a1a1a;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  min-width: 0;
}
.brand img.logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
}
.brand .name {
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Search: keep current look, improve focus visibility */
.search-wrap {
  max-width: 640px;
  flex: 1;
  min-width: 220px;
}
.form-control.search {
  border-radius: 999px;
  padding-left: 2.25rem;
  background: #f7f7fb;
  border: 1px solid #e6e6f2;
}
.form-control.search:focus {
  border-color: var(--hint-purple);
  box-shadow: 0 0 0 0.2rem rgba(127, 90, 240, 0.15);
}
.form-control.search:focus-visible {
  outline: none;
} /* rely on box-shadow */
.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #8a8aa0;
  pointer-events: none;
}

/* Icon buttons */
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: #f5f5ff;
  border: 1px solid #ececff;
  color: #5b5b6b;
}
.btn-icon:hover {
  color: var(--hint-purple-2);
  border-color: var(--hint-purple);
  background: #fff;
}
.btn-icon:focus-visible {
  outline: 2px solid rgba(127, 90, 240, 0.35);
  outline-offset: 2px;
}

/* Avatar */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

/* Notification dot */
.badge-dot {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--hint-purple);
  box-shadow: 0 0 0 2px #fff;
}

:root {
  --hint-purple: #7f5af0; /* accent only */
  --hint-purple-2: #6246ea; /* deeper accent */
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #111827;
  --ink-2: #6b7280;
  --accent: #0d6efd; /* bootstrap primary */
}

/* ---------- Sidebar ---------- */
.mail-sidebar {
  height: calc(100vh - 72px);
  position: sticky;
  top: 72px; /* fixed header height */
  overflow-y: auto;
  background: var(--surface);
}

.btn-compose {
  border-radius: 999px;
  padding: 0.65rem 1rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  margin-top: 0.5rem;
  background-color: var(--hint-purple);
  color: #fff;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-compose:hover {
  background-color: var(--hint-purple-2);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}
.btn-compose:focus-visible {
  outline: 2px solid rgba(127, 90, 240, 0.25);
  outline-offset: 2px;
}

/* ---------- Folder list ---------- */
.folder-list .list-group-item {
  border: 0 !important;
  border-radius: 0.5rem;
  padding: 0.5rem 0.65rem;
  margin: 0.25rem 0; /* compact, consistent */
  color: var(--ink);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  transition: background 0.15s, border-left-color 0.15s;
}
.folder-list .list-group-item .left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.folder-list .list-group-item:hover {
  background: var(--surface-2);
}

/* Active: minimal purple accent */
.folder-list .list-group-item.active {
  background: rgba(127, 90, 240, 0.08);
  border-left: 3px solid var(--hint-purple);
  border-radius: 0 0.5rem 0.5rem 0;
  font-weight: 600;
  color: var(--ink);
}

.count-pill {
  background: #e5e7eb;
  color: #374151;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ---------- Labels ---------- */
.labels-title {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-size: 0.75rem;
  margin: 1rem 0.25rem 0.5rem;
}
.label-list .list-group-item {
  border: 0 !important;
  background: transparent;
  padding: 0.5rem 0.25rem;
}
.label-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.5rem;
}
.label-work {
  background: #3b82f6;
} /* blue    */
.label-personal {
  background: #10b981;
} /* green   */
.label-finance {
  background: #f59e0b;
} /* amber   */
.label-urgent {
  background: #ef4444;
} /* red     */
.label-travel {
  background: #8b5cf6;
} /* violet  */

/* ---------- Inbox toolbar z-layer ---------- */
.inbox .inbox-toolbar {
  z-index: 3;
}

/* ---------- Email list grid ---------- */
.email-list {
  /* wrapper; keep if you later add sticky headers */
}

.email-row {
  display: grid;
  grid-template-columns:
    28px /* checkbox */
    28px /* star     */
    36px /* avatar   */
    minmax(140px, 18ch) /* from     */
    1fr /* subject  */
    minmax(96px, 140px) /* meta     */
    0px; /* actions (space, shown on hover elsewhere) */
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f1f3f5;
  cursor: pointer;
}

/* ---------- Email row polish ---------- */

/* keep your last-child + hover */
.email-row:last-child {
  border-bottom: 0;
}

/* only apply hover effects on devices that actually have hover */
@media (hover: hover) {
  .email-row:hover {
    background: #f7f8fa;
  }
  .email-row .actions {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
  }
  .email-row:hover .actions {
    opacity: 1;
    pointer-events: auto;
  }
  .email-row:hover .meta {
    display: none;
  }
}

/* on touch devices, always show meta (no disappearing) and keep actions inline if you want */
@media (hover: none) {
  .email-row .actions {
    opacity: 1;
    pointer-events: auto;
  }
  .email-row .meta {
    display: flex;
  }
}

/* cells */
.email-row .cell {
  min-width: 0;
} /* allow truncation */
.email-row .avatar img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.email-row .from,
.email-row .subject {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.email-row .snippet {
  color: #6b7280;
}
.email-row.unread .from,
.email-row.unread .subject {
  font-weight: 600;
}

/* right-side meta/actions */
.email-row .meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-self: end;
}
.email-row .actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  justify-self: end;
}

/* bigger tap target for star on mobile */
.email-row .star {
  color: #b0b3b8;
}
.email-row .star .bi-star-fill {
  color: #f6c34a;
}

/* Two panes toggling */
.mail-pane .pane-list {
  display: block;
}
.mail-pane .pane-message {
  display: block;
}

.mail-pane .pane-message.d-none {
  display: none !important;
}

/* Subject & label alignment */
.message-header h5 {
  line-height: 1.2;
} /* Message view header: sticky + tidy */
.message-header {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* Let header controls wrap nicely on small screens */
.message-header .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Soft purple label (matches your theme vars if present) */
.badge-soft-purple {
  background: #f5f2ff;
  color: #5a36d6;
  border: 1px solid #e6e0ff;
}

/* Reply editor placeholder when empty */
#repEditor:empty:before {
  content: "Write your reply…";
  color: #9aa0a6;
}

/* Keep toolbar buttons compact and consistent */
#repToolbar .btn {
  --bs-btn-padding-y: 0.25rem;
  --bs-btn-padding-x: 0.5rem;
}

/* Attachments look */
.attachment-item {
  border: 1px solid #ece9ff;
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.attachment-item .meta {
  color: #6b7280;
  font-size: 0.85rem;
}

/* Reply toolbar active states (soft purple) */
#replyToolbar .btn.active {
  background: var(--hint-purple);
  border-color: var(--hint-purple);
  color: #fff;
}

/* Make message header stick below your fixed app header */
.mail-section .message-header {
  top: var(--header-h);
}

/* ===== Message View — Pro Styling (soft purple accent) ===== */
:root {
  --ink: #111827;
  --ink-2: #6b7280;
  --soft-surface: #ffffff;
  --soft-bg: #f8f9fb;
  --soft-purple: #f5f2ff;
  --line: #eef0f4;
  --accent: #7f5af0; /* used sparingly */
  --header-h: 72px; /* keep in sync with your app header */
}

/* Keep sticky header below app header */
#messageView .position-sticky {
  top: var(--header-h);
}

/* Top bar */
#messageView .bg-white {
  background: var(--soft-surface) !important;
}
#messageView .border-bottom {
  border-bottom: 1px solid var(--line) !important;
}
#messageView h5#mvSubject {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}
#messageView #mvLabel {
  background: var(--soft-purple) !important;
  color: #4b35c0 !important;
  border: 1px solid #e7e2ff !important;
  font-weight: 600;
}
#messageView .btn.btn-light {
  border: 1px solid #eaecf0;
  background: #fff;
}
#messageView .btn.btn-light:hover {
  background: #f6f7fb;
  border-color: #e5e7eb;
}

/* Container spacing */
#messageView .p-3 {
  padding: 1rem !important;
}
#messageView .card {
  border: 1px solid #eceef4;
  border-radius: 14px;
  overflow: hidden;
}
#messageView .card-body {
  padding: 1rem 1rem 0.75rem 1rem;
}

/* Sender block */
#messageView #mvAvatar {
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
#messageView #mvFromName {
  color: var(--ink);
}
#messageView #mvFromEmail,
#messageView #mvDate {
  color: var(--ink-2);
}

/* Message HTML content */
#mHtml {
  color: var(--ink);
  line-height: 1.55;
  font-size: 0.975rem;
}
#mHtml p {
  margin-bottom: 0.9rem;
}
#mHtml ul,
#mHtml ol {
  margin: 0.5rem 0 0.9rem 0;
  padding-left: 1.2rem;
}
#mHtml a {
  color: var(--accent);
  text-decoration: underline;
}

/* Attachments */
#mvAttWrap .fw-semibold {
  color: var(--ink);
}
#mvAttList .attachment-item {
  border: 1px solid #ece9ff;
  background: #fff;
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
#mvAttList .attachment-item:hover {
  background: #fafaff;
  border-color: #e3ddff;
  box-shadow: 0 4px 14px rgba(80, 56, 200, 0.06);
}

/* Divider */
#messageView hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 1rem 0;
}

/* Reply toolbar and editor */
#repToolbar .btn {
  border-radius: 8px;
  border-color: #e7e9f0;
  background: #fff;
}
#repToolbar .btn:hover {
  background: #f7f8fb;
  border-color: #e2e6ee;
}
#repToolbar .btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
#repEditor {
  min-height: 130px;
  border-radius: 10px;
  border: 1px solid #e5e7ef;
  background: #fff;
}
#repEditor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.18rem rgba(127, 90, 240, 0.12);
  outline: none;
}
#repEditor:empty:before {
  content: "Write your reply…";
  color: #9aa0a6;
}

/* Buttons */
#messageView #repSend {
  padding-inline: 0.9rem;
  border-radius: 10px;
  background-color: #7f5af0 !important;
}
#messageView #repSend i {
  margin-right: 0.35rem;
}

/* Small details */
#messageView .small.text-muted {
  color: var(--ink-2) !important;
}
#messageView .btn-group .btn {
  padding: 0.25rem 0.5rem;
}
.brand .name {
  white-space: nowrap;
}
.dropdown-menu {
  max-width: 92vw;
  width: max-content;
}
.label-list .list-group-item {
  border: 0;
  padding: 0.4rem 0.25rem;
  background: transparent;
}

#mailSidebarOffcanvas .offcanvas-body {
  overflow: auto;
}
#mailSidebarOffcanvas .btn-compose {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
/* Bottom-right floating compose window */
.pp-compose .modal-dialog {
  position: fixed;
  right: 16px;
  bottom: 16px;
  margin: 0;
  max-width: 520px;
  width: min(520px, 100vw - 24px);
  pointer-events: auto;
}
.pp-send {
  background-color: #7f5af0;
  color: #fff;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.pp-send:hover {
  background-color: #6246ea;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}
/* Make the shell tidy */
.pp-compose .modal-content {
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

/* Header / body / footer spacing */
.pp-compose .pp-header {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f0f1f5;
}
.pp-compose .pp-title {
  font-weight: 600;
}
.pp-compose .pp-body {
  padding: 0.75rem;
}
.pp-compose .pp-footer {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #f0f1f5;
}

/* Editor size */
.pp-compose .pp-editor {
  min-height: 160px;
  max-height: 48vh;
  overflow: auto;
}

/* Gentle purple hint */
.pp-compose .pp-input:focus,
.pp-compose .pp-editor:focus {
  box-shadow: 0 0 0 0.2rem rgba(127, 90, 240, 0.12);
  border-color: #e6e0ff;
}

/* Toolbar buttons: clear, compact, with active state */
.pp-compose #pp-toolbar .btn {
  border-color: #e6e6f2;
}
.pp-compose #pp-toolbar .btn.active {
  background: #f5f2ff;
  border-color: #e6e0ff;
}
/* never wrap the little bits on the right */
.email-row .meta .time,
.email-row .meta .status {
  white-space: nowrap;
}

/* subject should be the one that flexes; snippet is dimmer */
.email-row .subject {
  min-width: 0;
} /* ensures ellipsis works */
.email-row .subject .snippet {
  color: #6b7280;
}

/* never wrap the little bits on the right */
.email-row .meta .time,
.email-row .meta .status {
  white-space: nowrap;
}

/* subject should be the one that flexes; snippet is dimmer */
.email-row .subject {
  min-width: 0;
} /* ensures ellipsis works */
.email-row .subject .snippet {
  color: #6b7280;
}

/* === Responsive tidy for email rows & header === */
/* === Responsive tidy for email rows & header === */

/* xs: ultra small phones */
@media (max-width: 360px) {
  .count-pill {
    display: none;
  }
  .brand .name {
    max-width: 120px;
  } /* avoid overlap */
}

/* slightly small phones: logo only */
@media (max-width: 400px) {
  .brand .name {
    display: none;
  }
}

/* small phones: compose offset tweak */
@media (max-width: 480px) {
  .pp-compose .modal-dialog {
    right: 8px;
    bottom: 8px;
  }
}

/* <= 576px: compact row, keep avatar, hide sender name + snippet */
@media (max-width: 576px) {
  /* Ensure cells can shrink without overflowing */
  .email-row .cell,
  .email-row .subject,
  .email-row .snippet {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Make subject and snippet share space nicely */
  .email-row .subject {
    font-weight: 500;
  }
  .email-row .snippet {
    color: #6b7280;
    font-size: 0.85rem;
  }
}
/* <= 768px: medium phones & small tablets */
@media (max-width: 768px) {
  .search-wrap {
    display: none;
  } /* big search off */
  .app-header .container-fluid {
    gap: 0.4rem;
  }

  #messageView h5#mvSubject {
    font-size: 1rem;
  }
  #messageView .card-body {
    padding: 0.85rem;
  }

  .email-row {
    grid-template-columns:
      24px /* checkbox */
      24px /* star     */
      28px /* avatar   */
      minmax(0, 12ch) /* from (short) */
      1fr /* subject */
      minmax(72px, 100px) /* meta    */
      0px;
  }
  .email-row .subject .snippet {
    display: none;
  } /* still hide snippet here */
  .email-row .from {
    max-width: 12ch;
  } /* prevent overflow */
  .email-row .meta {
    white-space: nowrap;
  }
}

/* <= 992px: tablets / small laptops */
@media (max-width: 992px) {
  .email-row {
    grid-template-columns:
      24px /* checkbox */
      24px /* star     */
      32px /* avatar   */
      minmax(120px, 16ch) /* from     */
      1fr /* subject  */
      minmax(84px, 120px) /* meta     */
      0px;
    gap: 0.4rem;
    padding: 0.45rem 0.6rem;
  }
  .email-row .subject .snippet {
    display: inline;
  } /* okay to show again */
  .email-row .meta {
    white-space: nowrap;
  }
}

/* >= 768px: keep search flexible when shown */
@media (min-width: 768px) {
  .search-wrap {
    flex: 1;
  }
}
