/* ════════════════════════════════════════════════════════════════
   ALZAR MOBILE HOME — Dashboard card stack for phone mode.
   All cards: full-width, height: auto, stacked in a single column.
   No fixed heights, no multi-column grids, text wraps naturally.
   ════════════════════════════════════════════════════════════════ */

/* ── Page wrapper ──────────────────────────────────────────────── */
.mh-page {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 12px 80px;
    min-height: 100%;
    box-sizing: border-box;
}

/* ── Page header / greeting ────────────────────────────────────── */
.mh-page-hdr {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 4px 4px 2px;
}
.mh-greeting {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.mh-greeting-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text, #f1f5f9);
    line-height: 1.2;
}
.mh-greeting-date {
    font-size: 13px;
    color: var(--color-text-muted, #94a3b8);
}
.mh-summary-line {
    font-size: 13px;
    color: var(--color-text-muted, #94a3b8);
    padding: 0 4px 6px;
    line-height: 1.4;
}

/* ── Generic card shell ────────────────────────────────────────── */
.mh-card {
    background: var(--color-bg-card, #1e293b);
    border: 1px solid var(--color-border, rgba(255,255,255,0.08));
    border-radius: 14px;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}
.mh-card-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    gap: 8px;
}
.mh-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.mh-card-title i {
    font-size: 15px;
    color: var(--color-primary, #0ea5e9);
}
.mh-card-link {
    font-size: 12px;
    color: var(--color-primary, #0ea5e9);
    background: none;
    border: none;
    padding: 4px 0;
    cursor: pointer;
    flex-shrink: 0;
}
.mh-card-link:active { opacity: 0.6; }

/* ── KPI number tiles ──────────────────────────────────────────── */
.mh-kpi-row {
    display: flex;
    gap: 8px;
    padding: 0 12px 12px;
    flex-wrap: wrap;
}
.mh-kpi {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    background: var(--color-bg-hover, rgba(255,255,255,0.04));
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-sizing: border-box;
}
.mh-kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text, #f1f5f9);
    line-height: 1;
}
.mh-kpi-label {
    font-size: 11px;
    color: var(--color-text-muted, #94a3b8);
}
.mh-kpi-value.is-alert { color: #ef4444; }
.mh-kpi-value.is-warn  { color: #f59e0b; }
.mh-kpi-value.is-ok    { color: #22c55e; }

/* ── Generic tappable row ──────────────────────────────────────── */
.mh-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid var(--color-border, rgba(255,255,255,0.05));
    cursor: pointer;
    transition: background 0.12s;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    background: none;
    border-left: none;
    border-right: none;
    border-bottom: none;
}
.mh-row:active { background: var(--color-bg-hover, rgba(255,255,255,0.06)); }

.mh-row-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}
.mh-row-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
/* Allow text to wrap — never truncate on fixed width */
.mh-row-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text, #f1f5f9);
    white-space: normal;
    word-break: break-word;
}
.mh-row-sub {
    font-size: 12px;
    color: var(--color-text-muted, #94a3b8);
    white-space: normal;
    word-break: break-word;
}
.mh-row-end {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.mh-row-time {
    font-size: 12px;
    color: var(--color-text-muted, #94a3b8);
}

/* ── Status chip ───────────────────────────────────────────────── */
.mh-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    text-transform: capitalize;
}

/* ── Task rows ─────────────────────────────────────────────────── */
.mh-task-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid var(--color-border, rgba(255,255,255,0.05));
}
.mh-task-check {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 2px 0;
    color: var(--color-text-muted, #94a3b8);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.mh-task-check:active { opacity: 0.6; }
.mh-task-body { flex: 1; min-width: 0; }
.mh-task-title {
    font-size: 14px;
    color: var(--color-text, #f1f5f9);
    white-space: normal;
    word-break: break-word;
}
.mh-task-title.done {
    text-decoration: line-through;
    opacity: 0.45;
}
.mh-task-meta {
    font-size: 11px;
    color: var(--color-text-muted, #94a3b8);
    margin-top: 2px;
}

/* ── Alert / reminder rows ─────────────────────────────────────── */
.mh-alert-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid var(--color-border, rgba(255,255,255,0.05));
}
.mh-alert-icon {
    flex-shrink: 0;
    font-size: 16px;
    margin-top: 1px;
    color: #f59e0b;
}
.mh-alert-icon.is-red   { color: #ef4444; }
.mh-alert-icon.is-green { color: #22c55e; }
.mh-alert-body { flex: 1; min-width: 0; }
.mh-alert-text {
    font-size: 13px;
    color: var(--color-text, #f1f5f9);
    white-space: normal;
    word-break: break-word;
}
.mh-alert-sub {
    font-size: 11px;
    color: var(--color-text-muted, #94a3b8);
    margin-top: 2px;
}

/* ── Manufacturing stage pills ─────────────────────────────────── */
.mh-stage-pills {
    display: flex;
    gap: 8px;
    padding: 0 12px 12px;
    flex-wrap: wrap;
}
.mh-stage-pill {
    flex: 1 1 auto;
    min-width: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 10px;
    background: var(--color-bg-hover, rgba(255,255,255,0.04));
    border-radius: 8px;
    border-top: 3px solid transparent;
}
.mh-stage-pill-count {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    color: var(--color-text, #f1f5f9);
}
.mh-stage-pill-label {
    font-size: 10px;
    color: var(--color-text-muted, #94a3b8);
    text-align: center;
    white-space: nowrap;
}

/* ── Overdue label ─────────────────────────────────────────────── */
.mh-overdue-label { color: #ef4444; font-weight: 600; }

/* ── Loading / empty ───────────────────────────────────────────── */
.mh-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 16px;
    color: var(--color-text-muted, #94a3b8);
    font-size: 13px;
}
.mh-empty-row {
    padding: 14px 16px;
    font-size: 13px;
    color: var(--color-text-muted, #94a3b8);
    text-align: center;
    border-top: 1px solid var(--color-border, rgba(255,255,255,0.05));
}

/* ── Spinner ───────────────────────────────────────────────────── */
@keyframes mh-spin { to { transform: rotate(360deg); } }
.mh-spin { display: inline-block; animation: mh-spin 0.8s linear infinite; }

/* ══════════════════════════════════════════════════════════════════
   QUICK-CREATE FAB + SPEED DIAL
   Lives in document.body — JS shows/hides on pageChanged.
   ══════════════════════════════════════════════════════════════════ */

.mhf-wrap {
    position: fixed;
    bottom: 80px;
    right: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;  /* children re-enable as needed */
}

/* Primary FAB */
.mhf-fab {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--color-accent, #3b82f6);
    color: #fff;
    border: none;
    font-size: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(59,130,246,0.5);
    transition: transform 0.22s ease, background 0.18s;
    pointer-events: auto;
    flex-shrink: 0;
}
.mhf-fab:active { opacity: 0.85; }
.mhf-wrap.open .mhf-fab {
    transform: rotate(45deg);
    background: #475569;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

/* Speed-dial item list */
.mhf-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

/* Each action — single cohesive pill */
.mhf-item {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 44px;
    padding: 0 18px 0 14px;
    border-radius: 22px;
    border: none;
    background: var(--color-bg-card, #1e293b);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--color-text-primary, #f1f5f9);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    opacity: 0;
    transform: translateX(20px) scale(0.88);
    transition: opacity 0.18s ease, transform 0.18s ease, background 0.12s;
    pointer-events: none;
    user-select: none;
}
.mhf-item i {
    font-size: 20px;
    flex-shrink: 0;
    line-height: 1;
}
.mhf-item.mhf-task   i { color: #a78bfa; }
.mhf-item.mhf-note   i { color: #fbbf24; }
.mhf-item.mhf-job    i { color: #34d399; }
.mhf-item.mhf-client i { color: #60a5fa; }

.mhf-wrap.open .mhf-item {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}
.mhf-wrap.open .mhf-item:nth-child(1) { transition-delay:   0ms; }
.mhf-wrap.open .mhf-item:nth-child(2) { transition-delay:  50ms; }
.mhf-wrap.open .mhf-item:nth-child(3) { transition-delay: 100ms; }
.mhf-wrap.open .mhf-item:nth-child(4) { transition-delay: 150ms; }

.mhf-item:active {
    background: var(--color-bg-hover, #273349);
    transform: scale(0.96);
}

/* Backdrop — dims page when speed dial is open */
.mhf-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 199;
    display: none;
}
.mhf-backdrop.visible { display: block; }

/* ── Quick-Create bottom sheets ───────────────────────────────── */
.mhf-sheet-bd {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 500;
    display: flex;
    align-items: flex-end;
    animation: mhf-fade-in 0.15s ease;
}
.mhf-sheet {
    width: 100%;
    max-height: 86dvh;
    background: var(--color-bg-surface, #1a1a2e);
    border-radius: 18px 18px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: mhf-slide-up 0.22s ease;
}
.mhf-sheet-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--color-border, rgba(255,255,255,0.08));
    flex-shrink: 0;
}
.mhf-sheet-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary, #f1f5f9);
}
.mhf-sheet-cancel {
    background: none;
    border: none;
    color: var(--color-text-secondary, #94a3b8);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 0;
    font-family: inherit;
}
.mhf-sheet-save {
    background: var(--color-accent, #3b82f6);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.mhf-sheet-save:disabled { opacity: 0.45; cursor: not-allowed; }
.mhf-sheet-body {
    padding: 16px 16px 28px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.mhf-field { display: flex; flex-direction: column; gap: 5px; }
.mhf-field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.mhf-field-label .req { color: #ef4444; margin-left: 2px; }
.mhf-input,
.mhf-textarea {
    background: var(--color-bg-card, #1e293b);
    border: 1px solid var(--color-border, rgba(255,255,255,0.1));
    border-radius: 9px;
    padding: 12px 13px;
    color: var(--color-text-primary, #f1f5f9);
    font-family: inherit;
    font-size: 15px;
    width: 100%;
    box-sizing: border-box;
}
.mhf-input:focus,
.mhf-textarea:focus {
    outline: none;
    border-color: var(--color-accent, #3b82f6);
}
.mhf-input::placeholder,
.mhf-textarea::placeholder { color: var(--color-text-muted, #64748b); }
.mhf-textarea { min-height: 82px; resize: vertical; line-height: 1.45; }

/* Selects — normalise to match text inputs exactly */
select.mhf-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M5 7.5l5 5 5-5'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
    cursor: pointer;
}
select.mhf-input option[disabled] { color: var(--color-text-muted, #64748b); }
/* Muted text while the "Select …" placeholder is shown */
select.mhf-input.mhf-select-empty { color: var(--color-text-muted, #64748b); }
select.mhf-input:focus {
    outline: none;
    border-color: var(--color-accent, #3b82f6);
}

/* Validation error state */
.mhf-input.mhf-invalid,
select.mhf-input.mhf-invalid { border-color: #ef4444; }
.mhf-input.mhf-invalid:focus,
select.mhf-input.mhf-invalid:focus { border-color: #ef4444; }
.mhf-field-err {
    font-size: 11.5px;
    color: #ef4444;
    margin-top: 2px;
    display: none;
}

.mhf-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .mhf-row-2 { grid-template-columns: 1fr; } }

.mhf-error-msg { font-size: 12px; color: #ef4444; }

@keyframes mhf-fade-in  { from { opacity: 0; }              to { opacity: 1; } }
@keyframes mhf-slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── Manufacturing field estimate — trim section ──────────── */

/* Visual separator before a new logical block (Trim, Notes) */
.mhf-field--section {
    margin-top: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--color-border, rgba(255,255,255,0.07));
}

.mhf-trim-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}
.mhf-trim-row {
    display: grid;
    grid-template-columns: 64px 1fr;
    align-items: center;
    gap: 10px;
}
.mhf-trim-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary, #94a3b8);
}
/* Compact inputs inside the trim grid — slightly shorter than full-height fields */
.mhf-trim-input {
    padding: 8px 11px;
    font-size: 14px;
    min-height: unset;
}
.mhf-draft-note {
    font-size: 12px;
    color: var(--color-text-muted, #64748b);
    text-align: center;
    margin: 0;
}
