/* ═══════════════════════════════════════════════════════════════
   MODAL SYSTEM — Overlay, Dialog, Prompt, Action Menu, Toast
   ═══════════════════════════════════════════════════════════════ */

/* ─── Overlay ─── */
.hb-overlay {
    position: fixed;
    inset: 0;
    z-index: 6000;
    background: rgba(0,0,0,0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease-out;
    padding: 24px;
}
.hb-overlay.visible { opacity: 1; }
.hb-overlay--light { background: rgba(0,0,0,0.15); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

/* ─── Dialog Card (centered macOS-style for ALL dialogs) ─── */
.hb-dialog {
    background: #F5F5F7;
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 24px;
    corner-shape: squircle;
    box-shadow: 0 24px 80px rgba(0,0,0,0.16), 0 0 0 0.5px rgba(0,0,0,0.04);
    width: min(420px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    transform: scale(0.94) translateY(8px);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1),
                opacity 0.18s ease-out;
}
.hb-overlay.visible .hb-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}
/* Form dialogs → slightly wider */
.hb-dialog--form {
    width: min(520px, calc(100vw - 48px));
}

/* Drag handle — hidden for centered dialogs */
.hb-dialog-handle {
    display: none;
}

/* Bottom-sheet header bar (title + cancel/done) */
.hb-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px 4px;
}
.hb-sheet-header .hb-dialog-title {
    flex: 1;
    text-align: center;
    margin: 0;
}
.hb-sheet-action {
    border: none;
    background: none;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 10px;
    transition: background 0.12s;
    min-width: 60px;
}
.hb-sheet-action:hover { background: rgba(0,0,0,0.04); }
.hb-sheet-action:active { transform: scale(0.97); }
.hb-sheet-action.cancel { color: var(--text-secondary); }
.hb-sheet-action.confirm { color: var(--system-blue); }

/* When form uses sheet layout, hide old bottom actions */
.hb-dialog--form.hb-sheet .hb-dialog-actions { display: none; }
.hb-dialog--form.hb-sheet .hb-dialog-body { padding-top: 8px; }

.hb-dialog-body {
    padding: 28px 24px 16px;
}
.hb-dialog-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
    background: rgba(0,122,255,0.08); color: var(--system-blue);
}
.hb-dialog-icon.danger { background: rgba(255,59,48,0.10); color: #FF3B30; }
.hb-dialog-icon .material-symbols-outlined { font-size: 22px; }

.hb-dialog-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0 0 6px;
}
.hb-dialog-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* Dialog input */
.hb-dialog-input {
    width: 100%;
    margin-top: 14px;
    padding: 11px 16px;
    border: 1.5px solid rgba(0,0,0,0.08);
    border-radius: 14px;
    corner-shape: squircle;
    font-size: 14px;
    font-family: var(--font-body);
    background: rgba(0,0,0,0.02);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.hb-dialog-input:focus {
    border-color: var(--system-blue);
    box-shadow: 0 0 0 3.5px rgba(0,122,255,0.10);
}

/* Dialog actions */
.hb-dialog-actions {
    display: flex;
    gap: 8px;
    padding: 12px 24px 20px;
    justify-content: flex-end;
}
.hb-dialog-btn {
    padding: 11px 24px;
    border: none;
    border-radius: 14px;
    corner-shape: squircle;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.hb-dialog-btn:active { transform: scale(0.97); transition: transform 80ms var(--ease-spring); }
.hb-dialog-btn.cancel {
    background: rgba(0,0,0,0.06);
    color: var(--text-secondary);
}
.hb-dialog-btn.cancel:hover { background: rgba(0,0,0,0.09); }
.hb-dialog-btn.confirm {
    background: var(--system-blue);
    color: white;
}
.hb-dialog-btn.confirm:hover { background: #0051A8; }
.hb-dialog-btn.confirm.danger {
    background: #FF3B30;
}
.hb-dialog-btn.confirm.danger:hover { background: #D70015; }

/* Form fields inside dialog */
.hb-dialog .be-field {
    margin-bottom: 10px;
}
.hb-dialog .be-field:last-child { margin-bottom: 0; }

/* Danger action row (e.g. Delete inside form dialogs) */
.hb-dialog-danger-row {
    padding: 0 22px 12px;
    border-top: 0.5px solid rgba(0,0,0,0.06);
    margin-top: 8px;
    padding-top: 12px;
}
.hb-dialog-danger-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sf);
    font-size: 13px;
    font-weight: 600;
    color: var(--system-red);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 0;
    opacity: 0.8;
}
.hb-dialog-danger-btn:hover { opacity: 1; }
.hb-dialog-danger-btn .material-symbols-outlined { font-size: 16px; }

/* ─── Action Menu (popover) ─── */
.hb-action-menu-wrap {
    position: fixed;
    inset: 0;
    z-index: 6001;
    pointer-events: none;
}
.hb-action-menu {
    position: fixed;
    pointer-events: auto;
    min-width: 180px;
    max-width: 280px;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(48px) saturate(180%);
    -webkit-backdrop-filter: blur(48px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 16px;
    corner-shape: squircle;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 12px 30px rgba(0,0,0,0.14), 0 0 0 0.5px rgba(0,0,0,0.04);
    padding: 5px;
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
    transform-origin: top left;
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}
.hb-action-menu.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.hb-action-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-family: var(--font-body);
    transition: background 0.12s;
}
.hb-action-item:hover { background: rgba(0,0,0,0.04); }
.hb-action-item:active { transform: scale(0.97); transition: transform 80ms var(--ease-spring); }
.hb-action-item .material-symbols-outlined { font-size: 18px; color: var(--text-tertiary); }
.hb-action-item.danger { color: #FF3B30; }
.hb-action-item.danger .material-symbols-outlined { color: #FF3B30; }
.hb-action-item.danger:hover { background: rgba(255,59,48,0.06); }

.hb-action-sep {
    height: 0;
    border-top: 0.5px solid rgba(0,0,0,0.06);
    margin: 4px 8px;
}

/* ─── Toast ─── */
.hb-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    background: rgba(40,40,42,0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 0.5px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    corner-shape: squircle;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-body);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.2,0,0,1);
    pointer-events: none;
}
.hb-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.hb-toast .material-symbols-outlined { font-size: 18px; }
.hb-toast.success .material-symbols-outlined { color: #34C759; }
.hb-toast.error .material-symbols-outlined { color: #FF3B30; }
.hb-toast.warning .material-symbols-outlined { color: #FF9500; }

/* ─── Undo Toast ─── */
.hb-undo-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 10px 16px;
    background: rgba(40,40,42,0.94);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 0.5px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    corner-shape: squircle;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-body);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.2,0,0,1);
    pointer-events: auto;
}
.hb-undo-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.hb-undo-toast .material-symbols-outlined {
    font-size: 18px;
    color: rgba(255,255,255,0.5);
}
.hb-undo-label {
    flex: 1;
    color: rgba(255,255,255,0.85);
    font-weight: 500;
}
.hb-undo-btn {
    padding: 5px 14px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 8px;
    color: #5AC8FA;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}
.hb-undo-btn:hover { background: rgba(255,255,255,0.25); }
.hb-undo-hint {
    font-size: 11px;
    color: rgba(255,255,255,0.3);
    font-weight: 500;
}

@media (max-width: 600px) {
    .hb-undo-toast {
        bottom: 88px;
        left: 16px; right: 16px;
        transform: translateX(0) translateY(16px);
        width: auto;
    }
    .hb-undo-toast.visible {
        transform: translateX(0) translateY(0);
    }
    .hb-undo-hint { display: none; }
}

/* (hb-overlay--center removed — base overlay is now centered) */

/* ─── Transaction Category Grid ─── */
.txn-cat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 14px;
}
.txn-cat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border: 1.5px solid rgba(0,0,0,0.08);
    border-radius: 14px;
    background: rgba(0,0,0,0.02);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    line-height: 1.2;
}
.txn-cat-pill:hover {
    background: rgba(0,122,255,0.04);
    border-color: rgba(0,122,255,0.15);
}
.txn-cat-pill.selected {
    background: rgba(0,122,255,0.08);
    border-color: var(--system-blue);
    color: var(--system-blue);
}
.txn-cat-pill .material-symbols-outlined {
    font-size: 20px;
    color: var(--text-tertiary);
    transition: color 0.15s;
}
.txn-cat-pill.selected .material-symbols-outlined {
    color: var(--system-blue);
}

/* Transaction modal sections */
.txn-modal-merchant {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 0.5px solid rgba(0,0,0,0.06);
}
.txn-modal-merchant-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: rgba(0,122,255,0.08);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.txn-modal-merchant-icon .material-symbols-outlined {
    font-size: 20px;
    color: var(--system-blue);
}
.txn-modal-merchant-info {
    flex: 1;
    min-width: 0;
}
.txn-modal-merchant-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.txn-modal-merchant-date {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}
.txn-modal-amount {
    font-family: var(--font-mono);
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.txn-modal-amount.deposit { color: var(--system-green); }

.txn-modal-section {
    margin-top: 16px;
}
.txn-modal-section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

/* Bill linker select */
.txn-bill-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid rgba(0,0,0,0.1);
    border-radius: 14px;
    font-size: 13px;
    font-family: var(--font-body);
    background: rgba(0,0,0,0.02);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
    cursor: pointer;
}
.txn-bill-select:focus {
    border-color: var(--system-blue);
}

/* Reviewed toggle */
.txn-reviewed-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 0.5px solid rgba(0,0,0,0.06);
}
.txn-reviewed-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.txn-reviewed-label .material-symbols-outlined {
    font-size: 18px;
    color: var(--text-tertiary);
}
/* txn-toggle removed — uses canonical .toggle-switch from components.css */

/* ─── Mobile adjustments ─── */
@media (max-width: 768px) {
    .hb-overlay { padding: 16px; }
    .hb-dialog { width: min(420px, calc(100vw - 32px)); }
    .hb-dialog-body { padding: 22px 20px 14px; }
    .hb-dialog-actions { padding: 10px 20px 18px; }
    .hb-dialog-title { font-size: 16px; }
    .hb-toast { bottom: 88px; }
}
