/**
 * BYOD Messages — Frontend Styles
 * Inherits the full dark-navy palette from domain-selector.css.
 * Uses solid hex values instead of rgba transparency so the UI
 * renders correctly whether the page background is light or dark.
 *
 * Palette contract (matches domain-selector.css):
 *   --bg-deep    : #0F172A  darker navy  — deepest surfaces
 *   --bg-mid     : #1E293B  dark navy    — cards / panels
 *   --border     : #334155  slate border
 *   --text-hi    : #F1F5F9  almost-white — primary labels
 *   --text-lo    : #94A3B8  light-gray   — secondary / muted
 *   --accent     : #3B82F6  blue
 *   --accent-glow: rgba(59,130,246,0.20) — focus ring
 *
 * @package TempMailsMultiDomain
 * @since 1.0.0
 */

/* =============================================================================
   WRAPPER — give the whole block a solid dark canvas
   ============================================================================= */

#tmcd-byod-messages-wrapper,
.tmcd-byod-messages-wrapper {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #1E293B;
    border-radius: 16px;
    padding: 24px;
    box-sizing: border-box;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.30);
}

/* =============================================================================
   DOMAIN ROW — inherits .tmcd-domain-selector-wrapper from domain-selector.css
   no extra overrides needed; gap above handles spacing
   ============================================================================= */

.tmcd-bm-domain-row {
    width: 100%;
}

/* =============================================================================
   TOOLBAR — search + filter + refresh
   ============================================================================= */

.tmcd-bm-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Search wrapper ── */
.tmcd-bm-search-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
}

.tmcd-bm-search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #94A3B8;
    pointer-events: none;
    user-select: none;
    line-height: 1;
}

/* Solid dark background — no transparent artifacts */
.tmcd-bm-search-input {
    width: 100%;
    padding: 11px 38px 11px 42px;
    border-radius: 10px;
    border: 2px solid #334155;
    background: #0F172A;
    color: #F1F5F9;
    font-size: 14px;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    -webkit-appearance: none;
}

.tmcd-bm-search-input::placeholder {
    color: #64748B;
}

.tmcd-bm-search-input:hover {
    border-color: #3B82F6;
}

.tmcd-bm-search-input:focus {
    border-color: #3B82F6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.20);
}

/* Clear button */
.tmcd-bm-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px;
    color: #64748B;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
}

.tmcd-bm-search-clear:hover {
    color: #F1F5F9;
    background: #334155;
}

.tmcd-bm-search-clear .material-symbols-outlined {
    font-size: 16px;
    display: block;
}

/* ── Filter dropdown ── */
.tmcd-bm-filter-wrapper {
    flex-shrink: 0;
}

.tmcd-bm-filter-select {
    height: 44px;
    padding: 0 36px 0 14px;
    border-radius: 10px;
    border: 2px solid #334155;
    background-color: #0F172A;
    /* Custom arrow that's always visible on dark bg */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394A3B8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px;
    color: #F1F5F9;           /* ← visible white label */
    font-size: 14px;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.tmcd-bm-filter-select:hover {
    border-color: #3B82F6;
}

.tmcd-bm-filter-select:focus {
    border-color: #3B82F6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.20);
}

/* Dropdown options — must specify bg so browser paints them dark */
.tmcd-bm-filter-select option {
    background-color: #0F172A;
    color: #F1F5F9;
}

/* ── Refresh button ─
   Inherits .tempmails-btn from Core; these just tweak size/shape  */
.tmcd-bm-refresh-btn {
    height: 44px;
    width: 44px;
    padding: 0;
    flex-shrink: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tmcd-bm-refresh-btn .material-symbols-outlined {
    font-size: 20px;
}

/* =============================================================================
   STATS BAR
   Reuses .tempmails-stats from Core with dark overrides from domain-selector.css
   ============================================================================= */

.tmcd-bm-stats.tempmails-stats {
    background: #0F172A !important;
    border: 1px solid #334155 !important;
    border-radius: 12px !important;
    padding: 14px 20px !important;
    margin-bottom: 0 !important;
}

.tmcd-bm-stats .tempmails-stat-label {
    color: #94A3B8 !important;
}

.tmcd-bm-stats .tempmails-stat-value {
    color: #F1F5F9 !important;
}

.tmcd-bm-stats .tempmails-stat-value.tempmails-unread {
    color: #3B82F6 !important;
}

/* =============================================================================
   SELECT PROMPT
   Shown before any domain is chosen
   ============================================================================= */

#tmcd-bm-select-prompt {
    text-align: center;
    padding: 48px 24px;
    color: #64748B;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
}

/* =============================================================================
   LOADING SPINNER
   ============================================================================= */

#tmcd-bm-loading.tempmails-loading {
    background: #0F172A !important;
    border: 1px solid #334155 !important;
    border-radius: 12px !important;
    color: #94A3B8 !important;
}

/* =============================================================================
   MESSAGES CONTAINER + LIST
   ============================================================================= */

#tmcd-bm-messages-container {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #334155;
    background: #0F172A;
}

#tmcd-bm-messages-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── Individual message row ── */
.tmcd-bm-message-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    cursor: pointer;
    background: #0F172A;
    border-bottom: 1px solid #1E293B;
    transition: background 0.15s ease;
}

.tmcd-bm-message-row:last-child {
    border-bottom: none;
}

.tmcd-bm-message-row:hover {
    background: #1E293B;
}

/* Unread row */
.tmcd-bm-message-row.tmcd-bm-unread {
    background: #1E3A8A;
    border-bottom-color: rgba(59, 130, 246, 0.15);
}

.tmcd-bm-message-row.tmcd-bm-unread:hover {
    background: #1E40AF;
}

/* ── Unread indicator dot ── */
.tmcd-bm-row-indicator {
    flex-shrink: 0;
    width: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tmcd-bm-unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3B82F6;
    flex-shrink: 0;
}

/* ── Main content column ── */
.tmcd-bm-row-main {
    flex: 1;
    min-width: 0;   /* required for text-overflow to work */
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tmcd-bm-row-from {
    font-size: 13px;
    font-weight: 600;
    color: #94A3B8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

.tmcd-bm-message-row.tmcd-bm-unread .tmcd-bm-row-from {
    color: #93C5FD;
}

.tmcd-bm-row-subject {
    font-size: 14px;
    font-weight: 500;
    color: #CBD5E1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

.tmcd-bm-message-row.tmcd-bm-unread .tmcd-bm-row-subject {
    color: #F1F5F9;
    font-weight: 700;
}

.tmcd-bm-row-to {
    font-size: 12px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Meta column — date + delete ── */
.tmcd-bm-row-meta {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.tmcd-bm-row-date {
    font-size: 12px;
    color: #475569;
    white-space: nowrap;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Delete button — hidden until row hovered */
.tmcd-bm-delete-btn {
    opacity: 0;
    transition: opacity 0.15s ease;
    padding: 4px 8px;
    min-height: unset;
    height: auto;
    font-size: 12px;
    background: transparent !important;
    border: 1px solid #334155 !important;
    color: #EF4444 !important;
    border-radius: 6px !important;
    box-shadow: none !important;
}

.tmcd-bm-delete-btn:hover {
    background: rgba(239, 68, 68, 0.12) !important;
    border-color: #EF4444 !important;
    transform: none !important;
}

.tmcd-bm-delete-btn .material-symbols-outlined {
    font-size: 15px;
}

.tmcd-bm-message-row:hover .tmcd-bm-delete-btn {
    opacity: 1;
}

/* Always show on touch / disabled state */
.tmcd-bm-delete-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* =============================================================================
   EMPTY STATE
   ============================================================================= */

#tmcd-bm-empty-state {
    text-align: center;
    padding: 56px 24px;
    background: #0F172A;
    border-radius: 12px;
    border: 1px solid #334155;
}

#tmcd-bm-empty-state .material-symbols-outlined {
    font-size: 56px;
    color: #334155;
    display: block;
    margin-bottom: 16px;
}

#tmcd-bm-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: #94A3B8;
    margin: 0 0 8px 0;
    font-family: Poppins, -apple-system, sans-serif;
    display: block;
}

#tmcd-bm-empty-hint {
    font-size: 13px;
    color: #475569;
    display: block;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* =============================================================================
   LOAD MORE BUTTON
   ============================================================================= */

.tmcd-bm-load-more-wrapper {
    display: flex;
    justify-content: center;
    padding: 14px 0 2px;
}

.tmcd-bm-load-more-wrapper .tempmails-btn {
    min-width: 160px;
    background: #1E293B !important;
    border: 1px solid #334155 !important;
    color: #94A3B8 !important;
    box-shadow: none !important;
}

.tmcd-bm-load-more-wrapper .tempmails-btn:hover {
    border-color: #3B82F6 !important;
    color: #3B82F6 !important;
    transform: none !important;
}

//* =============================================================================
   MODAL — dark overlay + dark card
   Extends .tempmails-modal from Core + domain-selector.css overrides
   ============================================================================= */

#tmcd-bm-modal.tempmails-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999999;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

#tmcd-bm-modal.tempmails-modal[style*="display: block"],
#tmcd-bm-modal.tempmails-modal[style*="display:block"] {
    display: flex !important;
}

/* Overlay */
#tmcd-bm-modal .tempmails-modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.85) !important;
    backdrop-filter: blur(6px) !important;
    z-index: 1;
}

/* Card */
#tmcd-bm-modal .tempmails-modal-content {
    position: relative;
    background: #0F172A !important;
    border: 1px solid #334155 !important;
    border-radius: 16px !important;
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.50) !important;
    z-index: 2;
    animation: tmcdBmModalIn 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    color: #F1F5F9 !important;
}

@keyframes tmcdBmModalIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0);    }
}

/* Header */
#tmcd-bm-modal .tempmails-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 26px;
    border-bottom: 1px solid #1E293B !important;
}

/* FIX: Subject heading uses Poppins (heading font) */
#tmcd-bm-modal .tempmails-modal-header h3,
#tmcd-bm-modal-subject {
    font-family: Poppins, -apple-system, sans-serif;
    font-size: 17px;
    font-weight: 600;
    color: #F1F5F9 !important;
    margin: 0;
    flex: 1;
    line-height: 1.4;
}

/* Close button */
#tmcd-bm-modal-close {
    background: #1E293B !important;
    border: none;
    cursor: pointer;
    padding: 7px;
    border-radius: 8px;
    color: #94A3B8 !important;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#tmcd-bm-modal-close:hover {
    background: rgba(239, 68, 68, 0.12) !important;
    color: #EF4444 !important;
}

#tmcd-bm-modal-close .material-symbols-outlined {
    font-size: 22px;
}

/* Meta strip */
.tmcd-bm-modal-meta {
    padding: 14px 26px;
    background: #1E293B !important;
    border-bottom: 1px solid #334155;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

.tmcd-bm-modal-meta-row {
    display: flex;
    gap: 10px;
}

.tmcd-bm-modal-meta-row strong {
    color: #64748B;
    font-weight: 600;
    min-width: 48px;
    flex-shrink: 0;
}

.tmcd-bm-modal-meta-row span {
    color: #CBD5E1;
}

/*
 * FIX: Body area — scoped under #tmcd-bm-modal for ID-level specificity so
 * WordPress theme rules (which commonly use class-only selectors) cannot win.
 * background-color is declared separately alongside background because some
 * themes override one property but not the other.
 * Inter is the body font per product spec.
 */
#tmcd-bm-modal .tmcd-bm-modal-body,
#tmcd-bm-modal #tmcd-bm-modal-content,
#tmcd-bm-modal .tempmails-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 26px;
    background: #0F172A !important;
    background-color: #0F172A !important;
    color: #CBD5E1 !important;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

/*
 * FIX: <pre> and <code> inside every possible parent chain within the modal.
 * WordPress themes commonly force  pre { background: #fff !important }
 * using compound class selectors. Repeating the parent chain at each level
 * gives us specificity (2,0,1) or higher which beats all known theme rules.
 * Inter replaces monospace — matches body font spec.
 */
#tmcd-bm-modal .tmcd-bm-modal-body pre,
#tmcd-bm-modal .tmcd-bm-modal-body code,
#tmcd-bm-modal .tempmails-modal-body pre,
#tmcd-bm-modal .tempmails-modal-body code,
#tmcd-bm-modal #tmcd-bm-modal-content pre,
#tmcd-bm-modal #tmcd-bm-modal-content code,
#tmcd-bm-modal pre,
#tmcd-bm-modal code {
    background: #1E293B !important;
    background-color: #1E293B !important;
    color: #CBD5E1 !important;
    border: 1px solid #334155 !important;
    box-shadow: none !important;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif !important;
}

/*
 * HTML body — rendered natively as a <div> (no iframe).
 * All parent-page CSS inherits correctly: dark bg, white text, Inter font.
 * overflow-y + max-height keeps long emails scrollable inside the modal.
 */
#tmcd-bm-modal .tmcd-bm-body-html,
.tmcd-bm-body-html {
    width: 100%;
    min-height: 120px;
    max-height: 56vh;
    overflow-y: auto;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 16px;
    background: #0F172A !important;
    background-color: #0F172A !important;
    color: #CBD5E1 !important;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
    box-sizing: border-box;
}

/*
 * Suppress any inline colors injected by the email HTML itself.
 * Targets <p>, <span>, <td>, <div> that carry style="color:#000" etc.
 * Uses !important + ID scope to beat both theme CSS and inline styles.
 */
#tmcd-bm-modal .tmcd-bm-body-html *:not(a) {
    color: #CBD5E1 !important;
    background: transparent !important;
    background-color: transparent !important;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif !important;
}

/* Keep links readable */
#tmcd-bm-modal .tmcd-bm-body-html a {
    color: #3B82F6 !important;
    text-decoration: underline;
}

/* Keep images from overflowing */
#tmcd-bm-modal .tmcd-bm-body-html img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/*
 * FIX: Plain-text body rendered as <pre class="tmcd-bm-body-text">.
 * Selector expanded with ID+class chain for maximum specificity.
 * Font changed from monospace → Inter per body font spec.
 * background-color added alongside background.
 */
#tmcd-bm-modal .tmcd-bm-body-text,
#tmcd-bm-modal pre.tmcd-bm-body-text,
.tmcd-bm-body-text {
    margin: 0;
    padding: 16px;
    font-size: 14px;
    line-height: 1.7;
    color: #CBD5E1 !important;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif !important;
    background: #1E293B !important;
    background-color: #1E293B !important;
    border-radius: 8px;
    border: 1px solid #334155 !important;
    max-height: 56vh;
    overflow-y: auto;
}

/* Footer */
.tmcd-bm-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 18px 26px;
    border-top: 1px solid #1E293B;
    background: #0F172A;
}

/* Delete button in modal footer */
#tmcd-bm-modal-delete {
    background: rgba(239, 68, 68, 0.10) !important;
    border: 1px solid #EF4444 !important;
    color: #EF4444 !important;
    box-shadow: none !important;
}

#tmcd-bm-modal-delete:hover {
    background: rgba(239, 68, 68, 0.22) !important;
    transform: none !important;
}

/* =============================================================================
   BODY SCROLL LOCK — toggled by JS
   ============================================================================= */

body.tmcd-modal-open {
    overflow: hidden;
}

/* =============================================================================
   SPINNING ANIMATION — refresh button in-flight
   ============================================================================= */

@keyframes tmcdBmSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.tmcd-bm-spinning {
    animation: tmcdBmSpin 0.8s linear infinite;
}

/* =============================================================================
   RESPONSIVE — collapse toolbar at 900 px
   ============================================================================= */

@media (max-width: 900px) {

    #tmcd-byod-messages-wrapper,
    .tmcd-byod-messages-wrapper {
        padding: 16px;
    }

    .tmcd-bm-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .tmcd-bm-search-wrapper {
        min-width: unset;
        width: 100%;
    }

    .tmcd-bm-filter-wrapper,
    .tmcd-bm-filter-select {
        width: 100%;
    }

    .tmcd-bm-message-row {
        flex-wrap: wrap;
        padding: 12px 14px;
    }

    .tmcd-bm-row-meta {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 12px;
    }

    /* On touch devices there is no hover — always show delete button */
    .tmcd-bm-delete-btn {
        opacity: 1;
    }

    .tmcd-bm-body-html {
        min-height: 220px;
        max-height: 46vh;
    }

    #tmcd-bm-modal .tempmails-modal-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0 !important;
    }
}
