/* Mail list fixes: aligned icons in the bulk-action buttons and stable text inside message rows.
   Loaded last on the mail page (index.html). */

/* ---------- Bulk actions (read, unread, star, restore, trash) and refresh: the icon sits exactly in the middle ---------- */
html :is(.bulk-action-button, .refresh-action-button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  line-height: 1;
}
html .bulk-action-button > b,
html .refresh-action-button > b {
  display: grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  place-items: center;
  font-size: 0;
  line-height: 0;
}
html :is(.bulk-action-button, .refresh-action-button) > b > :is(svg, img, i) {
  display: block;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  transform: none !important;
}
@media (max-width: 1250px) {
  /* Phones and tablets: square icon-only buttons, one size for all of them */
  html .bulk-actions { gap: 6px; }
  html .bulk-actions > .bulk-action-button,
  html .refresh-action-button {
    flex: 0 0 38px;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    gap: 0;
  }
}

/* ---------- Message rows: the text never jumps (fixed line boxes, no layout shift from badges or fallback fonts) ---------- */
html .message-row {
  contain: layout style;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html .message-open {
  align-content: center;
  font-synthesis: none;
}
html .message-open :is(strong, .row-subject, .row-snippet, time) {
  line-height: 18px;
}
html .message-open .thread-count {
  height: 18px;
  min-height: 18px;
  line-height: 18px;
  vertical-align: baseline;
}
html .message-row :is(.message-open, .star-button):is(:hover, :focus, :active) {
  transform: none !important;
}
@media (hover: none), (pointer: coarse) {
  /* A tap leaves :hover stuck on the row: it must not change the geometry */
  html .message-row:hover { position: relative; z-index: auto; }
}

/* ---------- Image preview: photo, then its info (format, size, resolution), then the buttons, all visible at once ---------- */
html .image-preview-dialog[open] { display: flex; flex-direction: column; }
html .image-preview-stage { flex: 1 1 auto; min-height: 200px; max-height: calc(100dvh - 240px); }
html .image-preview-stage img { max-height: calc(100dvh - 280px); }
html .image-preview-info {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px 22px;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
html .image-preview-info-item { display: inline-flex; align-items: baseline; gap: 7px; min-width: 0; font-size: 13px; }
html .image-preview-info-item small { color: var(--muted); font-size: 12px; font-weight: 700; }
html .image-preview-info-item b { min-width: 0; max-width: 260px; overflow: hidden; color: var(--text); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
html .image-preview-actions { flex: 0 0 auto; border-top: 1px solid var(--line); }
html .image-preview-actions button:disabled { opacity: 1; cursor: default; }
@media (max-width: 640px) {
  html .image-preview-actions { justify-content: stretch; }
  html .image-preview-actions button { flex: 1 1 100%; }
}

/* ---------- Plan badge in the profile and the "subscription ends soon" card ---------- */
html .account-plan-badge {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  width: max-content;
  margin-top: 6px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: 800 11px/1.2 Onest, Inter;
  letter-spacing: .06em;
  text-decoration: none;
}
html .account-name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
html .account-name-row #popover-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html .account-name-row .account-plan-badge { margin-top: 0; flex: 0 0 auto; position: relative; overflow: hidden; isolation: isolate; }
html .account-plan-badge:hover { filter: brightness(1.12); }

/* Free: plain quiet pill */
html .account-plan-badge[data-status="free"] { color: var(--muted, var(--text)); }

/* Pro: blue double border */
html .account-plan-badge[data-status="pro"] {
  color: #cfe3ff;
  background: linear-gradient(135deg, #12274a, #0c1a33);
  border: 1px solid #4d8dff;
  box-shadow: 0 0 0 2px #0c1a33, 0 0 0 3px #4d8dff66, 0 0 12px #4d8dff55;
}

/* Max: violet gradient frame with a soft glow */
html .account-plan-badge[data-status="max"] {
  color: #f0e1ff;
  border: 1px solid transparent;
  background: linear-gradient(#1c1233, #1c1233) padding-box, linear-gradient(135deg, #a855f7, #ec4899, #a855f7) border-box;
  box-shadow: 0 0 14px #a855f777;
  text-shadow: 0 0 8px #c084fcaa;
}

/* Ultra: animated gold shimmer */
html .account-plan-badge[data-status="ultra"] {
  color: #2b1d00;
  border: 1px solid #ffd66b;
  background: linear-gradient(110deg, #b8860b 0%, #ffe28a 35%, #fff4c2 50%, #ffcf4a 65%, #b8860b 100%);
  background-size: 220% 100%;
  box-shadow: 0 0 0 2px #2b1d00, 0 0 0 3px #ffd66b88, 0 0 16px #ffc83d88;
  animation: plan-shimmer 3.2s linear infinite;
}

/* PREMIUM: rainbow rotating frame, crown-like glow */
html .account-plan-badge[data-status="premium"] {
  color: #fff;
  border: 1.5px solid transparent;
  background: linear-gradient(#0b0b12, #0b0b12) padding-box, linear-gradient(90deg, #ff4d6d, #ffb703, #3ddc97, #4d8dff, #c77dff, #ff4d6d) border-box;
  background-size: 100% 100%, 300% 100%;
  box-shadow: 0 0 16px #c77dff77, 0 0 28px #4d8dff44;
  text-shadow: 0 0 8px #ffffffaa;
  animation: plan-rainbow 4s linear infinite;
}
@keyframes plan-shimmer { to { background-position: -220% 0; } }
@keyframes plan-rainbow { to { background-position: 0 0, 300% 0; } }
@media (prefers-reduced-motion: reduce) {
  html .account-plan-badge[data-status="ultra"], html .account-plan-badge[data-status="premium"] { animation: none; }
}

html .subscription-reminder {
  position: fixed;
  top: 78px;
  right: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(380px, calc(100vw - 32px));
  padding: 12px 12px 12px 16px;
  border: 1px solid var(--vxp-highlight, var(--accent));
  border-radius: 12px;
  background: var(--surface-2, #1b1b1f);
  color: var(--text);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .45), 0 0 18px var(--vxp-glow, transparent);
  animation: sub-reminder-in .4s cubic-bezier(.16, 1, .3, 1) both;
}
html .subscription-reminder.is-leaving { animation: sub-reminder-out .26s ease-in both; }
html .subscription-reminder > div { display: grid; flex: 1 1 auto; gap: 3px; min-width: 0; }
html .subscription-reminder strong { font: 800 14px/1.25 Onest, Inter; }
html .subscription-reminder span { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
html .subscription-reminder-action {
  flex: 0 0 auto;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-3, #26262b);
  color: var(--text);
  font: 750 13px/1 Onest, Inter;
  text-decoration: none;
}
html .subscription-reminder-action:hover { border-color: var(--vxp-highlight, var(--accent)); }
html .subscription-reminder-close { flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
html .subscription-reminder-close:hover { color: var(--text); background: var(--surface-3, #26262b); }
html .subscription-reminder-close .lucide { width: 16px; height: 16px; }
@keyframes sub-reminder-in { from { opacity: 0; transform: translateX(40px); } }
@keyframes sub-reminder-out { to { opacity: 0; transform: translateX(40px); } }
@media (max-width: 760px) { html .subscription-reminder { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; } }
@media (prefers-reduced-motion: reduce) { html .subscription-reminder, html .subscription-reminder.is-leaving { animation: none; } }