/* ==========================================================================
   Message view — shared by the public view (/view/{hash_id}, view.blade.php)
   and the private mailbox inline detail (#pm-msg-detail, private-mail.blade.php).
   MESSAGE_VIEW_V1 — loaded after style.css; overrides below use a higher
   specificity than the theme rules so order does not matter.
   Palette follows the site: primary var(--primary_color) (#1570e8 live),
   radius 12px, clean type. One memorable element: the OTP pill / magic-link
   card. Everything else stays quiet and matches the existing .viewbox.
   ========================================================================== */

/* Subject line inside the viewbox header (public + private). */
.viewbox-header .viewbox-subject {
    display: block;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Private head: the sender line was bold; with the subject above it the
   sender goes regular so the subject is the one bold line — same as public. */
.viewbox-header .pm-msg-head-info #pm-msg-from {
    font-weight: 400;
}
.viewbox-header .pm-msg-head-info #pm-msg-subject {
    display: block;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* MESSAGE_VIEW_V3: Bootstrap .col is flex:1 0 0% with NO min-width:0, so
   the nowrap subject forces the middle column wide and the header row wraps
   — the date / heart / delete buttons drop onto their own lines at the left.
   Let the middle column shrink so the subject truncates with ellipsis
   instead; the row stays one line (back left, subject middle, actions right).
   Scoped to the header's direct .col child only. */
.viewbox-header .row > .col {
    min-width: 0;
}

/* MESSAGE_VIEW_V4-RESTORE (round 6): the v4 one-row header rules hid
   the header content in real browsers (only the back arrow painted),
   although a local rig built from the same bytes rendered one row.
   Removed again: the header is back to the round-3 behaviour — the
   last browser-verified all-visible state (stacked). Do NOT re-add
   the one-row rules without a browser-side diagnosis. */

/* --- Reference header layout (user screenshot) — MESSAGE_VIEW_V5: back
   far left; subject / sender name / sender email stacked in the middle;
   date top-right with the action buttons below it at the right. Custom
   flex, NOT Bootstrap .row/.col: the round-4 one-row rules on .row/.col
   hid the header content in real browsers, so the header no longer uses
   them at all. Middle uses flex-basis auto (never 0) — the proven
   private-header pattern — so it cannot collapse. The favourite heart
   stays: the reference shows no heart, but it is a working feature, so
   it sits next to the trash in .vh-actions (remove it only if asked). --- */
.viewbox-header .vh-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}
.viewbox-header .vh-back {
    flex: 0 0 auto;
}
.viewbox-header .vh-mid {
    flex: 1 1 auto;
    min-width: 0;
}
.viewbox-header .vh-right {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}
.viewbox-header .vh-date {
    white-space: nowrap;
}
.viewbox-header .vh-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Attachments: the theme rule has a black top border (#222, leftover).
   Light grey, same as the bottom border. */
.viewbox .viewbox-attachments {
    border-top: 1px solid #e5e7eb;
}

/* --- OTP pill + magic-link card (moved here from the inline <style> in
   partials/plugins.blade.php so both message surfaces share one design). --- */
.viewbox-body .otp-pill {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    background: #e8f7ee;
    border: 1px solid #22c55e;
    border-radius: 12px;
    padding: 12px 16px;
    margin: 16px 25px;
}
.viewbox-body .otp-pill-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #15803d;
}
.viewbox-body .otp-pill-code {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: .12em;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #14532d;
}
.viewbox-body .otp-pill-copy {
    background: var(--primary_color, #1570e8);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 8px 14px;
    font-weight: 600;
    cursor: pointer;
}
.viewbox-body .otp-pill-copy:hover {
    background: #0f5cc4;
}
.viewbox-body .otp-pill-copy:focus-visible {
    outline: 2px solid #0f5cc4;
    outline-offset: 2px;
}
.viewbox-body .otp-pill-copied {
    font-size: 13px;
    font-weight: 600;
    color: #15803d;
}
/* Magic-link card: label above the link so long URLs wrap cleanly below
   it instead of squeezing beside it. */
.viewbox-body .otp-magic-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    background: #eff6ff;
    border: 1px solid #1570e8;
    border-radius: 12px;
    padding: 12px 16px;
    margin: 0 25px 12px;
}
.viewbox-body .otp-magic-card:first-child {
    margin-top: 16px;
}
.viewbox-body .otp-magic-label {
    font-size: 13px;
    font-weight: 700;
    color: #1e40af;
}
.viewbox-body .otp-magic-link {
    font-weight: 600;
    color: #1570e8;
    word-break: break-all;
}

/* --- Shared loading state (same spinner the private view already had). --- */
.viewbox-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: 3rem 1rem;
    color: #6b7280;
}
.viewbox-spinner {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid #e5e7eb;
    border-top-color: var(--primary_color, #1570e8);
    animation: mv-spin .8s linear infinite;
}
@keyframes mv-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .viewbox-spinner { animation: none; }
}

@media (max-width: 575px) {
    .viewbox-body .otp-pill-code { font-size: 20px; }
    .viewbox-body .otp-pill,
    .viewbox-body .otp-magic-card { margin-left: 16px; margin-right: 16px; }
    /* Reference header on phones: hide the date like the private header
       already does (.pm-msg-head-date), so the subject keeps room. */
    .viewbox-header .vh-date { display: none; }
}
